3. Oracle 데이터베이스 논리 백업 및 복구

1. Oracle 논리 백업 소개
Oracle 논리 백업 의 핵심 은 데 이 터 를 복사 하 는 것 이다.Oracle 이 제공 하 는 논리 백업 과 복구 명령 은 exp / imp, expdp / impdp 가 있 습 니 다.물론 표 급 복사 (create table back as select * from table) 도 논리 백업 이 라 고 할 수 있 습 니 다.Oracle 논리 백업 은 증분 백업 을 지원 하지 않 습 니 다.데이터 복구 에 도 일치 하지 않 습 니 다.그래서 보통 데이터 이전 에 사용 되 는 작업 입 니 다.
프레젠테이션 대상 만 들 기
create tablespace lottu datafile '/data/oracle/data/lottu01.dbf' size 2G autoextend on;
create user lottu identified by li0924  default tablespace lottu;  
grant connect, resource to lottu ;
grant select any dictionary to lottu ;
create user rax identified by rax123 default tablespace lottu;  
grant connect, resource to rax ;
grant select any dictionary to rax ;
conn lottu/li0924
create table tbl_lottu as select level as id, 'lottu' as name from dual connect by level <= 10000;
create table tbl_lottu_01 as select level as id, 'lottu'||level as name from dual connect by level <= 100;
conn rax/rax123
create table tbl_rax as select level as id, 'rax' as name from dual connect by level <= 10000;

2. Oracle 내 보 내기 / 가 져 오기 명령 exp / imp
exp / imp 명령 은 가장 원시 적 인 데이터 보호 도구 입 니 다.효율 적 으로 는 확실히 좋 지 않다.클 라 이언 트 실행 지원.이 간단 한 시범 에서 어떻게 조작 하 는 지 보 여 주세요.
백업 대상 목록:
. exporting tablespace definitions
. exporting profiles
. exporting user definitions
. exporting roles
. exporting resource costs
. exporting rollback segment definitions
. exporting database links
. exporting sequence numbers
. exporting directory aliases
. exporting context namespaces
. exporting foreign function library names
. exporting PUBLIC type synonyms
. exporting private type synonyms
. exporting object type definitions
. exporting system procedural objects and actions
. exporting pre-schema procedural objects and actions
. exporting cluster definitions

2.1 내 보 내기 명령 exp
  • 내 보 내기 표 의 일부 기록
  • exp lottu/li0924 GRANTS=Y TABLES=tbl_lottu  QUERY="'where id < 100'" FILE=/home/oracle/exp/lottu01.dmp LOG=/home/oracle/exp/log/lottu01.log
  • 어떤 Schema 아래 표 내 보 내기
  • exp lottu/li0924 GRANTS=Y TABLES="(tbl_lottu,tbl_lottu_01)" FILE=/home/oracle/exp/lottu02.dmp LOG=/home/oracle/exp/log/lottu02.log
  • 어떤 Schema 의 대상 을 내 보 냅 니까
  • exp system/Oracle235 OWNER="(lottu,rax)"  FILE=/home/oracle/exp/system03.dmp LOG=/home/oracle/exp/log/system03.log
  • 전체 라 이브 러 리 내 보 내기
  • exp system/Oracle235 FULL=Y FILE=/home/oracle/exp/system04.dmp LOG=/home/oracle/exp/log/system04.log

    2.2 명령 imp 가 져 오기
    imp 는 exp 의 역방향 조작 에 해당 합 니 다.조작 하기 전에;가 져 올 대상 이 데이터베이스 에 존재 하지 않 는 지 확인 해 야 합 니 다.현지에서 복구 하면;회복 대상 을 먼저 드 롭 하기;imp 명령 을 실행 하고 있 습 니 다.
    어떤 Schema 아래 표 가 져 오기;exp 위의 예제 2
    [oracle@oracle235 ~]$ sqlplus lottu/li0924
    
    SQL*Plus: Release 11.2.0.4.0 Production on Sat Aug 4 04:42:18 2018
    
    Copyright (c) 1982, 2013, Oracle.  All rights reserved.
    
    
    Connected to:
    Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    SQL> drop table tbl_lottu;
    
    Table dropped.
    
    SQL> drop table tbl_lottu_01;
    
    Table dropped.
    
    SQL> exit
    Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    [oracle@oracle235 ~]$ imp lottu/li0924 GRANTS=Y TABLES="(tbl_lottu,tbl_lottu_01)" FILE=/home/oracle/exp/lottu02.dmp LOG=/home/oracle/imp/lottu02.log
    
    Import: Release 11.2.0.4.0 - Production on Sat Aug 4 04:43:25 2018
    
    Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
    
    
    Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
    With the Partitioning, OLAP, Data Mining and Real Application Testing options
    
    Export file created by EXPORT:V11.02.00 via conventional path
    import done in UTF8 character set and UTF8 NCHAR character set
    export server uses AL16UTF16 NCHAR character set (possible ncharset conversion)
    . importing LOTTU's objects into LOTTU
    . importing LOTTU's objects into LOTTU
    . . importing table                    "TBL_LOTTU"      10000 rows imported
    . . importing table                 "TBL_LOTTU_01"        100 rows imported
    Import terminated successfully without warnings.

    3. Oracle 내 보 내기 / 가 져 오기 명령 expdp / impdp
    expdp / impdp 는 Oracle 10G 이후 에 야 나타 납 니 다.사실 자체 사용 에 높 은 기술 함량 이 필요 한 것 은 아니다.exp / imp 보다기능 과 효율 면 에서 크게 향상 되 었 다.
    병렬 지원 작업 의 일시 정지 와 재 시작 지원 지원 대상 필터 백업 / 복구 효율 면 에서 그것 은 크게 향상 되 었 다.그래서 10G 이후 에는 exp / imp 를 버 릴 수 있 습 니 다.
    empdp 와 impdp 는 서버 의 도구 프로그램 으로 ORACLE 서버 에서 만 사용 할 수 있 고 클 라 이언 트 에서 만 사용 할 수 없습니다.사용 하기 전에 디 렉 터 리 를 만들어 야 합 니 다.다음 과 같이 시범 을 보이다.
  • 서버 에 디 렉 터 리 만 들 기
  • mkdir -p /data/ora_dir_lottu
  • 논리 디 렉 터 리 를 만 들 고 작업 하 는 사용자 에 게 지정 한 디 렉 터 리 에 작업 권한 을 부여 합 니 다
  • create directory dp_lottu as '/data/ora_dir_lottu';
    grant read,write on directory dp_lottu to lottu;

    3.1 내 보 내기 명령 expdp
  • 표 모드 로 내 보 내기
  • expdp lottu/li0924  tables=tbl_lottu,tbl_lottu_01 dumpfile=expdp_lottu01.dmp logfile=expdp_lottu01.log directory=dp_lottu
  • 표 공간 에 따라 내 보 내기
  • expdp "'/ as sysdba'" tablespaces=tp_lottu dumpfile=expdp_lottu02.dmp logfile=expdp_lottu02.log directory=dp_lottu job_name=lottu02
  • 내 보 내기 방안
  • expdp "'/ as sysdba'" SCHEMAS=lottu,rax dumpfile=expdp_lottu05.dmp logfile=expdp_lottu05.log directory=dp_lottu
  • 전체 데이터베이스 내 보 내기
  • expdp "'/ as sysdba'" dumpfile=expdp_full.dmp full=y logfile=expdp_lottu05.log directory=dp_lottu

    3.2 명령 impdp 가 져 오기
    impdp 는 명령 expdp 를 가 져 오 는 역방향 작업 에 해당 합 니 다.사용 방법 은 expdp 와 같 습 니 다.위의 expdp 를 교체 하 는 것 과 같 습 니 다.
    impdp 가 져 온 방안, 표 나 표 공간 이 dump 파일 과 일치 하지 않 습 니 다.다음 매개 변수 로 교체 할 수 있 습 니 다.
    REMAP_SCHEMA
    Objects from one schema are loaded into another schema.
    
    REMAP_TABLE
    Table names are remapped to another table.
    For example, REMAP_TABLE=HR.EMPLOYEES:EMPS.
    
    REMAP_TABLESPACE
    Tablespace objects are remapped to another tablespace.

    예제 에서 보 듯 이 \ # lottu 사용자 의 데 이 터 를 모두 표 공간 tp 로 가 져 옵 니 다.rax
    impdp "'/ as sysdba'" directory=dp_lottu dumpfile=expdp_lottu04.dmp remap_tablespace=tp_lottu:tp_rax 

    복사 표
    Oracle 에서 테이블 복사 방식:
    create table tablename_back as select * from tablename;

    좋은 웹페이지 즐겨찾기