1、邏輯備份相關設置
1.邏輯備份主要是編碼格式設置
export ORACLE_SID=
export NLS_LANG=
select PROPERTY_NAME,PROPERTY_VALUE from database_properties;數據庫
2、EXP/IMP客戶端工具導出導入實驗
1.導出導入用戶的對象
exp scott/tiger@ipemsdb file=/u01/app/backdir/logico/scott_lxtb1_lxtb11.dmp tables=lxtb1,lxtb11 log=/u01/app/backdir/logico/scott_lxtb1_lxtb11.log [rows=n]
只導入表結構及數據[只導入表結構],導入前刪掉對應對象,不能添加導入
imp scott/tiger@ipemsdb file=/u01/app/backdir/logico/scott_lxtb1_lxtb11.dmp tables=lxtb1,lxtb11 log=/u01/app/backdir/logico/in_scott_lxtb1_lxtb11.log [rows=n]
2.導出導入方案
exp scott/tiger@ipemsdb owner=scott file=/u01/app/backdir/logico/owner_scott.dmp log=/u01/app/backdir/logico/owner_scott.log
導入本身的方案,重建用戶後,導入以前用戶導出本身的方案
imp scott/tiger@ipemsdb file=/u01/app/backdir/logico/owner_scott.dmp log=/u01/app/backdir/logico/in_owner_scott.log full=y
導出導入其餘用戶方案
exp system/oracle@ipemsdb owner=(hr,scott) file=/u01/app/backdir/logico/hr_scott.dmp log=/u01/app/backdir/logico/hr_scott.log
imp system/oracle@ipemsdb file=/u01/app/backdir/logico/hr_scott.dmp log=/u01/app/backdir/logico/in_hr_scott.log fromuser=hr,scott touser=hr,scott[full=y]
3.導出導入全庫
exp system/oracle@ipemsdb file=/u01/app/backdir/logico/exp_full.dmp log=/u01/app/backdir/logico/exp_full.log full=y inctype=complete
imp system/oracle@ipemsdb file=/u01/app/backdir/logico/exp_full.dmp log=/u01/app/backdir/logico/in_exp_full.log full=y ignore=y
參考資料:http://blog.csdn.net/wwww1988600/article/details/14120949服務器
3、EXPDP/IMPDP服務端工具導出導入實驗
1.設置導出導入目錄
create directory dump_dir as '/u01/app/backdir/logico';
grant read , write on directory dump_dir to scott;
drop directory dump_dir;
2.導出導入表
expdp scott/tiger directory=dump_dir dumpfile=tab.dmp TABLES=dept,emp logfile=expdp_tab.log
impdp scott/tiger directory=dump_dir dumpfile=tab.dmp tables=dept,emp logfile=impdp_tab.log
impdp system/oracle directory=dump_dir dumpfile=tab.dmp tables=dept,emp logfile=impdp_tab.log remap_schema=SCOTT:scott_a
3.導出導入方案,導入時能夠不用建立方案
expdp system/oracle directory=dump_dir dumpfile=schema.dmp schemas=scott_a,scott logfile=e_schema.log
impdp system/oracle directory=dump_dir dumpfile=schema.dmp schemas=scott_a,scott logfile=i_schema.log
4.導出導入數據庫,不會導出sys,ordsys,ordplugins,ctxsys。mdsys,lbacsys,xdb等方案對象
expdp system/oracle directory=dump_dir dumpfile=full.dmp full=y
impdp system/oracle directory=dump_dir dumpfile=full.dmp full=yoracle
4、遷移表空間(跨庫遷移)
1.使用expdp/impdp數據泵,字符集自動轉換,不用特殊設置
導出庫搭建測試數據,包括用戶,表存放同一表空間,
create tablespace oltp datafile '/u01/app/oracle/oradata/ipemsdb/datafile/oltp01.dbf' size 20M;
create user trans identified by trans default tablespace oltp;
grant connect,resource to trans;
create table trans.emp as select * from scott.emp;
create table trans.dept as select * from scott.emp;
select USERNAME,DEFAULT_TABLESPACE from dba_users where USERNAME='TRANS';
select OWNER,TABLE_NAME,TABLESPACE_NAME from dba_tables where owner='TRANS';
兩庫創導出導入目錄並授予操做權限
mkdir -p /home/oracle/dir
create directory dir as '/home/oracle/dir';
grant read , write on directory dir to public;
目標上建立用戶、解鎖、受權(沒法指定用戶的默認表空間)
create user trans identified by trans;
alter user trans account unlock;
grant connect,resource to trans;
檢查自包含,如存在清理包含(刪除外鍵)
execute dbms_tts.transport_set_check('OLTP',true);
select * from transport_set_violations;
查數據文件,將表空間設爲只讀
alter tablespace oltp read only;
expdp導出表空間
expdp system/oracle DUMPFILE=oltp.dmp DIRECTORY=dir TRANSPORT_TABLESPACES=oltp
拷貝導出的dump文件 oltp.dump 至新服務器目錄,同時拷貝數據文件至對應目錄
scp oltp.dmp 192.168.0.200:/home/oracle/dir/
scp /u01/app/oracle/oradata/ipemsdb/datafile/oltp01.dbf 192.168.0.200:/u01/app/oracle/oradata/ipemsdb/datafile/
expdp導入指定數據文件裏(導入後用戶的默認表空間爲users對象表空爲導入表空間)
impdp system/oracle dumpfile=oltp.dmp directory=dir TRANSPORT_DATAFILES='/u01/app/oracle/oradata/ipemsdb/datafile/oltp_01.dbf'
表空間設爲可讀寫模式;
alter tablespace oltp read write;app
2.使用exp/imp導入導出
檢查 NLS_LANG 設置確認字符集
搭建測試數據
檢查自包含
execute dbms_tts.transport_set_check('OLTP',true);
select * from transport_set_violations;
設置表空間未只讀模式
alter tablespace oltp read only;
只能用sys用戶操做 sys as sysdba
exp導出表空間
exp file=/u01/app/backdir/logico/exp_oltp.dmp tablespaces=oltp TRANSPORT_TABLESPACE=y
Username: sys as sysdba
Password:
拷貝 oltp.dump, 數據文件
imp導入
imp file=/u01/app/dir/exp_oltp.dmp tablespaces=oltp TRANSPORT_TABLESPACE=y datafiles='/u01/app/oracle/oradata/ipemsdb/datafile/oltp_01.dbf'
Username: sys as sysdba
Password:
設置表空間爲讀寫模式
alter tablespace oltp read write;
5、過程錯誤收集
ORA-00600: 內部錯誤代碼, 參數: [kcratr1_lastbwr], [], [], [], [], [], [], []
啓動時報以上錯誤,多半是操做系統問題,如機器名改了等
ORA-31626: job does not exist
ORA-31637: cannot create job SYS_IMPORT_TRANSPORTABLE_01 for user SYSTEM
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPV$FT_INT", line 600
ORA-39080: failed to create queues "KUPC$C_1_20151127071451" and "KUPC$S_1_20151127071451" for Data Pump job
ORA-06512: at "SYS.DBMS_SYS_ERROR", line 95
ORA-06512: at "SYS.KUPC$QUE_INT", line 1555
ORA-04031: unable to allocate 56 bytes of shared memory ("streams pool","unknown object","streams pool","fixed allocation callback")
檢查表空間是否空間不足,sga_target是否太小ide