IT技術互動(dong)交流(liu)平(ping)jiao)/h4>

杏彩代理官网

作(zuo)者︰一起走(zou)過的日子  來源︰IT165收集  發布日期(qi)︰2020-02-19 08:32:55

1.檢查主備的環境

dg1節點(dian):

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節點(dian):

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節點(dian)(primary角色):

SQL> select switchover_status,database_role from v$database;

SWITCHOVER_STATUS    DATABASE_ROLE

-------------------- ----------------

TO STANDBY           PRIMARY

SQL> 


dg2節點(dian)(standby角色):

SQL> select switchover_status,database_role from v$database;

SWITCHOVER_STATUS    DATABASE_ROLE

-------------------- ----------------

NOT ALLOWED          PHYSICAL STANDBY

SQL> 


3.在主庫上執(zhi)行切換命令(ling)(primary節點(dian))

SQL> alter database commit to switchover to physical standby; --將(jiang)primary角色轉(zhuan)換為standby角色

Database altered.

SQL> shutdown immediate              --關(guan)閉數據庫,啟動(dong)到(dao)mount狀(zhuang)態

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角色的狀(zhuang)態

SWITCHOVER_STATUS    DATABASE_ROLE

-------------------- ----------------

TO PRIMARY           PHYSICAL STANDBY

SQL> 


4.在備庫上執(zhi)行(standby節點(dian))

SQL> select switchover_status,database_role from v$database;     --查看standby備庫角色的狀(zhuang)態

SWITCHOVER_STATUS    DATABASE_ROLE

-------------------- ----------------

TO PRIMARY           PHYSICAL STANDBY

SQL> alter database commit to switchover to primary;       --將(jiang)備庫的角色修(xiu)改為primary

Database altered.

SQL> select switchover_status,database_role from v$database;

SWITCHOVER_STATUS    DATABASE_ROLE

-------------------- ----------------

NOT ALLOWED          PRIMARY

SQL> alter database open;          --打開(kai)數據庫

Database altered.

SQL> 


5.在備庫上執(zhi)行(standby節點(dian))

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;      --修(xiu)改以前主庫為日志應用

Database altered. 

SQL> 


6.測(ce)試(shi)主備節點(dian)是(shi)否切換成功

dg2節點(dian)(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節點(dian)(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> 


Tag標(biao)簽(qian)︰oracle  11g  dataguard主備切換  
  • 杏彩代理官网

About IT165 - 廣告服務 - 隱私聲明(ming) - 版(ban)權申明(ming) - 免責(ze)條款 - 網站地圖 - 網友(you)投稿 - 聯系方(fang)式(shi)
本站內容來自于互聯網,僅供用于網絡技術學習,學習中請遵(zun)循(xun)相關(guan)法律法規
杏彩代理官网 | 下一页