千家信息网

Oracle DG主备启动和关闭流程

发表于:2025-02-01 作者:千家信息网编辑
千家信息网最后更新 2025年02月01日,环境:Oracle 11g RAC和DG关闭操作流程:RAC节点:关闭primary主机:SQL>shutdown immediate无法shutdown immediateSQL> shutdown
千家信息网最后更新 2025年02月01日Oracle DG主备启动和关闭流程

环境:

Oracle 11g RAC和DG


关闭操作流程

RAC节点:

关闭primary主机:

SQL>shutdown immediate

无法shutdown immediate

SQL> shutdown abort;

ORACLE instance shut down.

SQL> startup restrict;

ORACLE instance started.

SQL> shutdown

Database closed.

Database dismounted.

ORACLE instance shut down.


关闭standby主机:

SQL>alter database recover managed standby database cancel;

SQL>shutdown immediate


开启操作流程

开启standby主机:


SQL> startup mount;
ORACLE instance started.

Total System Global Area 1.7103E+10 bytes
Fixed Size 2245480 bytes
Variable Size 2181041304 bytes
Database Buffers 1.4898E+10 bytes
Redo Buffers 21708800 bytes
Database mounted.
SQL> select RECOVERY_MODE from v$archive_dest_status where rownum<5;

RECOVERY_MODE
-----------------------
IDLE
IDLE
IDLE

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;
Database altered.
开启primary主机:
primary主机是RAC,会自动拉起来。
primary主机RAC一切正常。

发现standby主机监听不正常:
重启监听。
[oracle@dg ~]$ lsnrctl status


LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 11-DEC-2017 15:12:16


Copyright (c) 1991, 2011, Oracle. All rights reserved.


Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused


[oracle@dg ~]$ lsnrctl stop


LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 11-DEC-2017 15:12:37


Copyright (c) 1991, 2011, Oracle. All rights reserved.


Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
[oracle@dg ~]$ lsnrctl start


LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 11-DEC-2017 15:12:44


Copyright (c) 1991, 2011, Oracle. All rights reserved.


Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...


TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Log messages written to /u01/app/oracle/diag/tnslsnr/dg/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg)(PORT=1521)))


Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 11-DEC-2017 15:12:45
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Log File /u01/app/oracle/diag/tnslsnr/dg/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg)(PORT=1521)))
The listener supports no services
The command completed successfully
[oracle@dg ~]$ lsnrctl status


LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 11-DEC-2017 15:13:29


Copyright (c) 1991, 2011, Oracle. All rights reserved.


Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 11-DEC-2017 15:12:45
Uptime 0 days 0 hr. 0 min. 44 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Log File /u01/app/oracle/diag/tnslsnr/dg/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dg)(PORT=1521)))
Services Summary...
Service "DG" has 1 instance(s).
Instance "DG", status READY, has 1 handler(s) for this service...
The command completed successfully

开启standby主机的只读功能:
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;


Database altered.


SQL> alter database open read only;


Database altered.


SQL> select RECOVERY_MODE from v$archive_dest_status where rownum<5;


RECOVERY_MODE
-----------------------
IDLE
IDLE
IDLE
IDLE


SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;


Database altered.


SQL> select RECOVERY_MODE from v$archive_dest_status where rownum<5;


RECOVERY_MODE
-----------------------
MANAGED REAL TIME APPLY
IDLE
IDLE
IDLE

主备的alert日志正常:
RAC01 alert日志:
Thread 1 advanced to log sequence 35614 (LGWR switch)
Current log# 2 seq# 35614 mem# 0: +DATA/prd/onlinelog/group_2.257.929893623
Mon Dec 11 15:50:16 2017
LNS: Standby redo logfile selected for thread 1 sequence 35614 for destination LOG_ARCHIVE_DEST_2
Mon Dec 11 15:50:16 2017
Archived Log entry 94045 added for thread 1 sequence 35613 ID 0x35485ff1 dest 1:

RAC02 alert日志:
Thread 2 advanced to log sequence 18461 (LGWR switch)
Current log# 3 seq# 18461 mem# 0: +DATA/prd/onlinelog/group_3.261.929893729
Mon Dec 11 15:32:10 2017
LNS: Standby redo logfile selected for thread 2 sequence 18461 for destination LOG_ARCHIVE_DEST_2
Mon Dec 11 15:32:11 2017
Archived Log entry 94043 added for thread 2 sequence 18460 ID 0x35485ff1 dest 1:


DG alert日志:
Media Recovery Waiting for thread 2 sequence 18461 (in transit)
Recovery of Online Redo Log: Thread 2 Group 8 Seq 18461 Reading mem 0
Mem# 0: /oracle/oradata/standby08.log
Mon Dec 11 15:50:16 2017
RFS[4]: Selected log 6 for thread 1 sequence 35614 dbid 893924085 branch 929893623
Mon Dec 11 15:50:16 2017
Media Recovery Waiting for thread 1 sequence 35614 (in transit)
Recovery of Online Redo Log: Thread 1 Group 6 Seq 35614 Reading mem 0
Mem# 0: /oracle/oradata/standby06.log
Mon Dec 11 15:51:44 2017
Archived Log entry 40467 added for thread 1 sequence 35613 ID 0x35485ff1 dest 1:


如果通过重启监听无法解决DG节点的监听问题,可以通过动态注册监听来解决

alter system register









0