Step By Step Configure DataGuard (10g) Physical Standby Database On Linux X86_64(2/2)
本文承接http://djb1008.itpub.net/post/42280/504822
[oracle@standbydb archivelog]$ pwd
/oradata/archivelog
[oracle@standbydb archivelog]$ ls -lt *
standby_arc:
total 47820
-rw-r----- 1 oracle oinstall 286208 Sep 3 18:41 1_212_724504451.dbf
-rw-r----- 1 oracle oinstall 197120 Sep 3 18:32 1_211_724504451.dbf
-rw-r----- 1 oracle oinstall 4096 Sep 3 18:31 1_210_724504451.dbf
-rw-r----- 1 oracle oinstall 48413184 Sep 3 18:31 1_209_724504451.dbf
primary_arc:
total 0
[@more@]我們可以看到歸檔日誌檔案從主節點複製到了備節點,並且得到了應用。
[oracle@standbydb archivelog]$ sqlplus / as sysdba
SQL> SELECT SEQUENCE#, FIRST_TIME, NEXT_TIME FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
SEQUENCE# FIRST_TIM NEXT_TIME
---------- --------- ---------
209 03-SEP-10 03-SEP-10
210 03-SEP-10 03-SEP-10
211 03-SEP-10 03-SEP-10
212 03-SEP-10 03-SEP-10
SQL> SELECT SEQUENCE#,APPLIED FROM V$ARCHIVED_LOG ORDER BY SEQUENCE#;
SEQUENCE# APP
---------- ---
209 YES
210 YES
211 YES
212 YES
到目前位置,主備資料庫環境已經完全搭建完成了,並投入使用。搭建的是Physical Standby Database。
三. 主備資料庫切換
注意:
主庫伺服器的名稱為:primarydb,備庫伺服器的名稱為:standbydb。在下面的指令碼中可以透過命令列前面的提示符可以知道在那臺伺服器上執行的。例如"[oracle@primarydb /]$",就可以看出是在主庫伺服器上執行。
- 生產環境從主庫伺服器切換到備庫伺服器
1.1 停止主庫執行
[oracle@primarydb /]$ sqlplus / as sysdba
SQL> alter database commit to switchover to physical standby;
Database altered.
SQL> shutdown immediate;
ORA-01507: database notmount
ORACLE instance shut down.
1.2 將主庫執行在standby database狀態
[oracle@primarydb /]$ sqlplus / as sysdba
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 1073741824 bytes
Fixed Size 2089472 bytes
Variable Size 578817536 bytes
Database Buffers 490733568 bytes
Redo Buffers 2101248 bytes
SQL> alter database mount standby database;
Database altered.
SQL> alter database recover managed standby database disconnect from session;
Database altered.
1.3 啟動備庫為生產環境
[oracle@standbydb ~]$ sqlplus / as sysdba
SQL> alter database commit to switchover to primary;
Database altered
備庫的alert日誌描述如下:
[oracle@standbydb ~]$tail -f alert_gridctl.log
alter database commit to switchover to primary
Mon Sep 6 11:24:30 2010
ALTER DATABASE SWITCHOVER TO PRIMARY (gridctl)
Mon Sep 6 11:24:30 2010
If media recovery active, switchover will wait 900 seconds
SwitchOver after complete recovery through change 9735881
Standby became primary SCN: 9735879
Converting standby mount to primary mount.
Mon Sep 6 11:24:34 2010
Switchover: Complete - Database mounted as primary (gridctl)
Completed: alter database commit to switchover to primary
SQL>shutdown immediate;
ORA-01507: database notmount
ORACLE instance shut down.
SQL>startup
ORACLE instance started.
。。。。。。
Database mounted.
Database opened.
1.4 修改主庫伺服器的引數log_archive_dest_2為空
[oracle@primarydb /]$ sqlplus / as sysdba
SQL> show parameter log_archive_dest_2
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_2 string service=standby mandatory reop
en=60
SQL>ALTER SYSTEM SET log_archive_dest_2='' SCOPE=BOTH;
1.5 修改備庫伺服器的引數log_archive_dest_2,將日誌應用到主庫伺服器
[oracle@standbydb ~]$ sqlplus / as sysdba
SQL> alter system set log_archive_dest_2='service=primary mandatory reopen=60' scope=both;
1.6 檢視備庫伺服器上資料庫的角色狀態,並進行日切換
[oracle@standbydb ~]$ sqlplus / as sysdba
SQL> select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
---------- ----------------
READ WRITE PRIMARY
SQL> alter system switch logfile;
System altered.
1.7 檢查主庫伺服器的資料庫角色狀態,並檢視alert日誌檔案,驗證日誌是否得到了應用
[oracle@primarydb /]$ sqlplus / as sysdba
SQL> select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
---------- ----------------
MOUNTED PHYSICAL STANDBY
[oracle@standbydb ~]$tail -f alert_gridctl.log
Mon Sep 6 16:15:20 2010
RFS[1]: Archived Log: '/oradata/archivelog/standby_arc/1_237_724504451.dbf'
Mon Sep 6 16:15:23 2010
Media Recovery Log /oradata/archivelog/standby_arc/1_237_724504451.dbf
Media Recovery Waiting for thread 1 sequence 238
- 生產環境從備庫伺服器切換回主庫伺服器
2.1 備庫伺服器將資料庫角色從primary轉換為standby
[oracle@standbydb ~]$ sqlplus / as sysdba
SQL> select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
---------- ----------------
READ WRITE PRIMARY
SQL> alter database commit to switchover to standby;
SQL> shutdown immediate;
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup nomount;
ORACLE instance started.
Total System Global Area 1073741824 bytes
Fixed Size 2089472 bytes
Variable Size 578817536 bytes
Database Buffers 490733568 bytes
Redo Buffers 2101248 bytes
SQL> alter database mount standby database;
SQL> alter system set log_archive_dest_2='' scope=both;
SQL> alter database recover managed standby database disconnect from session;
SQL> select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
---------- ----------------
MOUNTED PHYSICAL STANDBY
2.2 主庫伺服器將資料庫角色從standby轉換為primary
[oracle@primarydb /]$ sqlplus / as sysdba
SQL> select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
---------- ----------------
MOUNTED PHYSICAL STANDBY
SQL> alter database commit to switchover to primary;
SQL> shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 1073741824 bytes
Fixed Size 2089472 bytes
Variable Size 578817536 bytes
Database Buffers 490733568 bytes
Redo Buffers 2101248 bytes
Database mounted.
Database opened.
SQL> alter system set log_archive_dest_2='service=standby mandatory reopen=60' scope=both;
SQL> select open_mode,database_role from v$database;
OPEN_MODE DATABASE_ROLE
---------- ----------------
READ WRITE PRIMARY
SQL> alter system switch logfile;
檢視備庫伺服器的alert日誌檔案,可以看到來自主庫伺服器的日誌得到了應用。
[oracle@standbydb ~]$ tail -f alert_gridctl.log
。。。。。。
Media Recovery Log /oradata/archivelog/standby_arc/1_240_724504451.dbf
Media Recovery Log /oradata/archivelog/standby_arc/1_241_724504451.dbf
Media Recovery Waiting for thread 1 sequence 242
切換到此完成。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/32980/viewspace-1037940/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- Step By Step Configure DataGuard (10g) Physical Standby Database On Linux X86_64(1/2待續...)DatabaseLinux
- Step By Step Guide To Create Physical Standby Database Using RMAN [ID 469493.1]GUIIDEDatabase
- oracle Physical Standby failover stepOracleAI
- Step By Step Install Oracle GC 10.2.0.5 on Redhat Linux 5.5 x86_64 (2/2)OracleGCRedhatLinux
- Step by Step Guide on Creating Physical Standby Using RMAN DUPLICATE...FROM ACTIVE DATABASE WithoutGUIIDEDatabase
- Oracle 11gR2 Active DataGuard配置Step By Step(一)Oracle
- Oracle 11gR2 Active DataGuard配置Step By Step(二)Oracle
- Oracle 11gR2 Active DataGuard配置Step By Step(三)Oracle
- Step By Step Install Oracle GC 10.2.0.5 on Redhat Linux 5.5 x86_64 (1/2待續...)OracleGCRedhatLinux
- Step-By-Step Guide To Create Physical Standby On Normal File System For ASM Primary using RMANGUIIDEORMASM
- 單機Linux平臺Oracle 10g DataGuard Physical Standby 搭建例項(2)LinuxOracle 10g
- Oracle 10g R2建立ASM例項Step By Step(一)Oracle 10gASM
- Oracle 10g R2建立ASM例項Step By Step(四)Oracle 10gASM
- Step By Step Guide On Creating Physical Standby Using RMAN Duplicate In ASM Filesystem For ASM PrimaGUIIDEASM
- Learn C++ step by step(2) (轉)C++
- Step By Step of Configuring Oracle 11gR2 (11.2.0.1) RAC to RAC DataguardOracle
- ORACLE10g DataGuard 配置Physical Standby DatabaseOracleDatabase
- Recover physical standby database after loss of archive log(2)DatabaseHive
- Step 2: Establish the Database Administrator Authentication Method (60)Database
- oracle 10g physical standby database creationOracle 10gDatabase
- DataGuard:Physical Standby Switchover
- Step by Step Guide on How to Create Logical Standby [ID 738643.1]GUIIDE
- 使用RMAN備份集搭建Oracle Dataguard Step by Step(一)Oracle
- 使用RMAN備份集搭建Oracle Dataguard Step by Step(二)Oracle
- 配置 Oracle 10g RAC primary + RAC physical standby dataguardOracle 10g
- DataGuard:Physical Standby FailoverAI
- Linux Software RAID step by stepLinuxAI
- 安裝linux(step by step)(轉)Linux
- step by step install oracle 10g rac asm on windowsOracle 10gASMWindows
- 單機Linux平臺Oracle 11g DataGuard Physical Standby 搭建例項(2)LinuxOracle
- Convert a Physical Standby Database into a Snapshot Standby DatabaseDatabase
- Step by step install grid control agent on linux 5.3 x86_64遠端安裝Linux
- Step by Step, 為OSRFX2建立一個KMDF驅動程式
- 單機Linux平臺Oracle 10g DataGuard Physical Standby 搭建例項(10)LinuxOracle 10g
- 單機Linux平臺Oracle 10g DataGuard Physical Standby 搭建例項(9)LinuxOracle 10g
- 單機Linux平臺Oracle 10g DataGuard Physical Standby 搭建例項(8)LinuxOracle 10g
- 單機Linux平臺Oracle 10g DataGuard Physical Standby 搭建例項(7)LinuxOracle 10g
- 單機Linux平臺Oracle 10g DataGuard Physical Standby 搭建例項(6)LinuxOracle 10g