DB

05강

ssung2 2010. 4. 21. 10:43

Oracle Administration Workshop Ⅰ

 

  • 1장 Oracle Database Architecture

    • 10g의 의미 :

      • 10 Grid (자원이 부족한 시스템은 넉넉한 시스템 자원을 갖어다가 쓴다.)
    •  Control files

      • 물리적 구조에 대한 정보 (파일 위치, 파일 이름, 파일 사이즈)
      • 상태 구조에 대한 정보

        • (운영모드[Archive log mode, NoArchive log mode])
        • 파일이 Redolog인지 Data files인지 등 구분등
      • 동기화 정보

        • 데이타 베이스 인티그리티 및 파일이 깨진건 없는지 등 체크하는 정보
      •  Backup 정보
    • Redolog files

      • 테이타 베이스가 어떻게 변경되는지 그 최근 History가 들어 있다.
    • Database Architeture

      • 물리적 구조 : Datafiles, OS Block
      • 로직컬 구조 : Database, Tablespace, Segments, Extent, Block

        • Block : 데이타 베이스 최소 IO단위임
        • Extent : 연속된 Block, Tablespace의 할당 최소 단위
    • S.G.A (Shared Global Area : 공유되는 Global 영역[메모리예용])

      • Shared Pool : 쿼리 및 실행계획을 Cache하는 메모리 공간

        • Library Chche : 실행계획이 있는 공간
        • Data Dictionary cache : 실행계획을 작성할 수 있는 정보
      •  Database Buffer Cache

        • Data files에서 읽어들인 Block이 존재하는 메모리 공간
        • Buffer공간은 Block크기와 동일하다.
      • Redo Log Buffer

        • Database Buffer Cache의 변경 되는 내용이 존재하는 메모리 공간
        • Commit 되는 순간에 LGWR에 의해 Redolog files에 쓰여진다.
        • Recode 단위로 작업이 수행된다.(Block보다 훨 작지)
      • Background Process

        • LGWR : Commit시 Redo Log Buffer를 Row단위로 Redolog files에 Write한다.
        • SMON : Instance Fail날때 복구 하는 놈(insert되기 전 instance가 Down될때)
        • PMON : 클라이언드와

          • User Process : 사용자가 DB에 접속하기 위한 Tool 등
          • Server process : User Process를 담당하는 Server Process

            • 하나의 User Process를 대응하는 Server Process가 사용하는 메모리 공간을 ==>> PGA
            • 비정상적으로 User Process 종료될때 PGA가 초기화 되지 않는다.

              이것을 감지하고 해서 가는 Background Process 가 PMON이다.

        • CKPT : 동기화 정보를 갱신한다.
        • DBW n : Database Buffer Cache의 변경된 더티 버퍼를 Data files로 Write하는 Background Process이다.

          • 여러개 띄을 수 있어용^^;  왜? 그래야 빨리 file에 적죠
        • ARCn(이건 옵션) : Redolog files을 Archive log files로 Backup 하는 Process
      • SGA 특징

        • Static SGA(정적 SGA) : 변경시는 Shutdown -> parameter file변경 -> startup
        • Dynamic SGA : DB를 Down하지 않고 명령어로 변경한다.

          • ALTER SYSTEM SET shared_pool_size = 120M; (shared pool사이즈 조정한것임)
          • 9i부터 생긴거고... 왜? 아놔 은행 싸이트 그런곳은 DB Down을 못해! 쩌러 그래서 만듬
        • ASMM(automatic shared Memory Management) 10g 부터 지원함

          • parameter의 SGA_TARGET을 0으로 설정하면 완전 자동으로 처리 된다. 리스타트? 명령? 필요 없어
    • Parameter file : 씽글 오라클 서버의 환경 정보가 있는 파일
    • Password file : 리모트 머신에서 관리자 모드로 오라클 서버에 접근할때 서버쪽에 반듯이 있어야 하는 파일
    • Archived log files : Redolog files의 History를 저장한다. (Redolog files의 백업본)
    • PGA : Program Global Area : Private to each server and background process, 공유 메모리 아냐
    • SGA Buffer 종류

      • Pinned : 현재 Access되는 Buffer (User가 조낸 Access중)
      • Free or unused : 아직 사용전(비어 있는 상태[DB 지금 켰깠지])
      • Clean : Data file로 읽어 들이후 변경 되지 않아 Buffer 상의 Data와 Data file의 데이타 이미지가 같다.이게 Clean
      • Dirty : 위에 Clean Buffer가 변경 되면 Dirty이다.
      • Free or unused -> Clean -> Pinned -> Dirty -> Clean -> Pinned -> Dirty -> Clean 반복이죠 뭐!
    • 한나의 Table은 하나의 Tablespace에만 존재 할 수 있다.

      • 근데 같은 Table이 하나의 Tablespace에 여러개 존재 할 수 있다.
    • SYSTEM tablespaces : Meta Data존재(table name, column name, password 등이 존재)
    • SYSAUX tablespaces :  추가 Meta Data존재 10g 부터존재함 
  • 2강 Installation

    • 오라클 툴

      •  Oracle Enterprice Manager

        • (WEB) Enterprice Manager Database Console : 싱글 DB관리 하는 환경
        • (WEB) Enterprice Manager Grid Control : 여러개의 DB를 관리
        • (NO WEB) Enterprice Manager Java Confole : 웹 환경이 아닐때 사용
      • Data Pump : 오라클 DB공간에서의 데이타 이동해주는 툴
      • SQL*Loader : 오라클 아닌 다른 환경의 Text데이타를 오라클에 insert하는 툴
    • 오라클 OS설치 및 DB설치 자료가 있는 site : http://www.oracle-base.com
    • Installation Option

      • OUI 실행 모드

        • lnteractive Mode : 대화형 설치? 흐흐
        • Silent Mode :  한번 설치 할때 response file 작성 한것 가지고 머신이랑 대화 없이 머신이 쭉~ 설치
        • Suppressed Mode : response file에 없는것만 물어 봄
    • 설치

      • Basic Installation

        • Create Starter Database(additional 720MB) DB Sortwere 설지하고 DB instance는 만들겠냐?
      • Advanced Installation

        • 에서 Product Language 에서 korea를 선택해줘야 OUI로 설치시 한글 깨지지 않음 
  • 3장 Creating an Oracle Database

    •  Database 환경

      • OLTP (Transaction Processing)

        • 대규모 동시 User (동시에 수천명..)
        • 극히 짧은 Tx을 요청한다.
      • OLAP(Data Warehouse)

        • 소규모의 동시 User(세~네면의 적은)
        • 극히 긴 Tx을 요청
      • OLTP+OLAP = General Purpose
    • distributed database(분산DB환경)의 대표 DB이름(Golbal Database Name)

      • acme1.oracle.com (acme1=DB명, oracle=도메인명)
    • Flash Recovery Area

      • 백업 및 복구와 관련된 파일을 저장하는 Disk Path
    • 수동으로 DB를 삭제하는 방법

      • 10g DB삭제방법
      1.  

        • $sqlplur / as sysdba

          >shutdown abort

          >startup mount Restricted

          >Drop database;

      • 9i DB 삭제 방법
      1.  

        • $sqlplus '/ as sysdba'

          >shutdown abort

          >exit

          >$rm *.ctl

          >$rm *.dbf

          >$rm *.rdb

    • User Lock풀기명령 : ALTER USER hr IDENTIFIED BY hr ACCOUNT UNLOCK;

       

  • 4장 Managing the Oracle Instance

    • 리스너와 DB의 관계는 1:1이 아니다...착각 마삼

       oms(1).jpg

    • agent

      • 해당 머신상의 리스너 & DB등 target의 정보를 OMS로 전달한다. 이후 OMS는 OMR로 이동하나 보던데!
      • OMS게 받은 명령을 agent가 직접 수행한다.(뭐..백업을 받던지 등등의 작업을 진행)
      • 즉, 리모트 환경에서 Grid Console -> OMS -> 각 머신의 Agent 가 명령을 수행한다는 것이다.
      •  Grid Console

        • $emctl start | stop oms
        • $emctl start | stop agent
      • Database Console

        • $emctl start | stop dbconsole (위에 두 명령을 한방에)
        • Database Console는 하나의 DB를 관리 하는데 그 DB자체가 OMS이다.
    • DB 깐 이후 remote에서 접근하기

      • Database 기동 및 접근
      1.  

        1. $oracle user로 login 한다.
        2. $lsnrctl start (리스너를 start한다.)
        3. $sqlplus / as sysdba

          1. >startup
          2. >exit
        4. emctl start dbconsole (개별DB의 OMS를 가동한다.)
        5. 접근 주소 확인

          1. $vi /etc/hosts 에서 DB ip 및 domain 등을 확인 기록 한다.
          2. $cd $ORACLE_HOME/install
          3. $vi portlist.ini 에서 포트 확인
          4. $vi readme.txt 에서 em등의 주소및 port를 확인 한다.

            1. 확있했으면 remote에서 접근해 보아도 좋다.
            2. 확인된 ip로 em을 접근한다.

              1. 이후 OS의 hosts파일에 em 도메인을 등록하고 도메인으로 em을 접근한다.
        6. 설치된 ip로 putty등의 tool을 사용하여 접급한다.
        7. 확인한 em주소로 접근한다.
        8. $isqlplusctl start 를 기동한다.

          1. 확인했던 isqlplus 주소로 접근하여 확인한다.
    •  Database 구조확인

      • DB가 설치된 OS단에서의 확인
      1.  

        login as: oracle
        oracle@211.183.3.240's password:
        Last login: Sat Nov 28 18:40:20 2009 from 211.183.3.248
        [oracle@orad1 ~]$ cd $ORACLE_BASE
        [oracle@orad1 oracle]$ ls
        admin  flash_recovery_area  oradata  oraInventory  product
        [oracle@orad1 oracle]$ cd oradata
        [oracle@orad1 oradata]$ ls
        ORCL
        [oracle@orad1 oradata]$ cd ORCL/
        [oracle@orad1 ORCL]$ ls
        controlfile  datafile  onlinelog
        [oracle@orad1 ORCL]$ cd controlfile/
        [oracle@orad1 controlfile]$ ls
        o1_mf_5k1rw4z2_.ctl
        [oracle@orad1 controlfile]$ cd ..
        [oracle@orad1 ORCL]$ cd datafile/
        [oracle@orad1 datafile]$ ls
        o1_mf_example_5k1rwntq_.dbf  o1_mf_temp_5k1rwjtm_.tmp
        o1_mf_sysaux_5k1rv1mn_.dbf   o1_mf_undotbs1_5k1rv1op_.dbf
        o1_mf_system_5k1rv1mh_.dbf   o1_mf_users_5k1rv1pc_.dbf
        [oracle@orad1 datafile]$ cd ..
        [oracle@orad1 ORCL]$ ls
        controlfile  datafile  onlinelog
        [oracle@orad1 ORCL]$ cd onlinelog/
        [oracle@orad1 onlinelog]$ ls
        o1_mf_1_5k1rw79t_.log  o1_mf_2_5k1rw8rd_.log  o1_mf_3_5k1rwbdd_.log
        [oracle@orad1 onlinelog]$

      • sqlplus 안에서 DB 관련 파일 확인
      1.  

        • login as: oracle
          oracle@211.183.3.240's password:
          Last login: Sat Nov 28 18:23:49 2009 from 211.183.3.248
          [oracle@orad1 ~]$ sysplus / as sysdba
          -bash: sysplus: command not found
          [oracle@orad1 ~]$ oracle
          [oracle@orad1 ~]$ sqlplus / as sysdba
        • SQL*Plus: Release 10.2.0.1.0 - Production on Sat Nov 28 18:40:44 2009
        • Copyright (c) 1982, 2005, Oracle.  All rights reserved.

        • Connected to:
          Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
          With the Partitioning, OLAP and Data Mining options
        • SQL> SELECT name FROM v$database;
        • NAME
          ---------
          ORCL
        • SQL> SELECT name FROM v$datafile;
        • NAME
          --------------------------------------------------------------------------------

          (DB 설치시 미러링 선택하여 미러링 되어 있는 상태 실제 파일은 3개)
          /u01/app/oracle/oradata/ORCL/datafile/o1_mf_system_5k1rv1mh_.dbf 
          /u01/app/oracle/oradata/ORCL/datafile/o1_mf_undotbs1_5k1rv1op_.dbf
          /u01/app/oracle/oradata/ORCL/datafile/o1_mf_sysaux_5k1rv1mn_.dbf
          /u01/app/oracle/oradata/ORCL/datafile/o1_mf_users_5k1rv1pc_.dbf
          /u01/app/oracle/oradata/ORCL/datafile/o1_mf_example_5k1rwntq_.dbf

        • SQL> SELECT member FROM v$logfile;
        • MEMBER
          --------------------------------------------------------------------------------

          (DB 설치시 미러링 선택하여 미러링 되어 있는 상태 실제 파일은 3개)
          /u01/app/oracle/oradata/ORCL/onlinelog/o1_mf_3_5k1rwbdd_.log
          /u01/app/oracle/flash_recovery_area/ORCL/onlinelog/o1_mf_3_5k1rwc4k_.log
          /u01/app/oracle/oradata/ORCL/onlinelog/o1_mf_2_5k1rw8rd_.log
          /u01/app/oracle/flash_recovery_area/ORCL/onlinelog/o1_mf_2_5k1rw9jg_.log
          /u01/app/oracle/oradata/ORCL/onlinelog/o1_mf_1_5k1rw79t_.log
          /u01/app/oracle/flash_recovery_area/ORCL/onlinelog/o1_mf_1_5k1rw814_.log

        • 6 rows selected.
        • SQL> SELECT name FROM v$controlfile;
        • NAME
          --------------------------------------------------------------------------------
          /u01/app/oracle/oradata/ORCL/controlfile/o1_mf_5k1rw4z2_.ctl
          /u01/app/oracle/flash_recovery_area/ORCL/controlfile/o1_mf_5k1rw538_.ctl
        • SQL> SELECT name FROM v$controlfile;
    • DB 다운 시키기

      1. start 반대로 하면 된다.
      2. isqlplusctl stop (isqlplus를 사용했다면 스탑)
      3. emctl stop dbconsole (em을 사용했다면 em 스탑)
      4. sqlplus / as sysdba

        1. >shutdown immediate (DB 스탑)
        2. >exit
      5.  lsnrctl stop (리스너 스탑)

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

이 글은 스프링노트에서 작성되었습니다.