本文共 24193 字,大约阅读时间需要 80 分钟。
根据视频演示,请自己手动完成视频中的实验内容并把关键步骤截图
一 主库LEO1配置
LEO11.启动归档模式并打开force logging
[oracle@odd ~]$ export ORACLE_SID=LEO1
[oracle@odd ~]$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.1.0 - Production on Sat Mar 1 17:29:56 2014Copyright (c) 1982, 2005, Oracle. All rights reserved.Connected to an idle instance.SQL> startup mountORACLE instance started.Total System Global Area 419430400 bytesFixed Size 1219784 bytesVariable Size 167772984 bytesDatabase Buffers 247463936 bytesRedo Buffers 2973696 bytesDatabase mounted.SQL> archive log listDatabase log mode Archive ModeAutomatic archival EnabledArchive destination /home/oracle/oracle/arcdataOldest online log sequence 13Next log sequence to archive 15Current log sequence 15SQL> alter database force logging;Database altered.SQL> select force_logging from v$database;FOR---YESSQL> alter database open;Database altered.SQL> select member from v$logfile where rownum=1;MEMBER--------------------------------------------------------------------------------/home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/redo01.logSQL> !ls /home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/redo*/home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/redo01.log /home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/redo03.log/home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/redo02.logSQL> select group# from v$log; GROUP#---------- 1 2 32.添加standby logfile 用于接收来自主库的redo日志SQL> alter database add standby logfile group 4 ('/home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/standbylog4a.log','/home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/standbylog4b.log') size 100m;Database altered.SQL> alter database add standby logfile group 5 ('/home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/standbylog5a.log','/home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/standbylog5b.log') size 100m;Database altered.SQL> alter database add standby logfile group 6 ('/home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/standbylog6a.log','/home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/standbylog6b.log') size 100m;Database altered.SQL> alter database add standby logfile group 7 ('/home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/standbylog7a.log','/home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/standbylog7b.log') size 100m;Database altered.SQL> select group#,status from v$standby_log; GROUP# STATUS---------- ---------- 4 UNASSIGNED 5 UNASSIGNED 6 UNASSIGNED 7 UNASSIGNEDSQL>3.配置网络
在tnsnames.ora文件中添加LEO3连接串[oracle@odd ~]$ vim /home/oracle/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora[oracle@odd ~]$ tail -n 8 /home/oracle/oracle/product/10.2.0/db_1/network/admin/tnsnames.oraLEO3= (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=even)(PORT=1521)) (CONNECT_DATA= (SERVER=DEDICATED) (SERVICE_NAME=LEO3) ) )[oracle@odd ~]$ [oracle@odd ~]$ mkdir -p /home/oracle/arch/LEO1[oracle@odd ~]$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.1.0 - Production on Sat Mar 1 18:10:17 2014Copyright (c) 1982, 2005, Oracle. All rights reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionWith the Partitioning, OLAP and Data Mining optionsSQL> create pfile from spfile;File created.SQL> exitDisconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionWith the Partitioning, OLAP and Data Mining options4.修改主库LEO1参数文件
[oracle@odd ~]$ vim /home/oracle/oracle/product/10.2.0/db_1/dbs/initLEO1.ora
[oracle@odd ~]$ tail -n 18 /home/oracle/oracle/product/10.2.0/db_1/dbs/initLEO1.ora##parameter for Primary Databasedb_name='LEO1'db_unique_name=LEO1 log_archive_format=%t_%s_%r.arc log_archive_config='DG_CONFIG=(LEO1,LEO3)' log_archive_dest_1='location=/home/oracle/arch/LEO1 valid_for=(all_logfiles,all_roles) db_unique_name=LEO1'log_archive_dest_2='service=LEO3 lgwr sync valid_for=(online_logfiles,primary_role) db_unique_name=LEO3'log_archive_dest_state_1=enablelog_archive_dest_state_2=enableremote_login_passwordfile=exclusive##parameter for Standby Databasefal_server=LEO3fal_client=LEO1standby_file_management=autodb_file_name_convert='LEO3','LEO1'log_file_name_convert='LEO3','LEO1'[oracle@odd ~]$ [oracle@odd ~]$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.1.0 - Production on Sat Mar 1 18:18:28 2014Copyright (c) 1982, 2005, Oracle. All rights reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionWith the Partitioning, OLAP and Data Mining optionsSQL> show parameter listenerNAME TYPE------------------------------------ --------------------------------VALUE------------------------------local_listener stringLISTENER_LEO1remote_listener stringSQL> shutdown immediateDatabase closed.Database dismounted.ORACLE instance shut down.SQL> create spfile from pfile;File created.SQL> 二 备库LEO3配置1.创建密码文件
注意密码文件需要保持与主库一致,我们采用复制主库密码文件到备库的方式,如果用重建的方式可能引起两边不一致报错[oracle@odd ~]$ scp /home/oracle/oracle/product/10.2.0/db_1/dbs/orapwLEO1 even:/home/oracle/oracle/product/10.2.0/db_2/dbs/orapwLEO3
oracle@even's password: orapwLEO1 100% 1536 1.5KB/s 00:00 [oracle@odd ~]$ 2.创建转储目录和归档目录[oracle@even ~]$ mkdir -p /home/oracle/oracle/admin/LEO3/{a,b,c,u}dump[oracle@even ~]$ mkdir -p /home/oracle/arch/LEO3[oracle@even ~]$3.冷备主库
[oracle@odd ~]$ cd /home/oracle/oracle/product/10.2.0/db_1/oradata/[oracle@odd oradata]$ lsLEO1[oracle@odd oradata]$ tar -czvf LEO1.tar LEO1LEO1/LEO1/control01.ctlLEO1/redo01.logLEO1/standbylog6b.logLEO1/sysaux01.dbfLEO1/standbylog6a.logLEO1/control02.ctlLEO1/part2_01.dbfLEO1/standbylog7a.logLEO1/standbylog5a.logLEO1/redo03.logLEO1/undotbs01.dbfLEO1/leo101.dbfLEO1/part3_01.dbfLEO1/move_tbs.dbfLEO1/standbylog5b.logLEO1/users01.dbfLEO1/standbylog4a.logLEO1/redo02.logLEO1/standbylog7b.logLEO1/system01.dbfLEO1/assm01.dbfLEO1/standbylog4b.logLEO1/part4_01.dbfLEO1/part1_01.dbfLEO1/tsport01.dbfLEO1/temp01.dbfLEO1/control03.ctlLEO1/mssm01.dbf[oracle@odd oradata]$ scp LEO1.tar even:/home/oracle/oracle/oradata/oracle@even's password: LEO1.tar 100% 105MB 52.5MB/s 00:02 [oracle@odd oradata]$ scp /home/oracle/oracle/product/10.2.0/db_1/dbs/initLEO1.ora even:/home/oracle/oracle/product/10.2.0/db_2/dbs/initLEO3.oraoracle@even's password: initLEO1.ora 100% 1995 2.0KB/s 00:00 [oracle@odd oradata]$ [oracle@even ~]$ cd /home/oracle/oracle/oradata/[oracle@even oradata]$ lsLEO1.tar LEO2 TEST[oracle@even oradata]$ mkdir LEO3[oracle@even oradata]$ tar -zxvf LEO1.tar -C LEO3LEO1/LEO1/control01.ctlLEO1/redo01.logLEO1/standbylog6b.logLEO1/sysaux01.dbfLEO1/standbylog6a.logLEO1/control02.ctlLEO1/part2_01.dbfLEO1/standbylog7a.logLEO1/standbylog5a.logLEO1/redo03.logLEO1/undotbs01.dbfLEO1/leo101.dbfLEO1/part3_01.dbfLEO1/move_tbs.dbfLEO1/standbylog5b.logLEO1/users01.dbfLEO1/standbylog4a.logLEO1/redo02.logLEO1/standbylog7b.logLEO1/system01.dbfLEO1/assm01.dbfLEO1/standbylog4b.logLEO1/part4_01.dbfLEO1/part1_01.dbfLEO1/tsport01.dbfLEO1/temp01.dbfLEO1/control03.ctlLEO1/mssm01.dbf[oracle@even oradata]$ ls LEO3/LEO1[oracle@even oradata]$ mv LEO3/LEO1/* LEO3/[oracle@even oradata]$ ls LEO3assm01.dbf LEO1 part1_01.dbf redo01.log standbylog4b.log standbylog6b.log system01.dbf users01.dbfcontrol01.ctl leo101.dbf part2_01.dbf redo02.log standbylog5a.log standbylog7a.log temp01.dbfcontrol02.ctl move_tbs.dbf part3_01.dbf redo03.log standbylog5b.log standbylog7b.log tsport01.dbfcontrol03.ctl mssm01.dbf part4_01.dbf standbylog4a.log standbylog6a.log sysaux01.dbf undotbs01.dbf[oracle@even oradata]$ rm LEO3/LEO1/ -r[oracle@even oradata]$ rm LEO3/control0*.ctl -f[oracle@even oradata]$ ls LEO3assm01.dbf part1_01.dbf redo01.log standbylog4b.log standbylog6b.log system01.dbf users01.dbfleo101.dbf part2_01.dbf redo02.log standbylog5a.log standbylog7a.log temp01.dbfmove_tbs.dbf part3_01.dbf redo03.log standbylog5b.log standbylog7b.log tsport01.dbfmssm01.dbf part4_01.dbf standbylog4a.log standbylog6a.log sysaux01.dbf undotbs01.dbf[oracle@even oradata]$4.生成备库的控制文件@LEO1
[oracle@odd oradata]$ sqlplus / as sysdbaSQL*Plus: Release 10.2.0.1.0 - Production on Sat Mar 1 20:14:37 2014Copyright (c) 1982, 2005, Oracle. All rights reserved.Connected to an idle instance.SQL> startup mountORACLE instance started.Total System Global Area 419430400 bytesFixed Size 1219784 bytesVariable Size 167772984 bytesDatabase Buffers 247463936 bytesRedo Buffers 2973696 bytesDatabase mounted.SQL> alter database create standby controlfile as '/home/oracle/control01.ctl';Database altered.SQL> ! [oracle@odd oradata]$ scp /home/oracle/control01.ctl even:/home/oracle/oracle/oradata/oracle@even's password: control01.ctl 100% 6896KB 6.7MB/s 00:00 [oracle@odd oradata]$ [oracle@even oradata]$ pwd/home/oracle/oracle/oradata[oracle@even oradata]$ lscontrol01.ctl LEO1.tar LEO2 LEO3 TEST[oracle@even oradata]$ cp control01.ctl LEO3/control01.ctl[oracle@even oradata]$ cp control01.ctl LEO3/control02.ctl[oracle@even oradata]$ cp control01.ctl LEO3/control03.ctl[oracle@even oradata]$5.准备备库的参数文件initLEO3.ora,这里仅列出需要修改的部分
[oracle@even oradata]$ vim /home/oracle/oracle/product/10.2.0/db_2/dbs/initLEO3.ora [oracle@even ~]$ tail -n22 /home/oracle/oracle/product/10.2.0/db_2/dbs/initLEO3.ora *.control_files='/home/oracle/oracle/oradata/LEO3/control01.ctl','/home/oracle/oracle/oradata/LEO3/control02.ctl','/home/oracle/oracle/oradata/LEO3/control03.ctl'#as primaryDB_NAME='LEO1' DB_UNIQUE_NAME=LEO3LOG_ARCHIVE_FORMAT=%t_%s_%r.arcLOG_ARCHIVE_CONFIG='DG_CONFIG=(LEO1,LEO3)'LOG_ARCHIVE_DEST_1='LOCATION=/home/oracle/arch/LEO3 VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=LEO3'LOG_ARCHIVE_DEST_2='SERVICE=LEO1 LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=LEO1' LOG_ARCHIVE_DEST_STATE_1=ENABLELOG_ARCHIVE_DEST_STATE_2=ENABLEREMOTE_LOGIN_PASSWORDFILE=EXCLUSIVE#as standbyFAL_SERVER=LEO1 FAL_CLIENT=LEO3 DB_FILE_NAME_CONVERT='/home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1','/home/oracle/oracle/oradata/LEO3'LOG_FILE_NAME_CONVERT='/home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1','/home/oracle/oracle/oradata/LEO3'STANDBY_FILE_MANAGEMENT=AUTOlocal_listener='LISTENER_LEO3'audit_file_dest='/home/oracle/oracle/admin/LEO3/adump'background_dump_dest='/home/oracle/oracle/admin/LEO3/bdump'core_dump_dest='/home/oracle/oracle/admin/LEO3/cdump'user_dump_dest='/home/oracle/oracle/admin/LEO3/udump'[oracle@even ~]$ [oracle@even ~]$ tail -n12 /home/oracle/oracle/product/10.2.0/db_2/network/admin/tnsnames.ora LEO3= (DESCRIPTION= (ADDRESS=(PROTOCOL=tcp)(HOST=even)(PORT=1521)) (CONNECT_DATA= (SERVER=DEDICATED) (SERVICE_NAME=LEO3) ) )LISTENER_LEO3 = (ADDRESS = (PROTOCOL = tcp)(HOST = even)(PORT = 1521))[oracle@even ~]$ @LEO1SQL> alter database open;
Database altered.SQL> select sequence#,applied from v$archived_log; SEQUENCE# APP---------- --- 10 NO 11 NO 12 NO 13 NO 14 NO 15 NO 16 NO 16 YES8 rows selected.SQL> select database_role,switchover_status from v$database;DATABASE_ROLE SWITCHOVER_STATUS---------------- --------------------PRIMARY SESSIONS ACTIVESQL> select process,status,group#,sequence# from v$managed_standby;PROCESS STATUS GROUP# SEQUENCE#--------- ------------ ---------------------------------------- ----------ARCH CLOSING 1 16ARCH CONNECTED N/A 0LGWR WRITING 2 17SQL> ![oracle@odd LEO1]$ tail -50f /home/oracle/oracle/product/10.2.0/db_1/admin/LEO1/bdump/alert_LEO1.log...alter database openSat Mar 1 23:10:00 2014LGWR: STARTING ARCH PROCESSESARC0 started with pid=15, OS id=17162Sat Mar 1 23:10:00 2014ARC0: Archival startedARC1: Archival startedLGWR: STARTING ARCH PROCESSES COMPLETEARC1 started with pid=16, OS id=17164Sat Mar 1 23:10:00 2014******************************************************************LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2******************************************************************LNSb started with pid=17, OS id=17166Sat Mar 1 23:10:03 2014LGWR: Standby redo logfile selected for thread 1 sequence 17 for destination LOG_ARCHIVE_DEST_2Thread 1 advanced to log sequence 17Sat Mar 1 23:10:03 2014ARC1: STARTING ARCH PROCESSESSat Mar 1 23:10:03 2014ARC0: Becoming the 'no FAL' ARCHARC0: Becoming the 'no SRL' ARCHARC0: LGWR is actively archiving destination LOG_ARCHIVE_DEST_2Sat Mar 1 23:10:03 2014Thread 1 opened at log sequence 17 Current log# 2 seq# 17 mem# 0: /home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/redo02.logSuccessful open of redo thread 1Sat Mar 1 23:10:03 2014MTTR advisory is disabled because FAST_START_MTTR_TARGET is not setSat Mar 1 23:10:03 2014SMON: enabling cache recoverySat Mar 1 23:10:03 2014ARC2: Archival startedARC1: STARTING ARCH PROCESSES COMPLETEARC1: Becoming the heartbeat ARCHARC2 started with pid=18, OS id=17170Sat Mar 1 23:10:03 2014ARC0: Standby redo logfile selected for thread 1 sequence 16 for destination LOG_ARCHIVE_DEST_2Sat Mar 1 23:10:05 2014Successfully onlined Undo Tablespace 1.Sat Mar 1 23:10:05 2014SMON: enabling tx recoverySat Mar 1 23:10:05 2014Database Characterset is US7ASCIISat Mar 1 23:10:06 2014Incremental checkpoint up to RBA [0x11.3.0], current log tail at RBA [0x11.28.0]Sat Mar 1 23:10:07 2014replication_dependency_tracking turned off (no async multimaster replication found)Starting background process QMNCQMNC started with pid=19, OS id=17172Sat Mar 1 23:10:09 2014Completed: alter database openSat Mar 1 23:16:06 2014Shutting down archive processesSat Mar 1 23:16:11 2014ARCH shutting downARC2: Archival stopped6.启动备库LEO3到mount状态
@LEO3[oracle@even ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Sat Mar 1 23:14:32 2014Copyright (c) 1982, 2005, Oracle. All rights reserved.Connected to:Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - ProductionWith the Partitioning, Oracle Label Security, OLAP and Data Mining optionsSQL> alter database recover managed standby database disconnect from session parallel 2;Database altered.SQL> select database_role,switchover_status from v$database;DATABASE_ROLE SWITCHOVER_STATUS---------------- --------------------PHYSICAL STANDBY SESSIONS ACTIVESQL> select process,status,group#,sequence# from v$managed_standby;PROCESS STATUS GROUP# SEQUENCE#--------- ------------ ---------------------------------------- ----------ARCH CLOSING 5 16ARCH CONNECTED N/A 0RFS IDLE 2 17RFS IDLE N/A 0RFS IDLE N/A 0MRP0 WAIT_FOR_LOG N/A 176 rows selected.SQL> ![oracle@even ~]$ tail /home/oracle/oracle/admin/LEO3/bdump/alert_LEO3.log...
Completed: ALTER DATABASE MOUNT
Sat Mar 1 23:10:03 2014Using STANDBY_ARCHIVE_DEST parameter default value as /home/oracle/arch/LEO3Redo Shipping Client Connected as PUBLIC-- Connected User is ValidRFS[1]: Assigned to RFS process 31791RFS[1]: Identified database type as 'physical standby'Primary database is in MAXIMUM PERFORMANCE modeSat Mar 1 23:10:03 2014RFS LogMiner: Client disabled from further notificationPrimary database is in MAXIMUM PERFORMANCE modeRFS[1]: Successfully opened standby log 4: '/home/oracle/oracle/oradata/LEO3/standbylog4a.log'Sat Mar 1 23:10:03 2014Redo Shipping Client Connected as PUBLIC-- Connected User is ValidRFS[2]: Assigned to RFS process 31793RFS[2]: Identified database type as 'physical standby'RFS[2]: Successfully opened standby log 5: '/home/oracle/oracle/oradata/LEO3/standbylog5a.log'Sat Mar 1 23:11:01 2014Redo Shipping Client Connected as PUBLIC-- Connected User is ValidRFS[3]: Assigned to RFS process 31895RFS[3]: Identified database type as 'physical standby'Sat Mar 1 23:14:34 2014alter database recover managed standby database disconnect from session parallel 2Sat Mar 1 23:14:34 2014Attempt to start background Managed Standby Recovery process (LEO3)MRP0 started with pid=20, OS id=32201Sat Mar 1 23:14:34 2014MRP0: Background Managed Standby Recovery process started (LEO3)Managed Standby Recovery not using Real Time Apply parallel recovery started with 2 processesClearing online redo logfile 1 /home/oracle/oracle/oradata/LEO3/redo01.logClearing online log 1 of thread 1 sequence number 17Sat Mar 1 23:14:40 2014Completed: alter database recover managed standby database disconnect from session parallel 2Sat Mar 1 23:14:41 2014Clearing online redo logfile 1 completeClearing online redo logfile 2 /home/oracle/oracle/oradata/LEO3/redo02.logClearing online log 2 of thread 1 sequence number 17Clearing online redo logfile 2 completeClearing online redo logfile 3 /home/oracle/oracle/oradata/LEO3/redo03.logClearing online log 3 of thread 1 sequence number 15Clearing online redo logfile 3 completeMedia Recovery Log /home/oracle/arch/LEO3/1_16_837172792.arcMedia Recovery Waiting for thread 1 sequence 17 (in transit)三 第一次切换(LEO1=>LEO3)换前LEO1库上创建swtich_tbs表空间 -> 切换 -> 检查表空间和对应的数据文件是否应用到了LEO3库创建表空间SQL> create tablespace swtich_tbs datafile '/home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/swtich_tbs.dbf' size 10m;Tablespace created.SQL> alter system archive log current;System altered.SQL>@LEO3
SQL> select * from v$tablespace where name='SWTICH_TBS'; TS# NAME INC BIG FLA ENC---------- ------------------------------ --- --- --- --- 14 SWTICH_TBS YES NO YESSQL> ![oracle@even oradata]$ tail /home/oracle/oracle/admin/LEO3/bdump/alert_LEO3.log ...Sat Mar 1 23:32:40 2014Primary database is in MAXIMUM PERFORMANCE modeRFS[1]: Successfully opened standby log 4: '/home/oracle/oracle/oradata/LEO3/standbylog4a.log'Sat Mar 1 23:32:44 2014Media Recovery Log /home/oracle/arch/LEO3/1_18_837172792.arcRecovery created file /home/oracle/oracle/oradata/LEO3/swtich_tbs.dbfSuccessfully added datafile 14 to media recoveryDatafile #14: '/home/oracle/oracle/oradata/LEO3/swtich_tbs.dbf'Media Recovery Waiting for thread 1 sequence 19 (in transit)查看LEO1库状态SQL> select database_role,switchover_status from v$database;DATABASE_ROLE SWITCHOVER_STATUS---------------- --------------------PRIMARY SESSIONS ACTIVESQL> 查看LEO3库状态SQL> select database_role,switchover_status from v$database;DATABASE_ROLE SWITCHOVER_STATUS---------------- --------------------PHYSICAL STANDBY SESSIONS ACTIVESQL>主库切换成备库,并终止存活的会话SQL> select database_role,switchover_status from v$database;DATABASE_ROLE SWITCHOVER_STATUS---------------- --------------------PRIMARY SESSIONS ACTIVESQL> alter database commit to switchover to physical standby with session shutdown;Database altered.SQL> select status,instance_name from v$instance;STATUS INSTANCE_NAME------------ ----------------STARTED LEO1SQL> shutdown immediateORA-01507: database not mountedORACLE instance shut down.SQL> startup mount; ORACLE instance started.Total System Global Area 419430400 bytesFixed Size 1219784 bytesVariable Size 171967288 bytesDatabase Buffers 243269632 bytesRedo Buffers 2973696 bytesDatabase mounted.SQL> select database_role,switchover_status from v$database;DATABASE_ROLE SWITCHOVER_STATUS---------------- --------------------PHYSICAL STANDBY TO PRIMARYSQL> select status,instance_name from v$instance;STATUS INSTANCE_NAME------------ ----------------MOUNTED LEO1SQL> alter database recover managed standby database disconnect from session parallel 2;Database altered.SQL> 备库切换成主库,并终止存活的会话SQL> alter database recover managed standby database cancel;alter database recover managed standby database cancel*ERROR at line 1:ORA-16136: Managed Standby Recovery not activeSQL> select database_role,switchover_status from v$database;DATABASE_ROLE SWITCHOVER_STATUS---------------- --------------------PHYSICAL STANDBY SESSIONS ACTIVESQL> alter database commit to switchover to primary with session shutdown;Database altered.SQL> alter database open;Database altered.SQL> select database_role,switchover_status from v$database;DATABASE_ROLE SWITCHOVER_STATUS---------------- --------------------PRIMARY SESSIONS ACTIVESQL> select sequence#,applied from v$archived_log; SEQUENCE# APP---------- --- 16 YES 17 YES 18 YES 19 YES 20 YES 21 NO 21 YES7 rows selected.SQL> select process,status,group#,sequence# from v$managed_standby;PROCESS STATUS GROUP# SEQUENCE#--------- ------------ ---------------------------------------- ----------ARCH CLOSING 5 18ARCH CLOSING N/A 21ARCH CONNECTED N/A 0LNS WRITING 1 22SQL>四 第二次切换(LEO3=>LEO1)
切换前LEO3库上创建一张表 -> 切换 -> 检查表和记录是否应用到LEO1库上
SQL> create table leo3 as select * from dba_objects;Table created.SQL> select count(*) from leo3; COUNT(*)---------- 9895SQL> alter system archive log current;System altered.SQL> select process,status,group#,sequence# from v$managed_standby;PROCESS STATUS GROUP# SEQUENCE#--------- ------------ ---------------------------------------- ----------ARCH CLOSING 5 18ARCH CLOSING N/A 21ARCH CONNECTED N/A 0LNS WRITING 3 23SQL>备库LEO1的alert中记录着恢复的过程[oracle@odd bdump]$ tail -50f /home/oracle/oracle/product/10.2.0/db_1/admin/LEO1/bdump/alert_LEO1.log ...Sat Mar 1 23:42:53 2014Redo Shipping Client Connected as PUBLIC-- Connected User is ValidRFS[3]: Assigned to RFS process 18578RFS[3]: Identified database type as 'physical standby'Sat Mar 1 23:44:41 2014RFS[2]: Possible network disconnect with primary databaseRedo Shipping Client Connected as PUBLIC-- Connected User is ValidRFS[4]: Assigned to RFS process 18761RFS[4]: Identified database type as 'physical standby'Primary database is in MAXIMUM PERFORMANCE modePrimary database is in MAXIMUM PERFORMANCE modeRFS[4]: Successfully opened standby log 5: '/home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/standbylog5a.log'Sat Mar 1 23:44:52 2014Fetching gap sequence in thread 1, gap sequence 22-22Sat Mar 1 23:44:55 2014RFS[3]: Successfully opened standby log 4: '/home/oracle/oracle/product/10.2.0/db_1/oradata/LEO1/standbylog4a.log'Sat Mar 1 23:45:22 2014Media Recovery Log /home/oracle/arch/LEO1/1_22_837172792.arcMedia Recovery Waiting for thread 1 sequence 23 (in transit)LEO1上检查leo3表,如果可以查到说明我们传递成功SQL> alter database open read only;alter database open read only*ERROR at line 1:ORA-01154: database busy. Open, close, mount, and dismount not allowed nowSQL> alter database recover managed standby database cancel;Database altered.SQL> alter database open read only;Database altered.SQL> select count(*) from leo3; COUNT(*)---------- 9895SQL> shutdown immediate;Database closed.Database dismounted.ORACLE instance shut down.SQL> startup mount;ORACLE instance started.Total System Global Area 419430400 bytesFixed Size 1219784 bytesVariable Size 171967288 bytesDatabase Buffers 243269632 bytesRedo Buffers 2973696 bytesDatabase mounted.SQL> alter database recover managed standby database disconnect from session parallel 2;Database altered.SQL> LEO3库切换成备库状态SQL> select database_role,switchover_status from v$database;DATABASE_ROLE SWITCHOVER_STATUS---------------- --------------------PRIMARY SESSIONS ACTIVESQL> alter database commit to switchover to physical standby with session shutdown;Database altered.SQL> shutdown immediateORA-01507: database not mountedORACLE instance shut down.SQL> startup mount;ORACLE instance started.Total System Global Area 419430400 bytesFixed Size 1219784 bytesVariable Size 176161592 bytesDatabase Buffers 239075328 bytesRedo Buffers 2973696 bytesDatabase mounted.SQL> alter database recover managed standby database disconnect from session parallel 2;Database altered.SQL> select database_role,switchover_status from v$database;DATABASE_ROLE SWITCHOVER_STATUS---------------- --------------------PHYSICAL STANDBY SESSIONS ACTIVESQL> LEO1库切换成主库状态
SQL> alter database recover managed standby database cancel;
alter database recover managed standby database cancel*ERROR at line 1:ORA-16136: Managed Standby Recovery not activeSQL> select database_role,switchover_status from v$database;DATABASE_ROLE SWITCHOVER_STATUS---------------- --------------------PHYSICAL STANDBY TO PRIMARYSQL> alter database commit to switchover to primary with session shutdown;Database altered.SQL> alter database open;Database altered.SQL> select database_role,switchover_status from v$database;DATABASE_ROLE SWITCHOVER_STATUS---------------- --------------------PRIMARY TO STANDBYSQL>--EOF--
转载地址:http://zgvai.baihongyu.com/