不停機 data guard 以及 switchover
DATA GUARD實施文件:
環境描述:
伺服器1:一個執行的OLTP資料庫,不能停機。資料庫安裝歸屬人 ora ,ORACLE_SID=research
伺服器2:一個已經安裝了資料庫的伺服器,有一個資料庫在跑,不能影響。資料庫安裝歸屬人 oracle ,ORACLE_SID=orcl
伺服器基本環境
Host machine IP |
OS release |
sys passwd |
database release |
database SID |
databse unique_name |
DG role |
installers |
192.168.0.15 |
Red Hat 5 |
oracle |
oracle Enterprise 10.2.0.1.0 |
orcl |
orcl |
standby |
oracle |
192.168.0.16 |
Red Hat 5 |
oracle |
oracle Enterprise 10.2.0.1.0 |
research |
research |
primary |
ora |
實施步驟:
DG我們的主備都是用SPFILE啟動例項的。
primary端:
一、強制資料庫logging和開啟archivelog
SQL> archive log list;
SQL> shutdown immediate;
SQL> startup mount ;
SQL> alter database archivelog;
SQL> archive log list;
SQL> alter database force logging;
SQL> select force_logging from v$database;
SQL> altet database open;
二、建立或是修改OS密碼檔案:
orapwd file=$ORACLE_HOME/dbs/orapw$ORACLE_SID password=oracle entries=30 force=y
然後SCP到standby端去。 (注意要修改ORACLE_SID 因為我們這裡的SID 不同。直接MV 就可以了。)
三、備份控制檔案:
Sql>alter database create standby controlfie as ‘/u01/backup/control.ctl’;或是RMAN 備份
RMAN>backup current controlfile for standby format =‘/u01/backup/control.ctl’; (我是用RMAN全庫備份帶上controlfile 所以沒有單獨進行備份)。然後SCP給standby注意複製成多份,並MV到parameter file 指定位置。
四、 修改listener.ora 和 tnsname.ora
Listener.ora 加上靜態監聽 (主備都加上靜態監聽)
# listener.ora Network Configuration File: /opt/oracle/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /opt/oracle/product/10.2.0/db_1)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = research.bj)
(ORACLE_HOME = /opt/oracle/product/10.2.0/db_1)
(SID_NAME = research)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = dg-pp)(PORT = 1521))
)
)
這裡注意細節,SID_DESC 不能頂格,還有括號不能少哦!GLOBAL_DBNAME=service_name
Tnsname.ora
# tnsnames.ora Network Configuration File: /opt/oracle/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
orcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.16)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
research =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.15)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = research.bj)
)
)
這裡注意orcl必須頂格,否則報錯
五、 修改parameter file
research.__db_cache_size=310378496
research.__java_pool_size=4194304
research.__large_pool_size=4194304
research.__shared_pool_size=134217728
research.__streams_pool_size=0
*.audit_file_dest='/opt/oracle/admin/research/adump'
*.background_dump_dest='/opt/oracle/admin/research/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/opt/oracle/oradata/research/control01.ctl','/opt/oracle/oradata/research/control02.ctl','/opt/oracle/oradata/research/control03.ctl'
*.core_dump_dest='/opt/oracle/admin/research/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=8
*.db_name='research'
*.db_recovery_file_dest='/opt/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=researchXDB)'
*.job_queue_processes=10
*.open_cursors=300
*.pga_aggregate_target=150994944
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=455081984
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/opt/oracle/admin/research/udump'
####以下是主庫修改的引數部分###
*.fal_client='research'
*.fal_server='orcl'
*.log_archive_config='DG_CONFIG=(research,orcl)'
*.log_archive_dest_1='LOCATION=/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=research'
*.log_archive_dest_2='SERVICE=orcl LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl'
*.log_archive_dest_state_1='ENABLE'
*.log_archive_dest_state_2='DEFER'
*.standby_file_management='AUTO'
因為我們是線上搭建DG,所以我們就直接命令修改了,但是DB_UNIQUE_NAME需要重啟才能生效,所以我們就按預設research好了。
以下為主庫線上修改命令:
alter system set fal_client='research';
alter system set fal_server='orcl';
alter system set log_archive_config='DG_CONFIG=(research,orcl)';
alter system set log_archive_dest_1='LOCATION=/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=research';
alter system set log_archive_dest_2='SERVICE=orcl LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=orcl';
alter system set log_archive_dest_state_1='ENABLE';
alter system set log_archive_dest_state_2='DEFER'; ##(這裡為什麼要DEFER,因為ENABLE自動傳輸會照成我們RMAN全庫備份長時間等待,ENABLE他就會傳輸,可是我們們還沒有搭建成功呢,所以這裡先DEFER,等我們DG搭建好,我們在修改成ENABLE,然日誌輸出)##
alter system set standby_file_management='AUTO';
六、 RMAN備份全庫
RUN {
allocate channel c1 type disk;
allocate channel c2 type disk;
sql 'alter system archive log current';
backup current controlfile for standby format='/u01/backup/control_%U';
BACKUP FORMAT '/u01/backup/orcl_%U_%T' skip inaccessible filesperset 5 DATABASE ;
sql 'alter system archive log current';
BACKUP FORMAT '/u01/backup/arch_%U_%T' skip inaccessible filesperset 5 ARCHIVELOG ALL DELETE INPUT;
release channel c2;
release channel c1;
}
過程省略,然後把備份檔案SCP 到 standby相同的目錄下,如果不同會出現ORA-19505
到這裡primary端操作基本完成,下面我們來standby
*********************************************************************
*********************************************************************
standby端
一、 修改OS密碼檔案:
primary端的 OS密碼檔案scp過來,並修改成standby的 ORACLE_SID
二、 修改parameter file:
primary端的parameter file 檔案 scp過來,並修改成standby的 ORACLE_SID
Primary file 修改
oracle.__db_cache_size=310378496(這裡注意我們scp過來的是research.修改成oracle.)
oracle.__java_pool_size=4194304
oracle.__large_pool_size=4194304
oracle.__shared_pool_size=134217728
oracle.__streams_pool_size=0
*.audit_file_dest='/opt/oracle/admin/research/adump'
*.background_dump_dest='/opt/oracle/admin/research/bdump'
*.compatible='10.2.0.1.0'
*.control_files='/opt/oracle/oradata/research/control01.ctl','/opt/oracle/oradata/research/control02.ctl','/opt/oracle/oradata/research/control03.ctl'
*.core_dump_dest='/opt/oracle/admin/research/cdump'
*.db_block_size=8192
*.db_domain=''
*.db_file_multiblock_read_count=8
*.db_name='research'
*.db_recovery_file_dest='/opt/oracle/flash_recovery_area'
*.db_recovery_file_dest_size=2147483648
*.dispatchers='(PROTOCOL=TCP) (SERVICE=researchXDB)'
*.job_queue_processes=10
*.log_archive_dest_1='location=/u01/arch'
*.open_cursors=300
*.pga_aggregate_target=150994944
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=455081984
*.undo_management='AUTO'
*.undo_tablespace='UNDOTBS1'
*.user_dump_dest='/opt/oracle/admin/research/udump'
#### add standby parameter file ###
*.DB_UNIQUE_NAME='orcl'
*.LOG_ARCHIVE_CONFIG='DG_CONFIG=(orcl,research)'
*.LOG_ARCHIVE_DEST_1='LOCATION=/u01/arch VALID_FOR=(ALL_LOGFILES,ALL_ROLES) DB_UNIQUE_NAME=orcl'
*.LOG_ARCHIVE_DEST_2='SERVICE=research LGWR ASYNC VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=research'
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.LOG_ARCHIVE_DEST_STATE_1=ENABLE
*.FAL_SERVER='research'
*.FAL_CLIENT='orcl'
*.STANDBY_FILE_MANAGEMENT='AUTO'
如果我們準備的資料檔案目錄,和admin目錄不同,那我們需要在引數檔案內指出並修改(這裡我們主庫和備庫的目錄相同所以沒有修改目錄,也方便了我們RMAN恢復的時候,不用RENAME了)。
三、 修改控制檔案:
primary端的控制檔案scp過來後,要修改成引數檔案制定的名字和目錄。否則引數檔案找不到,要把一份複製成多份,具體幾份那就看你的引數檔案了。
(我們這裡是用RMAN直接恢復的,我們的目錄也沒有改變所以就不用指定了)。
四、 修改listener.ora和tnsname.ora
Listener.ora 加上靜態監聽
# listener.ora Network Configuration File: /opt/oracle/product/10g/network/admin/listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /opt/oracle/product/10g)
(PROGRAM = extproc)
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = /opt/oracle/product/10g)
(SID_NAME = orcl)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = dg-ss)(PORT = 1521))
)
)
Tnsname.ora 修改
# tnsnames.ora Network Configuration File: /opt/oracle/product/10g/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
RMAN =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = dg-ss)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = rman)
)
)
EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)
orcl =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.16)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
research =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.0.15)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = research.bj)
)
)
Lsnrctl stop
Lsnrctl start
Lsnrclt status
這裡我們配置了2個,主要目的就是切換的時候不用在配置了。這裡主備的相同的。如果備庫沒有network/admin的檔案,可以從主庫cp過來。TNSPING 互相必須能PING通。
五、 recover standby database
1)把主庫備份的備份檔案,scp到相同的目錄下,如果目錄不同需要註冊。
2)Standby 端需要啟動到nomount 狀態,且用spfile啟動。(具體過程省略)。
3)利用RMAN 恢復standby database
Primary 端:
[ora@dg-pp dbs]$ rman target / auxiliary sys/system@orcle
_s
恢復管理器: Release 10.2.0.4.0 - Production on 星期五 5月 27 15:33:05 2011
Copyright (c) 1982, 2007, Oracle. All rights reserved.
連線到目標資料庫: DGDB1 (DBID=152223982)
已連線到輔助資料庫: DGDB1 (未裝載)
RMAN> duplicate target database for standby nofilenamecheck dorecover;
1. 這裡需要解釋一下我們直接用了 NOFILENAMECHECK 引數,是因為我們的主庫,備庫的資料檔案目錄相同。不同的話,需要我們制定指令碼。
2. RUN { # set new file names for the datafiles SET NEWNAME FOR DATAFILE 1 TO '?/dbs/standby_data_01.f'; SET NEWNAME FOR DATAFILE 2 TO '?/dbs/standby_data_02.f'; # run the DUPLICATE command DUPLICATE TARGET DATABASE FOR STANDBY; }
接下來就等待了,等到RMAN RECOVER 結束。檢視STANDBY狀態,為MOUNT。這裡一般情況會提示 未完成恢復,因為我們做DG這些操作的時候必須耗費時間,這段時間內我們沒有備份主庫的歸檔,也就是說你做完全庫後,主庫在執行還會產生歸檔的。這裡恢復的時候會提示,但是這不用擔心,我們的目的不就是做 DG ,DG的意義就在於把沒有同步過來的資料進行同步,我們的DG搭建好後。沒有被RMAN恢復的歸檔自然會被DG傳送過來了。
Standby 端:
SQL*Plus: Release 10.2.0.1.0 - Production on Sun Apr 1 17:58:41 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> conn /as sysdba
Connected.
SQL> select status from v$instance;
STATUS
------------------------
MOUNTED
六、 建立STANDYB REDO
因為我們使用的 LOG ASYNC ROLE 所以我們需要建立 standby redo
這裡需要在主備都建立standby redo 且大小,組數,必須相同。
Standby redo = (onredo+1) * 執行緒數 執行緒數這裡可以認為是RAC的節點數。
我們這裡是單例項,所以建立了4組 standby redo。
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 (’/資料檔案目錄/redo04.log)size 50M; (一共建立4組,步驟省略)
Primary 端:
在主庫也建立哦!
SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 (’/資料檔案目錄/redo04.log)size 50M; (一共建立4組,步驟省略)
接下來有點混亂一會primary端 一會standby端 注意好哦
standby端:
確保主庫OPEN,備庫MOUNT。
1、從庫將接收從主庫傳送過來的日誌
primary端:
SQL> alter system set log_archive_dest_state_2='ENABLE';
System altered.
Standby 端:
2、接收並應用日誌。
SQL> alter database recover managed standby database disconnect from session;
System altered.
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
----------------------------------------
SESSIONS ACTIVE
這裡sessions active 有session活動,這種情況正常。即使出現 NOT ALLOWED 也不要害怕,因為這些狀態不能確定你的DG 是否成功。因為SWITCHOVER_STATUS僅僅表示DG轉換的狀態。
到這裡standby端的操作完成了。
*********************************************************************
*********************************************************************
日誌傳送和應用測試
測試日誌有沒有傳送和同步
1、主庫
SQL>select max(sequence#) from v$archived_log;
SQL>alter system switch logfile;
SQL>select max(sequence#) from v$archived_log;
2、從庫
SQL>select max(sequence#) from v$archived_log;
兩個庫上看到的序列號一致表示日誌成功傳送;
在從庫上應用日誌
SQL>alter database recover managed standby database disconnect from session;
測試日誌是否能應用(測試資料是否一致)
1、主庫
在主庫上建立一個測試表並插入資料並提交 比如:
SQL>conn scott/tigger
SQL>create table test (name varchar2(10),job varchar2(20));
SQL>insert into test values('qiujunhua','dba');
SQL>insert into test values('qjh','plsql developer');
SQL>commit;
SQL>alter system switch logfile;
2、從庫
在從庫上應用日誌
SQL>alter database recover managed standby database disconnect from session;
在open從庫之前先停止應用日誌
SQL>alter database recover managed standby database cancel;
開啟資料庫驗證資料是否一致
SQL>alter database open;
SQL>conn scott/tigger
SQL>select * from test;
若看到的資料和主庫一致,說明日誌成功應用
3、返回到接收日誌狀態
從庫啟動應用日誌:(在從庫OPEN的狀態下直接執行不用先shutdown)
SQL>alter database recover managed standby database disconnect from session;
從庫停止應用日誌,但是繼續接收日誌
SQL>alter database recover managed standby database cancel;
執行後從庫處於mount狀態
*********************************************************************
*********************************************************************
Data guard switchover
檢視主庫,備庫的狀態。
primary端:
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE (證明還有session活動)
standby端:
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
----------------------------------------
NOT ALLOWED (備庫等待主庫經行操作,此狀態不影響switchover)
2、進行switchover 操作:
primary端:
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
SESSIONS ACTIVE
如果此狀態為’to standby’ 則可以直接切換
使用“alter database commit to switchover to physical standby ;”
我們當前狀態為‘ sessions active’ 說明還有session 活動。
使用“alter database commit to switchover to physical standby with session shutdown;” 執行完這個命令,資料庫為nomount狀態。
SQL> alter database commit to switchover to physical standby with session shutdown;
Database altered.
SQL> select status from v$instance;
STATUS
------------
STARTED
執行這個命令後,我們來看看 alert 日誌。這樣可以讓我們知道 命令都幹了些什麼
alter database commit to switchover to physical standby with session shutdown
Sun Apr 1 18:49:21 2012
ALTER DATABASE COMMIT TO SWITCHOVER TO PHYSICAL STANDBY (orcl)
Sun Apr 1 18:49:25 2012
Thread 1 advanced to log sequence 31
Current log# 2 seq# 31 mem# 0: /opt/oracle/oradata/research/redo02.log
Sun Apr 1 18:49:25 2012
ARCH: Standby redo logfile selected for thread 1 sequence 30 for destination LOG_ARCHIVE_DEST_2
Sun Apr 1 18:49:27 2012
Stopping background process CJQ0
Sun Apr 1 18:49:27 2012
SMON: disabling tx recovery
Sun Apr 1 18:49:27 2012
Stopping background process QMNC
Sun Apr 1 18:49:28 2012
Thread 1 advanced to log sequence 32
Current log# 3 seq# 32 mem# 0: /opt/oracle/oradata/research/redo03.log
Sun Apr 1 18:49:28 2012
ARC0: Standby redo logfile selected for thread 1 sequence 31 for destination LOG_ARCHIVE_DEST_2
Sun Apr 1 18:49:28 2012
Stopping Job queue slave processes
Sun Apr 1 18:49:36 2012
Waiting for Job queue slaves to complete
Sun Apr 1 18:50:03 2012
Job queue slave processes stopped
All dispatchers and shared servers shutdown
Sun Apr 1 18:50:05 2012
SMON: disabling cache recovery
Sun Apr 1 18:50:05 2012
Shutting down archive processes
Archiving is disabled
Sun Apr 1 18:50:10 2012
ARCH shutting down
ARC1: Archival stopped
Sun Apr 1 18:50:15 2012
ARC0: Becoming the heartbeat ARCH
ARC0: Archiving disabled
ARCH shutting down
ARC0: Archival stopped
Sun Apr 1 18:50:16 2012
Thread 1 closed at log sequence 32
Successful close of redo thread 1
Sun Apr 1 18:50:16 2012
ARCH: Noswitch archival of thread 1, sequence 32
ARCH: End-Of-Redo Branch archival of thread 1 sequence 32
ARCH: Archiving is disabled due to current logfile archival
Clearing standby activation ID 2102571270 (0x7d52b106)
The primary database controlfile was created using the
'MAXLOGFILES 16' clause.
There is space for up to 13 standby redo logfiles
Use the following SQL commands on the standby database to create
standby redo logfiles that match the primary database:
ALTER DATABASE ADD STANDBY LOGFILE 'srl1.f' SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE 'srl2.f' SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE 'srl3.f' SIZE 52428800;
ALTER DATABASE ADD STANDBY LOGFILE 'srl4.f' SIZE 52428800;
Archivelog for thread 1 sequence 32 required for standby recovery
MRP0 started with pid=10, OS id=17838
Sun Apr 1 18:50:17 2012
MRP0: Background Managed Standby Recovery process started (orcl)
Managed Standby Recovery not using Real Time Apply
Online logfile pre-clearing operation disabled by switchover
Media Recovery Log /u01/arch/1_32_779474103.dbf
Identified End-Of-Redo for thread 1 sequence 32
Sun Apr 1 18:50:22 2012
Media Recovery End-Of-Redo indicator encountered
Sun Apr 1 18:50:22 2012
Media Recovery Applied until change 500306
Sun Apr 1 18:50:22 2012
MRP0: Media Recovery Complete: End-Of-REDO (orcl)
Resetting standby activation ID 2102571270 (0x7d52b106)
Sun Apr 1 18:50:23 2012
Waiting for MRP0 pid 17838 to terminate
Sun Apr 1 18:50:24 2012
MRP0: Background Media Recovery process shutdown (orcl)
Sun Apr 1 18:50:24 2012
idle dispatcher 'D000' terminated, pid = (13, 1)
Sun Apr 1 18:50:24 2012
Switchover: Complete - Database shutdown required (orcl)
Sun Apr 1 18:50:24 2012
Completed: alter database commit to switchover to physical standby with session shutdown
此時看備庫的狀態已經成為 switchover pending 。這足以證明我們之前看到standby 狀態為not allowed 只是等待主庫給她髮狀態命令罷了。
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
----------------------------------------
SWITCHOVER PENDING
此時主庫已切換成了,備庫。現在重啟到mount
Shut immediate
Startup mount
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
--------------------
TO PRIMARY
此時的狀態也表明了我們轉換成功了,現在這個是備庫,備庫的switchover 狀態為to primary 。
到這裡primary 已經轉換成 standby了。
Standby 端:
1、上面的 primary 已經轉換成功了,我們看一下standby狀態。
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
----------------------------------------
SWITCHOVER PENDING
這裡需要我們應用日誌了。
使用“alter database recover managed standby database disconnect from session;”
SQL> alter database recover managed standby database disconnect from session;
Database altered.
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
----------------------------------------
TO PRIMARY
此時standby的狀態時to primary 允許我們轉換了。
使用“alter database commit to switchover to primary;”如果執行此命令後hold住的話,你可以使用下面命令經行操作。
SQL> alter database recover managed standby database disconnect from session;
alter database recover managed standby database disconnect from session
*
ERROR at line 1:
ORA-01153: an incompatible media recovery is active
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database commit to switchover to primary;
Database altered. 轉換成功之後,資料庫狀態為 nomount
SQL> select status from v$instance;
STATUS
------------------------
STARTED
Shut immediate
Statrtup
檢視狀態
SQL> select switchover_status from v$database;
SWITCHOVER_STATUS
----------------------------------------
SESSIONS ACTIVE
此時已經切換成功。如果真正的成功沒有,那我們還需要做 日誌傳輸和應用實驗。
證明我們的switchover 成功了。
FAILOVER(沒有做測試)
1、原則上在主庫上不進行操作
因為既然是FAILOVER ,生產情況主庫已經崩潰或者無法開啟!!!無法執行,這裡僅測試。
1、從庫取消恢復
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE FINISH FORCE;
---force關鍵字將會停止當前活動RFS程式,以便立即執行failover
2、備庫直接切換為主庫
SQL> ALTER DATABASE COMMIT TO SWITCHOVER TO PRIMARY;
3、啟動資料庫
SQL> SHUTDOWN IMMEDIATE;
SQL> STARTUP;
切換成功後原來主庫已經不是dg裡的一部分了。
接下來的工作就是將原來的主庫恢復資料 或者重新改造成dg裡的standby庫!!!
這裡感謝願意分享學習快樂的老師,同時也感謝我兄弟--邱tomcat。
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/26442936/viewspace-721390/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- data guard switchover on solaris 10
- In Data Guard,choose switchover or failover?AI
- Data Guard Switchover and Failover Best PracticesAI
- DATA GUARD物理STANDBY的 SWITCHOVER切換
- 【DG】Data Guard主備庫Switchover切換
- DATA GUARD物理備庫的SWITCHOVER切換
- DATA GUARD物理STANDBY的 SWITCHOVER切換[zt]
- data guard物理備份方式中的switchover轉換
- 玩轉Data Guard的switchover後切不回主庫
- 不停機 data guard 注意事項 (重建orapw對資料庫的影響)資料庫
- Data Guard中快速Switchover,Failover的一些建議AI
- 單機搭建Data Guard
- Data Guard高階玩法:通過閃回恢復switchover主庫
- Oracle 12c Data guard 物理主備庫正常切換(switchover)流程Oracle
- oracle10g data guard role transition_physical_logical_switchover_failoverOracleAI
- Oracle 11g Data guard 物理主備庫正常切換(switchover)流程Oracle
- DATA GUARD部署模式——DATA GUARD概念和管理模式
- How to configure Client Failover after Data Guard Switchover or Failover [ID 316740.1]clientAI
- 【DataGuard】使用Grid Control對Oracle物理Data Guard進行Switchover切換Oracle
- 介紹ORACLE DATA GUARD——DATA GUARD概念和管理Oracle
- Data guard搭建
- oracle data guard!!Oracle
- 盛哥學習 Data Guard 第三篇《物理standby之switchover 無損切換》
- Data Guard Broker系列之二:Data Guard Broker配置實戰
- 10g Data Guard physical standby的主備庫角色轉換測試(switchover & failover)AI
- DATA GUARD 簡介
- Data Guard 建立(ASM)ASM
- Oracle Data Guard配置Oracle
- Oracle 11g Data Guard Enabling Active Data GuardOracle
- [Data Guard]Oracle10g Data Guard學習筆記(一)Oracle筆記
- [Data Guard]Oracle10g Data Guard學習筆記(二)Oracle筆記
- [Data Guard]Oracle10g Data Guard學習筆記(三)Oracle筆記
- Oracle Data Guard Broker元件Oracle元件
- Oracle Data Guard簡介Oracle
- Active Data Guard初探(一)
- DATA GUARD架構(一)架構
- Oracle Data Guard 介紹Oracle
- Data Guard Wait EventsAI