SQL> archive log list; Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 35 Next log sequence to archive 37 Current log sequence 37
SQL> alter system set db_unique_name='kingm' scope=spfile; SQL> alter system set log_archive_config='dg_config=(kingm,kings)' scope=spfile; SQL> alter system set log_archive_dest_1='location=db_recovery_file_dest valid_for=(all_logfiles,all_roles) db_unique_name=kingm' scope=spfile; SQL> alter system set log_archive_dest_2='service=kings lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=kings' scope=spfile; SQL> alter system set fal_server='kings' scope=spfile; SQL> alter system set fal_client='kingm' scope=spfile; SQL> alter system set standby_file_management='auto' scope=spfile; SQL> alter system set log_archive_dest_state_2='defer' scope=spfile; SQL> alter system set service_names=king,kingm scope=spfile;
[oracle@king01 ~]$ cd $ORACLE_HOME/dbs [oracle@king01 dbs]$ sqlplus / as sysdba SQL> create pfile from spfile; File created. [oracle@king01 dbs]$ scp initking.ora 192.168.1.202:/u01/app/oracle/product/11.2.0/db_1/dbs [oracle@king01 dbs]$ scp orapwking 192.168.1.202:/u01/app/oracle/product/11.2.0/db_1/dbs
[oracle@king01 ~]$ mkdir -p /u01/app/oracle/backup [oracle@king02 ~]$ mkdir -p /u01/app/oracle/backup [oracle@king01 ~]$ rman target / RMAN> backup device type disk format '/u01/app/oracle/backup/%U' database plus archivelog; RMAN> backup device type disk format '/u01/app/oracle/backup/%U' current controlfile for standby; [oracle@king01 ~]$ scp /u01/app/oracle/backup/* 192.168.1.202:/u01/app/oracle/backup
[oracle@king01 ~]$ vi /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora KINGS = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.202)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = king) ) ) KINGM = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.201)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = king) ) )
[oracle@king02 ~]$ vi /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = king) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) (SID_NAME = king) ) ) LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = king02)(PORT = 1521)) ) ADR_BASE_LISTENER = /u01/app/oracle [oracle@king02 ~]$ lsnrctl start [oracle@king02 ~]$ lsnrctl status
[oracle@king02 ~]$ vi /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora KINGS = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.202)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = king) ) ) KINGM = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.201)(PORT = 1521)) ) (CONNECT_DATA = (SERVICE_NAME = king) ) )
[oracle@king01 ~]$ tnsping kings Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.202)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = king))) OK (40 msec) [oracle@king02 ~]$ tnsping kingm Used TNSNAMES adapter to resolve the alias Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.201)(PORT = 1521))) (CONNECT_DATA = (SERVICE_NAME = king))) OK (30 msec)
[oracle@king02 ~]$ cd $ORACLE_HOME/dbs [oracle@king02 dbs]$ vi initking.ora *.audit_file_dest='/u01/app/oracle/admin/king/adump' *.audit_trail='db' *.compatible='11.2.0.4.0' *.control_files='/u01/app/oracle/oradata/king/control01.ctl','/u01/app/oracle/fast_recovery_area/king/control02.ctl' *.db_block_size=8192 *.db_domain='' *.db_name='king' *.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area' *.db_recovery_file_dest_size=107374182400 *.db_unique_name='kings' *.diagnostic_dest='/u01/app/oracle' *.dispatchers='(PROTOCOL=TCP) (SERVICE=kingXDB)' *.fal_client='kings' *.fal_server='kingm' *.log_archive_config='dg_config=(kingm,kings)' *.log_archive_dest_1='location=db_recovery_file_dest valid_for=(all_logfiles,all_roles) db_unique_name=kings' *.log_archive_dest_2='service=kings lgwr async valid_for=(online_logfiles,primary_role) db_unique_name=kingm' *.memory_max_target=1073741824 *.memory_target=1073741824 *.open_cursors=300 *.processes=150 *.remote_login_passwordfile='EXCLUSIVE' *.service_names='KING','KINGS' *.standby_file_management='auto' *.undo_tablespace='UNDOTBS1' [oracle@king02 dbs]$ sqlplus / as sysdba SQL> create spfile from pfile; File created.
[oracle@king02 ~]$ mkdir -p /u01/app/oracle/admin/king/adump [oracle@king02 ~]$ mkdir -p /u01/app/oracle/admin/king/dpdump [oracle@king02 ~]$ mkdir -p /u01/app/oracle/admin/king/pfile [oracle@king02 ~]$ mkdir -p /u01/app/oracle/oradata/king [oracle@king02 ~]$ mkdir -p /u01/app/oracle/fast_recovery_area/king
[oracle@king02 ~]$ sqlplus / as sysdba SQL> startup nomount; ORACLE instance started. Total System Global Area 1068937216 bytes Fixed Size 2260088 bytes Variable Size 432014216 bytes Database Buffers 629145600 bytes Redo Buffers 5517312 bytes
[oracle@king02 ~]$ rman target sys/oracle@kingm auxiliary sys/oracle@kings nocatalog Recovery Manager: Release 11.2.0.4.0 - Production on Sat Mar 31 14:25:26 2018 Copyright (c) 1982, 2011, Oracle and/or its affiliates. All rights reserved. connected to target database: KING (DBID=1072562510) using target database control file instead of recovery catalog connected to auxiliary database: KING (not mounted) RMAN> duplicate target database for standby dorecover nofilenamecheck;
[oracle@king02 ~]$ sqlplus / as sysdba SQL> alter database add standby logfile '/u01/app/oracle/oradata/king/standby01.log' size 50m; SQL> alter database add standby logfile '/u01/app/oracle/oradata/king/standby02.log' size 50m; SQL> alter database add standby logfile '/u01/app/oracle/oradata/king/standby03.log' size 50m; SQL> alter database add standby logfile '/u01/app/oracle/oradata/king/standby04.log' size 50m; SQL> alter database recover managed standby database disconnect from session using current logfile;
[oracle@king01 ~]$ sqlplus / as sysdba SQL> alter system set log_archive_dest_state_2=enable scope=both; SQL> alter system switch logfile;
[oracle@king02 ~]$ sqlplus / as sysdba SQL> alter database recover managed standby database cancel; SQL> alter database open; SQL> alter database recover managed standby database disconnect from session using current logfile;
[oracle@king01 ~]$ sqlplus / as sysdba SQL> set line 200 SQL> col DATABASE_MODE for a30 SQL> col PROTECTION_MODE for a30 SQL> col RECOVERY_MODE for a30 SQL> select DEST_ID , DATABASE_MODE , RECOVERY_MODE , PROTECTION_MODE from v$archive_dest_status where DEST_ID=2; DEST_ID DATABASE_MODE RECOVERY_MODE PROTECTION_MODE ---------- ------------------------------ ------------------------------ ------------------------------ 2 OPEN_READ-ONLY MANAGED REAL TIME APPLY MAXIMUM PERFORMANCE SQL> col DEST_NAME for a20 SQL> col DESTINATION for a30 SQL> col ERROR for a50 SQL> select DEST_ID,DEST_NAME,STATUS, DESTINATION, ERROR from V$ARCHIVE_DEST where DEST_ID<=2; DEST_ID DEST_NAME STATUS DESTINATION ERROR ---------- -------------------- --------------------------- ------------------------------ -------------------------------------------------- 1 LOG_ARCHIVE_DEST_1 VALID db_recovery_file_dest 2 LOG_ARCHIVE_DEST_2 VALID kings SQL> col TYPE for a20 SQL> select DEST_NAME,DESTINATION,STATUS,TYPE,ARCHIVED_SEQ#,APPLIED_SEQ# from v$archive_dest_status where DEST_ID<=2; DEST_NAME DESTINATION STATUS TYPE ARCHIVED_SEQ# APPLIED_SEQ# -------------------- ------------------------------ --------------------------- -------------------- ------------- ------------ LOG_ARCHIVE_DEST_1 db_recovery_file_dest VALID LOCAL 50 0 LOG_ARCHIVE_DEST_2 kings VALID PHYSICAL 50 49 SQL> select THREAD# , SEQUENCE# , STATUS from v$log; THREAD# SEQUENCE# STATUS ---------- ---------- ------------------------------------------------ 1 49 INACTIVE 1 50 INACTIVE 1 51 CURRENT
[oracle@king02 ~]$ sqlplus / as sysdba SQL> set line 200 col ARCHIVED for a10 SQL> select THREAD# , SEQUENCE# , ARCHIVED , STATUS from v$standby_log; THREAD# SEQUENCE# ARCHIVED STATUS ---------- ---------- ---------- ------------------------------ 1 51 YES ACTIVE 1 0 NO UNASSIGNED 0 0 YES UNASSIGNED 0 0 YES UNASSIGNED SQL> select PROCESS , STATUS , THREAD# , SEQUENCE# , BLOCK# , BLOCKS from v$managed_standby where process != 'ARCH'; PROCESS STATUS THREAD# SEQUENCE# BLOCK# BLOCKS --------------------------- ------------------------------------ ---------- ---------- ---------- ---------- RFS IDLE 0 0 0 0 RFS IDLE 0 0 0 0 RFS IDLE 1 51 4381 1 MRP0 APPLYING_LOG 1 51 4381 102400
Oracle数据库容灾解决方案:Oracle DataGuard部署实录
原文:http://blog.51cto.com/13598811/2093451