1.檢查主備的環(huán)境
創(chuàng)新互聯(lián)堅持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站設(shè)計制作、做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時代的定襄網(wǎng)站設(shè)計、移動媒體設(shè)計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
dg1節(jié)點:
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/oradata/tong/archive
Oldest online log sequence 59
Next log sequence to archive 61
Current log sequence 61
SQL>
dg2節(jié)點:
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/oradata/tong/archive
Oldest online log sequence 60
Next log sequence to archive 0
Current log sequence 61
SQL>
2.查看主備的角色
dg1節(jié)點(primary角色):
SQL> select switchover_status,database_role from v$database;
SWITCHOVER_STATUS DATABASE_ROLE
-------------------- ----------------
TO STANDBY PRIMARY
SQL>
dg2節(jié)點(standby角色):
SQL> select switchover_status,database_role from v$database;
SWITCHOVER_STATUS DATABASE_ROLE
-------------------- ----------------
NOT ALLOWED PHYSICAL STANDBY
SQL>
3.在主庫上執(zhí)行切換命令(primary節(jié)點)
SQL> alter database commit to switchover to physical standby; --將primary角色轉(zhuǎn)換為standby角色
Database altered.
SQL> shutdown immediate --關(guān)閉數(shù)據(jù)庫,啟動到mount狀態(tài)
ORA-01507: database not mounted
ORACLE instance shut down.
SQL> startup mount
Total System Global Area 830930944 bytes
Fixed Size 2217912 bytes
Variable Size 545261640 bytes
Database Buffers 281018368 bytes
Redo Buffers 2433024 bytes
Database mounted.
SQL> select switchover_status,database_role from v$database; --查看目前primary角色的狀態(tài)
SWITCHOVER_STATUS DATABASE_ROLE
-------------------- ----------------
TO PRIMARY PHYSICAL STANDBY
SQL>
4.在備庫上執(zhí)行(standby節(jié)點)
SQL> select switchover_status,database_role from v$database; --查看standby備庫角色的狀態(tài)
SWITCHOVER_STATUS DATABASE_ROLE
-------------------- ----------------
TO PRIMARY PHYSICAL STANDBY
SQL> alter database commit to switchover to primary; --將備庫的角色修改為primary
Database altered.
SQL> select switchover_status,database_role from v$database;
SWITCHOVER_STATUS DATABASE_ROLE
-------------------- ----------------
NOT ALLOWED PRIMARY
SQL> alter database open; --打開數(shù)據(jù)庫
Database altered.
SQL>
5.在備庫上執(zhí)行(standby節(jié)點)
SQL> select switchover_status,database_role from v$database;
SWITCHOVER_STATUS DATABASE_ROLE
-------------------- ----------------
RECOVERY NEEDED PHYSICAL STANDBY
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION; --修改以前主庫為日志應(yīng)用
Database altered.
SQL>
6.測試主備節(jié)點是否切換成功
dg2節(jié)點(primary角色):
SQL> select * from tt;
A
----------
1
3
4
5
6
7
6 rows selected.
SQL> insert into tt values(8);
1 row created.
SQL> commit;
Commit complete.
SQL> select * from tt where a=8;
A
----------
8
SQL> alter system switch logfile;
System altered.
SQL> /
System altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/oradata/tong/archive
Oldest online log sequence 78
Next log sequence to archive 80
Current log sequence 80
SQL>
dg1節(jié)點(standby角色):
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/oradata/tong/archive
Oldest online log sequence 79
Next log sequence to archive 0
Current log sequence 80
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database open read only;
Database altered.
SQL> select * from tt;
A
----------
1
3
4
5
6
7
8
7 rows selected.
SQL>
分享文章:oracle11gdataguard主備切換
標(biāo)題鏈接:http://jinyejixie.com/article26/pggicg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供企業(yè)網(wǎng)站制作、品牌網(wǎng)站設(shè)計、營銷型網(wǎng)站建設(shè)、動態(tài)網(wǎng)站、云服務(wù)器、響應(yīng)式網(wǎng)站
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)