ITPub博客

首页 > Linux操作系统 > Linux操作系统 > RMAN 創建復制數據庫手冊

RMAN 創建復制數據庫手冊

原创 Linux操作系统 作者:golden_zhou 时间:2011-03-11 08:16:51 0 删除 编辑

RMAN 創建復制數據庫手冊

1. 建立主库全备份.(主庫操作)
在主库与復制库中建立相同的备份路径.以Oracle用户登录

$mkdir –p /data/rman
$chmod 770 /data/rman

做一次完整的RMAN热备份,當使用RMAN管理方式建立復制數據庫時,必須首先使用RMAN備份主數據庫的所有數據文件,控制文件和歸檔日志

$rman target sys/pwd@delll10p nocatalog
RMAN> backup database include current controlfile plus archivelog format='/data/rman/%d_%s.bak';
注意:ORACLE 10G 默認備份目錄是/u01/product/flash_recovery_area,如果執行以上命令時報錯,查看alert.log 則發現db_recovery_file_dest_size空間不足,需要調整db_recovery_file_dest_size大小為4G/6G/8G/10G, 然後再執行上面的備份命令,備份成功後備份集會保存到/data/rman 及 /u01/product/flash_recovery_area

Alert.log報錯如下:
Fri Jun 18 14:40:35 2010
Errors in file /u01/product/admin/delll10/udump/delll10_ora_14682.trc:
ORA-19815: WARNING: db_recovery_file_dest_size of 4294967296 bytes is 100.00% used, and has 0 remaining bytes available.
************************************************************************
You have following choices to free up space from flash recovery area:
1. Consider changing RMAN RETENTION POLICY. If you are using Data Guard,
   then consider changing RMAN ARCHIVELOG DELETION POLICY.
2. Back up files to tertiary device such as tape using RMAN
   BACKUP RECOVERY AREA command.
3. Add disk space and increase db_recovery_file_dest_size parameter to
   reflect the new space.
4. Delete unnecessary files using RMAN DELETE command. If an operating
   system command was used to delete files, then use RMAN CROSSCHECK and
   DELETE EXPIRED commands.
************************************************************************
Deleted Oracle managed file /u01/product/flash_recovery_area/DELLL10/backupset/2010_06_18/o1_mf_nnndf_TAG20100618T144031_61p56z5b_.bkp

2. 建立存放復制數據庫各種相關文件的OS目錄.(復制數據庫操作)

$mkdir -p /u01/product/admin/dell10qc
$cd /u01/product/admin/dell10qc
$mkdir adump bdump cdump dpdump udump pfile
$mkdir -p /u01/product/oradata/dell10qc
$mkdir -p /data/dell10qc/arch


3. 建立例程服務.(復制數據庫操作)
建立復制數據庫時,需要使用ORAPWD工具為例程建立口令文件,或從主庫拷貝口令文件到復制數據庫相應目錄

$orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=oracle entries=4

$scp primary_database_ip:/$ORACLE_HOME/dbs/orapw$ORACLE_SID  $ORACLE_HOME/dbs/orapw$ORACLE_SID

4. 建立參數文件.(復制數據庫操作)

A.連接到主數據庫建立文本參數文件
$sqlplus sys/pwd@primary as sysdba
SQL>create pfile='$ORACLE_HOME/dbs/init$ORACLE_SID.ora' from spfile;

B.編輯文本參數文件
dell10qc.__db_cache_size=398458880
dell10qc.__java_pool_size=12582912
dell10qc.__large_pool_size=4194304
dell10qc.__shared_pool_size=633339904
dell10qc.__streams_pool_size=0
*.archive_lag_target=600
*.audit_file_dest='/u01/product/admin/dell10qc/adump'
*.background_dump_dest='/u01/product/admin/dell10qc/bdump'
*.compatible='10.2.0.3.0'
*.control_files='/u01/product/oradata/dell10qc/control01.ctl','/u01/product/oradata/dell10qc/control02.ctl','/data/dell10qc/control03.ctl'
*.core_dump_dest='/u01/product/admin/dell10qc/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=16
*.log_file_name_convert='/u01/product/oradata/delll10/','/u01/product/oradata/dell10qc/','/data/delll10/','/data/dell10qc/'
*.db_name='dell10qc'
*.db_recovery_file_dest='/u01/product/flash_recovery_area'
*.db_recovery_file_dest_size=4294967296
*.dispatchers='(PROTOCOL=TCP) (SERVICE=delll10XDB)'
*.job_queue_processes=10
*.log_archive_dest_1='LOCATION=/data/dell10qc/arch'
*.log_archive_format='%t_%s_%r.arc'
*.open_cursors=300
*.pga_aggregate_target=524288000
*.processes=1000
*.remote_login_passwordfile='EXCLUSIVE'
*.sessions=1105
*.sga_target=1056964608
*.undo_management='AUTO'
*.undo_retention=3600
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/u01/product/admin/dell10qc/udump'

C.建立服務參數文件
SQL>create spfile='$ORACLE_HOME/dbs/spfile$ORACLE_SID.ora' from  pfile='$ORACLE_HOME/dbs/init$ORACLE_SID.ora'

5. 將主數據庫的備份集拷貝到復制數據庫相應目錄.(主庫操作)

$scp /data/rman/* second_database_ip:/data/rman/
$scp /u01/product/flash_recovery_area second_database_ip:/u01/product/flash_recovery_area

6. 啟動例程.(復制庫操作)

$export ORACLE_SID=oraclesid
$sqlplus sys/oracle as sysdba

7. 查看主庫的備份信息.(主庫操作)
rman target sys/pwd@delll10p nocatalog
RMAN>report schema
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    1024     SYSTEM               ***     /u01/product/oradata/delll10/system01.dbf
2    2000     UNDOTBS1             ***     /u01/product/oradata/delll10/undotbs01.dbf
3    1024     SYSAUX               ***     /u01/product/oradata/delll10/sysaux01.dbf
4    5        USERS                ***     /u01/product/oradata/delll10/users01.dbf
5    4000     LOG_DATA             ***     /data/delll10/LOG_DATA01.DBF
6    4000     LOG_DATA             ***     /data/delll10/LOG_DATA02.DBF
7    4000     WIP_IDX              ***     /data/delll10/WIP_IDX01.DBF
8    4000     PART_I_TS1           ***     /data/delll10/PART_I_TS1_1.DBF
9    4000     PART_I_TS1           ***     /data/delll10/PART_I_TS1_2.DBF
10   4000     PART_D_TS2           ***     /data/delll10/PART_D_TS2_1.DBF
11   4000     LOG_IDX              ***     /data/delll10/LOG_IDX01.DBF
12   4000     SN_DATA              ***     /data/delll10/SN_DATA01.DBF
13   4000     SN_IDX               ***     /data/delll10/SN_IDX01.DBF
14   4000     PART_D_TS1           ***     /data/delll10/PART_D_TS1_1.DBF
15   4000     BASE_DATA            ***     /data/delll10/BASE_DATA01.DBF
16   4000     WIP_DATA             ***     /data/delll10/WIP_DATA01.DBF
17   4000     BASE_IDX             ***     /data/delll10/BASE_IDX01.DBF
18   4000     PART_I_TS2           ***     /data/delll10/PART_I_TS2_3.DBF
19   4000     PART_I_TS2           ***     /data/delll10/PART_I_TS2_2.DBF
20   4000     PART_I_TS2           ***     /data/delll10/PART_I_TS2_1.DBF
21   4000     LOG_IDX              ***     /data/delll10/LOG_IDX02.DBF
22   4000     LOG_DATA             ***     /data/delll10/LOG_DATA03.DBF
23   4000     PART_I_TS2           ***     /data/delll10/PART_I_TS2_4.DBF
24   4000     SN_IDX               ***     /data/delll10/SN_IDX02.DBF
25   4000     PART_D_TS2           ***     /data/delll10/PART_D_TS2_2.DBF
26   4000     WIP_IDX              ***     /data/delll10/WIP_IDX02.DBF
27   2000     LOGMNRTS             ***     /u01/product/oradata/delll10/logmnrts01.DBF

8. 建立復制數據庫腳本.(復制庫操作)
$mkdir -p /data/temp
$vi /data/temp/createdup.txt
run {
set newname for datafile 1 to '/u01/product/oradata/dell10qc/system01.dbf';
set newname for datafile 2 to '/u01/product/oradata/dell10qc/undotbs01.dbf';
set newname for datafile 3 to '/u01/product/oradata/dell10qc/sysaux01.dbf';
set newname for datafile 4 to '/u01/product/oradata/dell10qc/users01.dbf';
set newname for datafile 5 to '/data/dell10qc/LOG_DATA01.DBF';
set newname for datafile 6 to '/data/dell10qc/LOG_DATA02.DBF';
set newname for datafile 7 to '/data/dell10qc/WIP_IDX01.DBF';
set newname for datafile 8 to '/data/dell10qc/PART_I_TS1_1.DBF';
set newname for datafile 9 to '/data/dell10qc/PART_I_TS1_2.DBF';
set newname for datafile 10 to '/data/dell10qc/PART_D_TS2_1.DBF';
set newname for datafile 11 to '/data/dell10qc/LOG_IDX01.DBF';
set newname for datafile 12 to '/data/dell10qc/SN_DATA01.DBF';
set newname for datafile 13 to '/data/dell10qc/SN_IDX01.DBF';
set newname for datafile 14 to '/data/dell10qc/PART_D_TS1_1.DBF';
set newname for datafile 15 to '/data/dell10qc/BASE_DATA01.DBF';
set newname for datafile 16 to '/data/dell10qc/WIP_DATA01.DBF';
set newname for datafile 17 to '/data/dell10qc/BASE_IDX01.DBF';
set newname for datafile 18 to '/data/dell10qc/PART_I_TS2_3.DBF';
set newname for datafile 19 to '/data/dell10qc/PART_I_TS2_2.DBF';
set newname for datafile 20 to '/data/dell10qc/PART_I_TS2_1.DBF';
set newname for datafile 21 to '/data/dell10qc/LOG_IDX02.DBF';
set newname for datafile 22 to '/data/dell10qc/LOG_DATA03.DBF';
set newname for datafile 23 to '/data/dell10qc/PART_I_TS2_4.DBF';
set newname for datafile 24 to '/data/dell10qc/SN_IDX02.DBF';
set newname for datafile 25 to '/data/dell10qc/PART_D_TS2_2.DBF';
set newname for datafile 26 to '/data/dell10qc/WIP_IDX02.DBF';
set newname for datafile 27 to '/u01/product/oradata/dell10qc/logmnrts01.DBF';
set newname for tempfile 1 to '/u01/product/oradata/dell10qc/temp01.dbf';
duplicate target database to dell10qc;
}

9. 建立復制數據庫.(復制庫操作)
$rman target sys/pwd@delll10p auxiliary sys/pwd@dell10qc  cmdfile  /data/temp/createdup.txt

10. 恢復復制數據庫.(復制庫操作)

A.將主庫的歸檔日志全部拷貝到復制數據庫的相應目錄
$scp primary_database_ip:/data/oracle_sid/arch /data/oracle_sid/arch

B.恢復復制數據庫
$rman target /
RMAN> restore database;
執行restore database 時會報如下錯誤,忽略直接下一步
Starting restore at 18-JUN-10
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=1091 devtype=DISK

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 06/18/2010 17:13:52
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 27 found to restore
RMAN-06023: no backup or copy of datafile 26 found to restore
RMAN-06023: no backup or copy of datafile 25 found to restore
RMAN-06023: no backup or copy of datafile 24 found to restore
RMAN-06023: no backup or copy of datafile 23 found to restore
RMAN-06023: no backup or copy of datafile 22 found to restore
RMAN-06023: no backup or copy of datafile 21 found to restore
RMAN-06023: no backup or copy of datafile 20 found to restore
RMAN-06023: no backup or copy of datafile 19 found to restore
RMAN-06023: no backup or copy of datafile 18 found to restore
RMAN-06023: no backup or copy of datafile 17 found to restore
RMAN-06023: no backup or copy of datafile 16 found to restore
RMAN-06023: no backup or copy of datafile 15 found to restore
RMAN-06023: no backup or copy of datafile 14 found to restore
RMAN-06023: no backup or copy of datafile 13 found to restore
RMAN-06023: no backup or copy of datafile 12 found to restore
RMAN-06023: no backup or copy of datafile 11 found to restore
RMAN-06023: no backup or copy of datafile 10 found to restore
RMAN-06023: no backup or copy of datafile 9 found to restore
RMAN-06023: no backup or copy of datafile 8 found to restore
RMAN-06023: no backup or copy of datafile 7 found to restore
RMAN-06023: no backup or copy of datafile 6 found to restore
RMAN-06023: no backup or copy of datafile 5 found to restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 2 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore
RMAN> recover database;
執行recover database 時會報如下錯誤,忽略直接下一步
Starting recover at 18-JUN-10
using channel ORA_DISK_1

starting media recovery

archive log filename=/data/dell10qc/arch/1_4455_717422003.arc thread=1 sequence=4455
archive log filename=/data/dell10qc/arch/1_4456_717422003.arc thread=1 sequence=4456
archive log filename=/data/dell10qc/arch/1_4457_717422003.arc thread=1 sequence=4457
archive log filename=/data/dell10qc/arch/1_4458_717422003.arc thread=1 sequence=4458
archive log filename=/data/dell10qc/arch/1_4459_717422003.arc thread=1 sequence=4459
archive log filename=/data/dell10qc/arch/1_4460_717422003.arc thread=1 sequence=4460
archive log filename=/data/dell10qc/arch/1_4461_717422003.arc thread=1 sequence=4461
archive log filename=/data/dell10qc/arch/1_4462_717422003.arc thread=1 sequence=4462
archive log filename=/data/dell10qc/arch/1_4463_717422003.arc thread=1 sequence=4463
archive log filename=/data/dell10qc/arch/1_4464_717422003.arc thread=1 sequence=4464
archive log filename=/data/dell10qc/arch/1_4465_717422003.arc thread=1 sequence=4465
archive log filename=/data/dell10qc/arch/1_4465_717422003.arc thread=1 sequence=4466
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 06/18/2010 17:14:15
RMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile '/data/dell10qc/arch/1_4465_717422003.arc'
ORA-00310: archived log contains sequence 4465; sequence 4466 required
ORA-00334: archived log: '/data/dell10qc/arch/1_4465_717422003.arc'

11. 打開復制數據庫.(復制庫操作)
SQL>shutdown immediate;
SQL>startup nomount;
SQL>alter database mount;
SQL>alter database open resetlogs;

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/25198367/viewspace-689051/,如需转载,请注明出处,否则将追究法律责任。

请登录后发表评论 登录
全部评论

注册时间:2011-03-09

  • 博文量
    238
  • 访问量
    307276