背景:公司有一套财务共享系统共18台服务器,其中oracle数据库RAC+DG,最近在容灾环境把所以服务器做还原演练。
所有的服务器,都是虚拟机,只有rac01和rac02不是,所以,RAC架构无法还原,只能还原adg。也就是今天的主题了:
抛弃主库,切换备库为主库。
通过这里https://www.modb.pro/doc/7556,大家可以看到,DG主备切换有2种方式,今天我要操作的是:failover方式。
但此次操作并非顺利的failover切换,如果是,我就不会重复写了。后面有意外,所以才到墨天轮记录。
开始操作,尝试下直接启动
SQL> startup;
ORACLE instance started.
Fixed Size 2269872 bytes
Variable Size 1442843984 bytes
Database Buffers 6895435776 bytes
Redo Buffers
10600448 bytes
Database mounted.
ORA-10458: standby database requires
recovery
ORA-01196: file 1 is inconsistent due to a
failed media recovery session
ORA-01110: data file 1:
'/u01/app/oracle/oradata/fsscdbadg/system.266.1029837385'
提示这是备库,需要recovery
查看备库的切换状态
SQL> select switchover_status from
v$database;
--------------------
NOT ALLOWED
--关闭物理备库的当前连接会话
SQL> Alter database commit to switchover
to physical standby with session shutdown;
--备库停掉redo apply (还可以强制,后面再加上force,但没试过)
SQL> alter database recover managed
standby database finish;
--再看查备库的切换状态
SQL> select switchover_status from
v$database;
--------------------
TO PRIMARY
--切换
SQL> alter database commit to switchover
to primary;
--关闭实例
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 8351150080 bytes
Fixed Size 2269872 bytes
Variable Size 1442843984 bytes
Database Buffers 6895435776 bytes
Redo Buffers
10600448 bytes
Database mounted.
Database opened.
SQL> select database_role from
v$database;
----------------
PRIMARY
--操作新增个表
SQL> create table test as select * from
dba_objects where rownum =1;
Table created.
看起来一切顺利,可以结贴了,但是:
alert日志,一直提示:
PING[ARC2]: Heartbeat failed to connect to standby 'fsscdb1'. Error is 12154.
Thu Jan 13 13:16:40 2022
Process m000 submission failed with error = 20
Thu Jan 13 13:16:40 2022
Starting background process SMCO
Process SMCO submission failed with error = 20
最后就出现了:
Errors in file
/u01/app/oracle/diag/rdbms/fsscdbadg/fsscdbadg/trace/fsscdbadg_pmon_18960.trc:
ORA-00444: background process "SMCO" failed while starting
ORA-00020: maximum number of processes (150) exceeded
连接进程超过150,你用sqlplus / as sysdba无法进去了,出现:
最后去trc日志里面查看,发现了:
Error 12154 connecting to destination
LOG_ARCHIVE_DEST_2 standby host 'fsscdb1'
Error 12154 attaching to destination
LOG_ARCHIVE_DEST_2 standby host 'fsscdb1'
*** 2022-01-13 13:06:07.653 4329 krsh.c
Error 12154 for archive log file 5 to
'fsscdb1'
查看LOG_ARCHIVE_DEST_2;:
SQL> show parameter LOG_ARCHIVE_DEST_2;
NAME TYPE VALUE
------------------------------------
----------- ------------------------------
log_archive_dest_2
string service=fsscdb1
ASYNC valid_fo
r=(online_logfiles,primary_rol
e) db_unique_name=fsscdb
说明这时候,他一直要往fsscdb1发送日志
SQL> alter system set LOG_ARCHIVE_DEST_2 = '';
System altered.
此时alert日志终于消停了。看起来问题解决了。
赶紧到墨天轮把经过纪录下来。如果还要意外,我再回来修改。