环境介绍:
1,VM1: OEL5.8+Oracle 11.2.0.3,考虑到笔记本的性能不行,因此最初考虑的是这个VM兼顾了Physical Primary 和Casecade Standby的重任。数据库是文件系统
2,VM2: OEL5.10+11.2.0.4,数据库是ASM的环境(Oracle Restart),作为Physical Standby。
考虑到版本兼容的问题,下一篇我讲切换他们的角色;
1,让VM2做为Cascade Standby的角色(因为不同版本,不能使用正常的open,只能open upgrade,因此,如果作为Physical Standby的话,不能放倒Open read only上)。
2,让VM1上的2个11.2.0.3的库分别作为Primary和Physical standby角色
创建standby controlfile和pfile:
07:37:17 SYS@lunar>alter database create standby controlfile as '/tmp/lunar.stb.ctl'; Database altered. Elapsed: 00:00:02.16 07:37:35 SYS@lunar> 07:45:46 SYS@lunar>create pfile='/tmp/lunarstb.pfile' from spfile; File created. Elapsed: 00:00:00.24 07:46:13 SYS@lunar>
创建需要的目录:
07:43:20 SYS@lunar>show parameter reco NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ control_file_record_keep_time integer 7 db_recovery_file_dest string /stage/fast_recovery_area db_recovery_file_dest_size big integer 1190198K db_unrecoverable_scn_tracking boolean TRUE recovery_parallelism integer 0 07:43:27 SYS@lunar> 07:44:34 SYS@lunar>show parameter audit NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ audit_file_dest string /u01/app/oracle/admin/lunar/ad ump audit_sys_operations boolean FALSE audit_syslog_level string audit_trail string NONE 07:44:38 SYS@lunar>
使用备份进行恢复:
[oracle@lunar trace]$ rman target / Recovery Manager: Release 11.2.0.3.0 - Production on Sat Aug 2 07:43:12 2014 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: LUNAR (DBID=2464578389) RMAN> list backup summary; using target database control file instead of recovery catalog List of Backups =============== Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag ------- -- -- - ----------- --------------- ------- ------- ---------- --- 1 B F A DISK 17-JUL-14 1 1 NO TAG20140717T211558 2 B F A DISK 17-JUL-14 1 1 YES TAG20140717T211604 3 B F A DISK 17-JUL-14 1 1 YES TAG20140717T211604 4 B F A DISK 17-JUL-14 1 1 YES TAG20140717T211604 5 B A A DISK 17-JUL-14 1 1 YES TAG20140717T211649 6 B A A DISK 17-JUL-14 1 1 YES TAG20140717T211649 7 B A A DISK 17-JUL-14 1 1 YES TAG20140717T211649 RMAN> list backup; List of Backup Sets =================== BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 1 Full 9.61M DISK 00:00:04 17-JUL-14 BP Key: 1 Status: AVAILABLE Compressed: NO Tag: TAG20140717T211558 Piece Name: /stage/backup/PRIMA_CONTROL.bkp Standby Control File Included: Ckp SCN: 1178911 Ckp time: 17-JUL-14 BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 2 Full 54.05M DISK 00:00:32 17-JUL-14 BP Key: 2 Status: AVAILABLE Compressed: YES Tag: TAG20140717T211604 Piece Name: /stage/backup/full_0epdl9gl_1_1.rman List of Datafiles in backup set 2 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 2 Full 1178928 17-JUL-14 /stage/lunar/sysaux01.dbf 3 Full 1178928 17-JUL-14 /stage/lunar/undotbs01.dbf 5 Full 1178928 17-JUL-14 /stage/lunar/soe01.dbf BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 3 Full 58.25M DISK 00:00:33 17-JUL-14 BP Key: 3 Status: AVAILABLE Compressed: YES Tag: TAG20140717T211604 Piece Name: /stage/backup/full_0fpdl9gl_1_1.rman List of Datafiles in backup set 3 File LV Type Ckp SCN Ckp Time Name ---- -- ---- ---------- --------- ---- 1 Full 1178929 17-JUL-14 /stage/lunar/system01.dbf 4 Full 1178929 17-JUL-14 /stage/lunar/users01.dbf 6 Full 1178929 17-JUL-14 /stage/lunar/lunar01.dbf BS Key Type LV Size Device Type Elapsed Time Completion Time ------- ---- -- ---------- ----------- ------------ --------------- 4 Full 1.05M DISK 00:00:03 17-JUL-14 BP Key: 4 Status: AVAILABLE Compressed: YES Tag: TAG20140717T211604 Piece Name: /stage/backup/full_0gpdl9ho_1_1.rman Control File Included: Ckp SCN: 1178948 Ckp time: 17-JUL-14 BS Key Size Device Type Elapsed Time Completion Time ------- ---------- ----------- ------------ --------------- 5 5.06M DISK 00:00:02 17-JUL-14 BP Key: 5 Status: AVAILABLE Compressed: YES Tag: TAG20140717T211649 Piece Name: /stage/backup/arch_0hpdl9i1_1_1.rman List of Archived Logs in backup set 5 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- --------- ---------- --------- 1 1 1069557 16-JUL-14 1080642 16-JUL-14 1 2 1080642 16-JUL-14 1080645 16-JUL-14 1 3 1080645 16-JUL-14 1080649 16-JUL-14 1 4 1080649 16-JUL-14 1080680 16-JUL-14 1 5 1080680 16-JUL-14 1080684 16-JUL-14 BS Key Size Device Type Elapsed Time Completion Time ------- ---------- ----------- ------------ --------------- 6 22.52M DISK 00:00:06 17-JUL-14 BP Key: 6 Status: AVAILABLE Compressed: YES Tag: TAG20140717T211649 Piece Name: /stage/backup/arch_0ipdl9i1_1_1.rman List of Archived Logs in backup set 6 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- --------- ---------- --------- 1 6 1080684 16-JUL-14 1113407 16-JUL-14 1 7 1113407 16-JUL-14 1145484 17-JUL-14 BS Key Size Device Type Elapsed Time Completion Time ------- ---------- ----------- ------------ --------------- 7 10.74M DISK 00:00:03 17-JUL-14 BP Key: 7 Status: AVAILABLE Compressed: YES Tag: TAG20140717T211649 Piece Name: /stage/backup/arch_0jpdl9i5_1_1.rman List of Archived Logs in backup set 7 Thrd Seq Low SCN Low Time Next SCN Next Time ---- ------- ---------- --------- ---------- --------- 1 8 1145484 17-JUL-14 1178967 17-JUL-14 1 9 1178967 17-JUL-14 1178977 17-JUL-14 RMAN>
使用screen在后台传输rman备份集:
[root@lunar ~]# screen -S lunar [root@lunar ~]# su - oracle [oracle@lunar ~]$ . lunar.env [oracle@lunar ~]$ env|grep ORA ORACLE_SID=lunar ORACLE_BASE=/u01/app/oracle ORACLE_HOME=/u01/app/oracle/product/11.2.0.3/dbhome_1 [oracle@lunar ~]$ cd /stage [oracle@lunar stage]$ cd backup [oracle@lunar backup]$ ls arch_0hpdl9i1_1_1.rman arch_0jpdl9i5_1_1.rman bk.sql full_0fpdl9gl_1_1.rman pfile_lunar.ora arch_0ipdl9i1_1_1.rman bk.log full_0epdl9gl_1_1.rman full_0gpdl9ho_1_1.rman PRIMA_CONTROL.bkp [oracle@lunar backup]$ ll total 165412 -rw-r----- 1 oracle oinstall 5302272 Jul 17 21:16 arch_0hpdl9i1_1_1.rman -rw-r----- 1 oracle oinstall 23611392 Jul 17 21:16 arch_0ipdl9i1_1_1.rman -rw-r----- 1 oracle oinstall 11265024 Jul 17 21:16 arch_0jpdl9i5_1_1.rman -rw-r--r-- 1 oracle oinstall 5155 Jul 17 21:16 bk.log -rw-r--r-- 1 oracle oinstall 405 Jul 17 21:15 bk.sql -rw-r----- 1 oracle oinstall 56680448 Jul 17 21:16 full_0epdl9gl_1_1.rman -rw-r----- 1 oracle oinstall 61087744 Jul 17 21:16 full_0fpdl9gl_1_1.rman -rw-r----- 1 oracle oinstall 1114112 Jul 17 21:16 full_0gpdl9ho_1_1.rman -rw-r--r-- 1 oracle oinstall 624 Jul 17 21:32 pfile_lunar.ora -rw-r----- 1 oracle oinstall 10092544 Jul 17 21:16 PRIMA_CONTROL.bkp [oracle@lunar backup]$ scp * oracle@192.168.56.26:/stage/backup/ oracle@192.168.56.26's password: [detached] [root@lunar ~]# screen -ls There is a screen on: 11012.lunar (Detached) 1 Socket in /var/run/screen/S-root. [root@lunar ~]# ps -ef|grep 11012 root 11012 1 0 08:10 ? 00:00:00 SCREEN -S lunar root 11013 11012 0 08:10 pts/2 00:00:00 /bin/bash root 11087 10627 0 08:14 pts/0 00:00:00 grep 11012 [root@lunar ~]# screen -r 11012 [oracle@lunar stage]$ cd backup [oracle@lunar backup]$ ls arch_0hpdl9i1_1_1.rman arch_0jpdl9i5_1_1.rman bk.sql full_0fpdl9gl_1_1.rman pfile_lunar.ora arch_0ipdl9i1_1_1.rman bk.log full_0epdl9gl_1_1.rman full_0gpdl9ho_1_1.rman PRIMA_CONTROL.bkp [oracle@lunar backup]$ ll total 165412 -rw-r----- 1 oracle oinstall 5302272 Jul 17 21:16 arch_0hpdl9i1_1_1.rman -rw-r----- 1 oracle oinstall 23611392 Jul 17 21:16 arch_0ipdl9i1_1_1.rman -rw-r----- 1 oracle oinstall 11265024 Jul 17 21:16 arch_0jpdl9i5_1_1.rman -rw-r--r-- 1 oracle oinstall 5155 Jul 17 21:16 bk.log -rw-r--r-- 1 oracle oinstall 405 Jul 17 21:15 bk.sql -rw-r----- 1 oracle oinstall 56680448 Jul 17 21:16 full_0epdl9gl_1_1.rman -rw-r----- 1 oracle oinstall 61087744 Jul 17 21:16 full_0fpdl9gl_1_1.rman -rw-r----- 1 oracle oinstall 1114112 Jul 17 21:16 full_0gpdl9ho_1_1.rman -rw-r--r-- 1 oracle oinstall 624 Jul 17 21:32 pfile_lunar.ora -rw-r----- 1 oracle oinstall 10092544 Jul 17 21:16 PRIMA_CONTROL.bkp [oracle@lunar backup]$ scp * oracle@192.168.56.26:/stage/backup/ oracle@192.168.56.26's password: arch_0hpdl9i1_1_1.rman 100% 5178KB 5.1MB/s 00:00 arch_0ipdl9i1_1_1.rman 100% 23MB 22.5MB/s 00:01 arch_0jpdl9i5_1_1.rman 100% 11MB 10.7MB/s 00:01 bk.log 100% 5155 5.0KB/s 00:00 bk.sql 100% 405 0.4KB/s 00:00 full_0epdl9gl_1_1.rman 100% 54MB 13.5MB/s 00:04 full_0fpdl9gl_1_1.rman 100% 58MB 4.2MB/s 00:14 full_0gpdl9ho_1_1.rman 100% 1088KB 1.1MB/s 00:00 pfile_lunar.ora 100% 624 0.6KB/s 00:00 PRIMA_CONTROL.bkp 100% 9856KB 4.8MB/s 00:02 [oracle@lunar backup]$ logout [root@lunar ~]#
安装cascade的screen(这个步骤跟本次操作没有关系,不过是临时遇到了,顺手做了一下):
[root@lunar ~]# cd /etc/yum.repos.d [root@lunar yum.repos.d]# wget http://public-yum.oracle.com/public-yum-el5.repo --2014-08-02 16:36:47-- http://public-yum.oracle.com/public-yum-el5.repo Resolving public-yum.oracle.com... 198.172.88.104 Connecting to public-yum.oracle.com|198.172.88.104|:80... connected. HTTP request sent, awaiting response... 200 OK Length: 4550 (4.4K) 1 Saving to: `public-yum-el5.repo.2' 100%[=============================================================================================================================>] 4,550 --.-K/s in 0s 2014-08-02 16:36:51 (80.1 MB/s) - `public-yum-el5.repo.2' saved [4550/4550] [root@lunar yum.repos.d]# yum install screen* Loaded plugins: rhnplugin, security This system is not registered with ULN. You can use up2date --register to register. ULN support will be disabled. el5_latest | 1.4 kB 00:00 ol5_UEK_latest | 1.2 kB 00:00 Setting up Install Process Resolving Dependencies --> Running transaction check ---> Package screen.x86_64 0:4.0.3-4.el5 set to be updated --> Finished Dependency Resolution Dependencies Resolved ======================================================================================================================================================================= Package Arch Version Repository Size ======================================================================================================================================================================= Installing: screen x86_64 4.0.3-4.el5 el5_latest 571 k Transaction Summary ======================================================================================================================================================================= Install 1 Package(s) Upgrade 0 Package(s) Total download size: 571 k Is this ok [y/N]: y Downloading Packages: screen-4.0.3-4.el5.x86_64.rpm | 571 kB 00:03 Running rpm_check_debug Running Transaction Test Finished Transaction Test Transaction Test Succeeded Running Transaction Installing : screen 1/1 Installed: screen.x86_64 0:4.0.3-4.el5 Complete! [root@lunar yum.repos.d]# scp oracle@192.168.56.66:/tmp/lunarstb.pfile . scp oracle@192.168.56.66:/tmp/lunar.stb.ctl .
配置主库的参数:
[oracle@lunar backup]$ cat lunarstb.pfile *.audit_file_dest='/u01/app/oracle/admin/lunar/adump' *.audit_trail='none' *.compatible='11.2.0.3.0' *.control_files='/stage/lunar/control01.ctl','/stage/lunar/control02.ctl' *.db_block_size=8192 *.db_domain='' *.db_name='lunar' *.db_recovery_file_dest='/stage/fast_recovery_area' *.db_recovery_file_dest_size=1218762752 *.deferred_segment_creation=FALSE *.diagnostic_dest='/u01/app/oracle' *.filesystemio_options='setall' *.open_cursors=300 *.pga_aggregate_target=153092096 *.processes=150 *.remote_login_passwordfile='EXCLUSIVE' *.sec_return_server_release_banner=FALSE *.sga_target=629145600 *.undo_tablespace='UNDOTBS1' *.db_unique_name='lunarp' *.log_archive_config='DG_CONFIG=(lunarp,lunars,lunarc)' *.fal_server='lunars' *.fal_client='lunarp' *.log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=lunarp' *.log_archive_dest_2='SERVICE=lunars LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=lunars' *.log_archive_dest_3='SERVICE=lunarc LGWR SYNC AFFIRM VALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE) DB_UNIQUE_NAME=lunarc' *.log_archive_dest_state_1='ENABLE' *.log_archive_dest_state_2='ENABLE' *.log_archive_dest_state_3='ENABLE' *.log_file_name_convert='+DATA/lunars/onlinelog/','/stage/lunar/' *.db_file_name_convert='+DATA/lunars/datafile/','/stage/lunar/' *.standby_file_management=auto *.service_names='lunar'
Physical Standby的参数文件:
*.db_unique_name='lunars' *.log_archive_config='DG_CONFIG=(lunarp,lunars,lunarc)' *.fal_server='lunarp' *.fal_client='lunars' *.log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=lunars' *.log_archive_dest_2='SERVICE=lunarp LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=lunarp' *.log_archive_dest_3='SERVICE=lunarc LGWR SYNC AFFIRM VALID_FOR=(STANDBY_LOGFILES,STANDBY_ROLE) DB_UNIQUE_NAME=lunarc' *.log_archive_dest_state_1='ENABLE' *.log_archive_dest_state_2='ENABLE' *.log_archive_dest_state_3='ENABLE' *.log_file_name_convert='/stage/lunar/','+DATA' *.db_file_name_convert='/stage/lunar/','+DATA' *.standby_file_management=auto *.DB_CREATE_FILE_DEST='+DATA' *.DB_CREATE_ONLINE_LOG_DEST_1='+DATA' *.control_files='+data/lunars/control01.ctl','+data/lunars/control02.ctl' *.service_names='lunar'
Cascade Standby的参数:
*.db_unique_name='lunarc' log_archive_config='DG_CONFIG=(lunarp,lunars,lunarc)' *.fal_server='lunarp','lunars' *.fal_client='lunarc' *.log_archive_dest_1='LOCATION=USE_DB_RECOVERY_FILE_DEST VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=lunarc' *.log_archive_dest_2='SERVICE=lunars LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=lunars' *.log_archive_dest_state_1='ENABLE' *.log_archive_dest_state_2='ENABLE' *.log_file_name_convert='/stage/lunar/','/stage/lunar/' *.db_file_name_convert='/stage/lunar/','/stage/lunar/' *.standby_file_management=auto *.service_names='lunar'
其余的过程就简单了,跟普通的ADG没什么分别:
1,分别在physical standby和cascade standby上做恢复standby controlfile和restore database。
2,使用alter database recover managed standby database using current logfile disconnect from session;应用日志了。
3,添加standby redo log:
alter database add standby logfile group 4(‘+DATA’) size 50M;
alter database add standby logfile group 5(‘+DATA’) size 50M;
alter database add standby logfile group 6(‘+DATA’) size 50M;
alter database add standby logfile group 7(‘+DATA’) size 50M;
最终的同步信息:
配置完成后,主库信息:
18:30:03 SYS@lunarp>show parameter name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_file_name_convert string +DATA/lunars/, /stage/lunar/ db_name string lunar db_unique_name string lunarp global_names boolean FALSE instance_name string lunarp lock_name_space string log_file_name_convert string +DATA/lunars/, /stage/lunar/ processor_group_name string service_names string lunar 18:30:14 SYS@lunarp> 18:30:14 SYS@lunarp>SELECT PROCESS, STATUS, THREAD#, SEQUENCE#, BLOCK#, BLOCKS FROM V$MANAGED_STANDBY; PROCESS STATUS THREAD# SEQUENCE# BLOCK# BLOCKS --------- ------------ ---------- ---------- ---------- ---------- ARCH CLOSING 1 32 1 1071 ARCH CLOSING 1 29 1 476 ARCH CLOSING 1 8 69633 405 ARCH CLOSING 1 32 1 1071 LGWR WRITING 1 33 42656 1 Elapsed: 00:00:00.01 18:31:19 SYS@lunarp>archive log list Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 31 Next log sequence to archive 33 Current log sequence 33 18:32:34 SYS@lunarp>
Physical Standby的信息:
18:30:38 SYS@lunarc>show parameter name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ db_file_name_convert string /stage/lunar/, /tempdisk/lunar c/ db_name string lunar db_unique_name string lunarc global_names boolean FALSE instance_name string lunarc lock_name_space string log_file_name_convert string /stage/lunar/, /tempdisk/lunar c/ processor_group_name string service_names string lunar 18:30:41 SYS@lunarc> 18:31:47 SYS@lunarc>SELECT PROCESS, STATUS, THREAD#, SEQUENCE#, BLOCK#, BLOCKS FROM V$MANAGED_STANDBY; PROCESS STATUS THREAD# SEQUENCE# BLOCK# BLOCKS --------- ------------ ---------- ---------- ---------- ---------- ARCH CLOSING 1 31 2048 646 ARCH CLOSING 1 32 1 1071 ARCH OPENING 1 10 0 0 ARCH CONNECTED 0 0 0 0 MRP0 WAIT_FOR_LOG 1 33 0 0 RFS IDLE 0 0 0 0 RFS IDLE 0 0 0 0 RFS IDLE 0 0 0 0 RFS IDLE 0 0 0 0 9 rows selected. Elapsed: 00:00:00.00 18:31:48 SYS@lunarc>
Cascade Standby的信息:
SQL> show parameter name NAME TYPE VALUE ------------------------------------ ----------- ------------------------------ cell_offloadgroup_name string db_file_name_convert string /stage/lunar/, +DATA/lunars/ db_name string lunar db_unique_name string lunars global_names boolean FALSE instance_name string lunars lock_name_space string log_file_name_convert string /stage/lunar/, +DATA/lunars/ processor_group_name string service_names string lunar SQL> SELECT PROCESS, STATUS, THREAD#, SEQUENCE#, BLOCK#, BLOCKS FROM V$MANAGED_STANDBY; PROCESS STATUS THREAD# SEQUENCE# BLOCK# BLOCKS --------- ------------ ---------- ---------- ---------- ---------- ARCH CLOSING 1 31 1 2693 ARCH CLOSING 1 32 1 1071 ARCH CONNECTED 0 0 0 0 ARCH CLOSING 1 32 1 1071 RFS IDLE 0 0 0 0 RFS IDLE 0 0 0 0 RFS IDLE 1 33 42696 1 7 rows selected. SQL>
切换是很里灵活的,后续将任意切换