ORA-16456 error, because the slave database is not mounted and the master database to perform switching, detailed solution
If you need to switch the master database to the slave database, the prerequisites are:
(1) The standby database must be in the mount state and the master database must be in the open state.
(2) It must not be in the maximum protection mode.
We sometimes switch the master database to the slave database and forget to put the slave database in the mount state but open state;
After performing the switchover operation on primary:
SQL> alterdatabase commit to switchover to physical standby;
Databasealtered.
View the primary database now:
00: 26: 00sys @ felix SQL> select switchover_status from v $ database;
SWITCHOVER_STATUS
----------------------------------------
RECOVERY NEEDED
Status when we find recovery needed
What should I do if something happens to me at this moment ??
I performed the following operations on the master database: (I thought this would work, but not)
00:26:26 sys @ felix SQL & gt; 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 & gt; shutdown immediate;
ORA-01092: Oracle instance terminated. Disconnection forced
00:27:17 sys @ felix SQL & gt; startup mount;
The ORA-24324: service handle not initialized.
ORA-01041: internal error. hostdefextension doesn't exist
00:27:25 sys @ felix SQL> exit
Then mount the master database:
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.
Run the following command in the standby database:
Mount slave database:
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>
Open the master database:
00:27:41 SQL> alter database open;
Database altered.
Switch the status of the master database and try again:
00:31:30 SQL> alter database commit to switchover to primary;
Database altered.
OK, it's successful. It seems there's hope to go down below.
Continue, 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
I am relieved to finally see to standby !!
OK to start switching between the master and slave databases:
Note: The master database must be in the open state, and the slave database must be in the mount state.
0:41:57 sys @ felix SQL> alter database commit to switchoverto physical standby
Database altered.
The master database is successfully executed:
Perform the following operations on the slave database:
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
Why is it wrong ??? A keyword is missing, from
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. Open the Master/Slave database:
OK. The master and slave databases have been fully switched.