时间:2021-07-01 10:21:17 帮助过:94人阅读
ORA-16456错误,由于备库未mount而在主库执行切换,解决办法详解
如果对数据库进行主备库的切换需要的前提条件是:
我们有时做主备库的切换,结果忘记了把备库处于mount状态而是open状态下;
当在primary执行过切换操作之后:
SQL>alterdatabase commit to switchover to physical standby;
Databasealtered.
现在对primary库进行查看:
00:26:00sys@felix SQL>select switchover_status from v$database;
SWITCHOVER_STATUS
----------------------------------------
RECOVERY NEEDED
状态我们发现时recovery needed
这个时刻,我感觉出事了,该怎么办??
我就在主库执行了如下操作:(以为这样会可以的,但是不行)
00:26:26 sys@felix SQL>alter database commit to switchoverto primary;
alter database commit to switchover to primary
*
ERROR at line 1:
ORA-16456: switchover to standby in progress or completed
0:26:54 sys@felix SQL>shutdown immediate;
ORA-01092: Oracle instance terminated.Disconnection forced
00:27:17 sys@felix SQL>startup mount;
ORA-24324: service handle not initialized
ORA-01041: internal error. hostdefextension doesn't exist
00:27:25 sys@felix SQL>exit
然后mount主库:
00:27:30 SQL>startup mount;
ORACLE instance started.
Total System Global Area 417546240 bytes
Fixed Size 2228944 bytes
Variable Size 289410352 bytes
Database Buffers 121634816 bytes
Redo Buffers 4272128 bytes
Database mounted.
mount备库:
03:21:36 SQL>shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
03:21:48 SQL>startup mount;
ORACLE instance started.
Total System Global Area 417546240 bytes
Fixed Size 2228944 bytes
Variable Size 289410352 bytes
Database Buffers 121634816 bytes
Redo Buffers 4272128 bytes
Database mounted.
03:22:02 SQL>
打开主库:
00:27:41 SQL>alter database open;
Database altered.
把主库的切换状态进行切换过来,再试一下:
00:31:30 SQL>alter database commit to switchover to primary;
Database altered.
Ok,成功了,看来往下面走是有希望了
继续,go!!!!
00:32:08 sys@felix SQL>select statusfrom v$instance;
STATUS
------------------------
MOUNTED
00:32:22 sys@felix SQL>alter database open;
Database altered.
00:32:32 sys@felix SQL>selectswitchover_status from v$database;
SWITCHOVER_STATUS
----------------------------------------
TO STANDBY
终于看到to standby了,心里算是松了一口气!!
ok,,开始真正的主备库的切换:
0:41:57 sys@felix SQL> alter database commit to switchoverto physical standby
Database altered.
主库执行成功:
在备库要进行操作:
03:46:06 SQL>select switchover_status from v$database;
SWITCHOVER_STATUS
----------------------------------------
RECOVERY NEEDED
03:46:46 SQL>alter database recover managed standbydatabase disconnect session;
alter database recovermanaged standby database disconnect session
*
ERROR at line 1:
ORA-00274: illegalrecovery option SESSION
03:52:23 SQL>alter database recover managed standby database disconnect FROMsession;
Database altered.
ORACLE instance shut down.
03:56:01 SQL>startup
ORACLE instance started.
Total System Global Area 417546240 bytes
Fixed Size 2228944 bytes
Variable Size 301993264 bytes
Database Buffers 109051904 bytes
Redo Buffers 4272128 bytes
Database mounted.
Database opened.
03:56:43 SQL>select switchover_status from v$database;
SWITCHOVER_STATUS
----------------------------------------
TO PRIMARY
03:57:13 SQL>alter database commit to switchover to primary;
Database altered.
03:57:42 SQL>shutdown immediate;
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
03:58:20 SQL>
Ok,打开主备库:
Ok,到此主备库已经完整切换了