1 |
DATA GUARD环境是否正常 |
172.16.31.246/172.16.31.231 |
oracle |
1. 在执行SWITCHOVER操作前,首先确认DATA GUARD环境工作是否正常。1.1 常规检查包括:a) 检查主库上V¥ARCHIVE_DEST视图:SELECT * FROM V¥ARCHIVE_DEST;b) 检查备库上V¥MANAGED_STANDBY视图:SELECT * FROM V¥MANAGED_STANDBY;c) 检查主库和备库上的V¥ARCHIVED_LOG视图:SELECT * FROM V¥ARCHIVED_LOG;d) 检查主库和备库对应的alert告警日志中是否存在错误。2. 如果DATA GUARD环境正常,就需要进行SWITCHOVER切换前的常规检查:2.1确认主库和备库间网络连接通畅;(可以通过ping、ftp等系统工具检查)2.2确认没有活动的会话连接在数据库中;(登录数据库查询V¥SESSION视图,检查是否存在USERNAME IS NULL的会话):SELECT COUNT(*) FROM V¥SESSION WHERE USERNAME IS NOT NULL;3. PRIMARY数据库处于打开的状态,STANDBY数据库处于MOUNT状态;(检查V¥DATABASE视图的OPEN_MODE):SELECT SWITCHOVER_STATUS FROM V¥DATABASE;4. 确保STANDBY数据库处于ARCHIVELOG模式;(检查V¥DATABASE视图的LOG_MODE):SELECT LOG_MODE FROM V¥DATABASE; |
2 |
登Primary数据库节点1切换预备操作 |
172.16.31.231 |
oracle |
查询会话切换状态:SQL> select count(*) from v¥session;SQL> select username, program from v¥session where username is not null;SQL> select switchover_status from v¥database;SWITCHOVER_STATUS------------------TO STANDBY |
3 |
登Primary数据库节点1 |
172.16.31.231 |
oracle |
执行主库的SWITCHOVER切换操作,然后关闭数据库,启动到NOMOUNT状态。SQL> alter database commit to switchover to physical standby with session shutdown;SQL> shutdown immediateSQL> startup nomount |
3 |
|
|
oracle |
SQL> alter database mount;SQL> select switchover_status from v¥database;SWITCHOVER_STATUS------------------TO PRIMARY |
4 |
登录STANDBY数据库 |
172.16.31.246 |
oracle |
SQL> select open_mode, database_role, switchover_status from v¥database;OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS---------- ---------------- ----------------MOUNTED PHYSICAL STANDBY TO PRIMARY |
4 |
|
|
oracle |
SQL> alter database commit to switchover to primary;Database altered. |
4 |
|
|
oracle |
SQL> shutdown immediate |
4 |
|
|
oracle |
SQL> startup.SQL> select open_mode, database_role, switchover_status from v¥database;OPEN_MODE DATABASE_ROLE SWITCHOVER_STATUS---------- ---------------- ----------------READ WRITE PRIMARY TO STANDBY |
5 |
登陆原Primary数据库节点1 |
172.16.31.231 |
oracle |
SQL> alter database recover managed standby database disconnect from session; |