switchover physical DB怎樣互換primary DB,相信很多沒有經(jīng)驗的人對此束手無策,為此本文總結(jié)了問題出現(xiàn)的原因和解決方法,通過這篇文章希望你能解決這個問題。
成都創(chuàng)新互聯(lián)是一家集網(wǎng)站建設(shè),本溪企業(yè)網(wǎng)站建設(shè),本溪品牌網(wǎng)站建設(shè),網(wǎng)站定制,本溪網(wǎng)站建設(shè)報價,網(wǎng)絡(luò)營銷,網(wǎng)絡(luò)優(yōu)化,本溪網(wǎng)站推廣為一體的創(chuàng)新建站企業(yè),幫助傳統(tǒng)企業(yè)提升企業(yè)形象加強企業(yè)競爭力??沙浞譂M足這一群體相比中小企業(yè)更為豐富、高端、多元的互聯(lián)網(wǎng)需求。同時我們時刻保持專業(yè)、時尚、前沿,時刻以成就客戶成長自我,堅持不斷學(xué)習(xí)、思考、沉淀、凈化自己,讓我們?yōu)楦嗟钠髽I(yè)打造出實用型網(wǎng)站。
PS:這一些實驗是建立在我之前博客實驗的基礎(chǔ)上的
為什么要先alter 先切主庫 再切備庫,
因為如果先切備庫的話,那么主庫的一些日志可能備庫收不到,導(dǎo)致不一致的情況發(fā)生
先切主庫------>standby DB 切換之后主庫是斷開close的,重新open后查看其狀態(tài)
20:53:33 SYS @ slow >select name,database_role,protection_mode,switchover_status from v$database;
NAME DATABASE_ROLE PROTECTION_MODE SWITCHOVER_STATUS
--------- ---------------- -------------------- --------------------
SLOW PRIMARY MAXIMUM AVAILABILITY TO STANDBY
1 row selected.
Elapsed: 00:00:00.00
20:55:15 SYS @ slow >edit
Wrote file afiedt.buf
1* select username,sid,serial# from v$session where username is not null
20:55:24 SYS @ slow >r
1* select username,sid,serial# from v$session where username is not null
USERNAME SID SERIAL#
------------------------------ ---------- ----------
SYS 1 5
1 row selected.
Elapsed: 00:00:00.01
20:55:25 SYS @ slow >r
1* select username,sid,serial# from v$session where username is not null
USERNAME SID SERIAL#
------------------------------ ---------- ----------
SYS 1 5
SCOTT 41 47
2 rows selected.
Elapsed: 00:00:00.00
20:56:25 SYS @ slow >alter database commit to switchover to standby;
Database altered.
Elapsed: 00:00:01.89
20:57:05 SYS @ slow >select name,database_role,protection_mode,switchover_status from v$database;
select name,database_role,protection_mode,switchover_status from v$database
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 5713
Session ID: 1 Serial number: 5
Elapsed: 00:00:00.00
20:58:08 SYS @ slow >select status from v$instance;
select status from v$instance
*
ERROR at line 1:
ORA-01034: ORACLE not available
Process ID: 5713
Session ID: 1 Serial number: 5
Elapsed: 00:00:00.00
20:58:46 SYS @ slow >startup
ORACLE instance started.
Total System Global Area 521936896 bytes
Fixed Size 2254824 bytes
Variable Size 377489432 bytes
Database Buffers 138412032 bytes
Redo Buffers 3780608 bytes
Database mounted.
Database opened.
21:07:19 SYS @ slow >select name,open_mode,database_role,protection_mode,switchover_status from v$database;
NAME OPEN_MODE DATABASE_ROLE PROTECTION_MODE SWITCHOVER_STATUS
--------- -------------------- ---------------- -------------------- --------------------
SLOW READ ONLY PHYSICAL STANDBY MAXIMUM AVAILABILITY TO PRIMARY
1 row selected.
Elapsed: 00:00:00.01
21:07:55 SYS @ slow >recover managed standby database disconnect;
Media recovery complete.
21:08:35 SYS @ slow >select name,open_mode,database_role,protection_mode,switchover_status from v$database;
NAME OPEN_MODE DATABASE_ROLE PROTECTION_MODE SWITCHOVER_STATUS
--------- -------------------- ---------------- -------------------- --------------------
SLOW READ ONLY WITH APPLY PHYSICAL STANDBY MAXIMUM AVAILABILITY TO PRIMARY
1 row selected.
Elapsed: 00:00:00.00
21:09:02 SYS @ slow >
再切換備庫----->primary DB 備庫mount狀態(tài)下操作 成功?。。?/p>
20:52:21 SYS @ gotime >select name,database_role,protection_mode,switchover_status from v$database;
NAME DATABASE_ROLE PROTECTION_MODE SWITCHOVER_STATUS
--------- ---------------- -------------------- --------------------
SLOW PHYSICAL STANDBY MAXIMUM AVAILABILITY NOT ALLOWED
1 row selected.
Elapsed: 00:00:00.01
20:53:12 SYS @ gotime >r
1* select name,database_role,protection_mode,switchover_status from v$database
NAME DATABASE_ROLE PROTECTION_MODE SWITCHOVER_STATUS
--------- ---------------- -------------------- --------------------
SLOW PHYSICAL STANDBY MAXIMUM AVAILABILITY NOT ALLOWED
1 row selected.
Elapsed: 00:00:00.00
20:59:16 SYS @ gotime >select username,sid from v$session where username is not null;
USERNAME SID
------------------------------ ----------
SYS 24
1 row selected.
Elapsed: 00:00:00.01
21:02:26 SYS @ gotime >alter database commit to switchover to primary with session shutdown;
alter database commit to switchover to primary with session shutdown
*
ERROR at line 1:
ORA-16139: media recovery required
Elapsed: 00:00:00.01
21:03:18 SYS @ gotime >recover managed standby database disconnect;
Media recovery complete.
21:03:51 SYS @ gotime >alter database commit to switchover to primary with session shutdown;
Database altered.
Elapsed: 00:00:02.04
21:05:00 SYS @ gotime >select name,database_role,protection_mode,switchover_status from v$database;
NAME DATABASE_ROLE PROTECTION_MODE SWITCHOVER_STATUS
--------- ---------------- -------------------- --------------------
SLOW PRIMARY MAXIMUM AVAILABILITY NOT ALLOWED
1 row selected.
Elapsed: 00:00:00.01
21:05:12 SYS @ gotime >alter database open;
Database altered.
Elapsed: 00:00:00.58
21:05:45 SYS @ gotime >select name,database_role,protection_mode,switchover_status from v$database;
NAME DATABASE_ROLE PROTECTION_MODE SWITCHOVER_STATUS
--------- ---------------- -------------------- --------------------
SLOW PRIMARY MAXIMUM AVAILABILITY FAILED DESTINATION
1 row selected.
Elapsed: 00:00:00.01
21:06:13 SYS @ gotime >
--------------------------------------但是,switchover_status是failed destination 狀態(tài)------------------------------------------
switchover之后的備庫slow,重新啟動listener
[oracle@slow ~]$ lsnrctl stop
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-JAN-2018 21:31:12
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=slow)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
[oracle@slow ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-JAN-2018 21:31:20
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/slow/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slow)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=slow)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 13-JAN-2018 21:31:20
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/slow/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slow)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@slow ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-JAN-2018 21:31:23
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=slow)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 13-JAN-2018 21:31:20
Uptime 0 days 0 hr. 0 min. 2 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/slow/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slow)(PORT=1521)))
The listener supports no services
The command completed successfully
關(guān)閉slow備庫,再打開mount狀態(tài)
21:28:36 SYS @ slow >shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
21:28:53 SYS @ slow >startup mount;
ORACLE instance started.
Total System Global Area 521936896 bytes
Fixed Size 2254824 bytes
Variable Size 377489432 bytes
Database Buffers 138412032 bytes
Redo Buffers 3780608 bytes
Database mounted.
21:29:08 SYS @ slow >
等slow備庫重新啟動之后,狀態(tài)為ready了
[oracle@slow ~]$ lsnrctl status
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-JAN-2018 21:32:05
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=slow)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 13-JAN-2018 21:31:20
Uptime 0 days 0 hr. 0 min. 44 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/slow/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=slow)(PORT=1521)))
Services Summary...
Service "slow" has 1 instance(s).
Instance "slow", status READY, has 1 handler(s) for this service...
The command completed successfully
[oracle@slow ~]$
現(xiàn)在的主庫gotime這邊重啟listener
[grid@sink ~]$ lsnrctl stop
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-JAN-2018 21:31:41
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=sink)(PORT=1521)))
The command completed successfully
[grid@sink ~]$ lsnrctl start
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 13-JAN-2018 21:31:46
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u01/11.2.0/grid/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/11.2.0/grid/network/admin/listener.ora
Log messages written to /u01/app/grid/diag/tnslsnr/sink/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=sink)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=sink)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 13-JAN-2018 21:31:46
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/11.2.0/grid/network/admin/listener.ora
Listener Log File /u01/app/grid/diag/tnslsnr/sink/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=sink)(PORT=1521)))
Services Summary...
Service "gotime" has 1 instance(s).
Instance "gotime", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
[grid@sink ~]$
gotime主庫重新啟動,到open
21:32:12 SYS @ gotime >startup force;
ORACLE instance started.
Total System Global Area 521936896 bytes
Fixed Size 2254824 bytes
Variable Size 377489432 bytes
Database Buffers 138412032 bytes
Redo Buffers 3780608 bytes
Database mounted.
Database opened.
21:32:35 SYS @ gotime >
switchover之后的備庫slow,查詢其狀態(tài),not allowed,正常了?。?
21:29:08 SYS @ slow >recover managed standby database disconnect;
Media recovery complete.
21:29:32 SYS @ slow >select name,open_mode,database_role,protection_mode,switchover_status from v$database;
NAME OPEN_MODE DATABASE_ROLE PROTECTION_MODE SWITCHOVER_STATUS
--------- -------------------- ---------------- -------------------- --------------------
SLOW MOUNTED PHYSICAL STANDBY MAXIMUM AVAILABILITY NOT ALLOWED
1 row selected.
Elapsed: 00:00:00.01
21:33:16 SYS @ slow >
在查詢狀態(tài),為to standby了,正常了??!
21:32:35 SYS @ gotime >select name,open_mode,database_role,protection_mode,switchover_status from v$database
21:32:45 2 ;
NAME OPEN_MODE DATABASE_ROLE PROTECTION_MODE SWITCHOVER_STATUS
--------- -------------------- ---------------- -------------------- --------------------
SLOW READ WRITE PRIMARY MAXIMUM AVAILABILITY TO STANDBY
1 row selected.
Elapsed: 00:00:00.02
21:32:47 SYS @ gotime >
看完上述內(nèi)容,你們掌握switchover physical DB怎樣互換primary DB的方法了嗎?如果還想學(xué)到更多技能或想了解更多相關(guān)內(nèi)容,歡迎關(guān)注創(chuàng)新互聯(lián)行業(yè)資訊頻道,感謝各位的閱讀!