oracle dg 状态检查
先检查备库的归档日志同步情况
select name,applied from v$archived_log;
alter database recover managed standby database cancel;
select thread#,sequence#,standby_dest,archived,applied,status from v$archived_log order by 1,2;
alter database recover managed standby database using current logfile disconnect from session;
.在备库 查看gap
1. select * from v$archive_gap;
alter database recover managed standby database disconnect from session;
查看主库的基本信息:
sys@enmo1 hey~1->select open_mode,protection_mode,database_role,switchover_status from v$database;
open_mode protection_mode database_role switchover_status
——————– —————————– ———————— ————————
read write maximum performance primary to standby
查看备库的基本信息:
sys@enmo2 hey~2->select open_mode,protection_mode,database_role,switchover_status from v$database;
open_mode protection_mode database_role switchover_status
————————- —————————– ———————— ————————
read only with apply maximum performance physical standby not allowed
备库应用日志保持和主库数据一致(如果不一致,执行如下语句应用日志)
sys@enmo2 hey~2->recover managed standby database using current logfile disconnect from session;
media recovery complete.
sys@enmo2 hey~2->recover managed standby database cancel;
media recovery complete.
主库切换到备库角色并查看切换之后的状态为recovery needed
sys@enmo1 hey~1->alter database commit to switchover to physical standby with session shutdown;
database altered.
sys@enmo1 hey~1->shutdown abort;
oracle instance started.
total system global area 830930944 bytes
fixed size 2257800 bytes
variable size 700451960 bytes
database buffers 121634816 bytes
redo buffers 6586368 bytes
database mounted.
sys@enmo1 hey~1->select switchover_status from v$database;
switchover_status
——————–
recovery needed
切换应用日志,然后在查看切换状态为to primary正常:
sys@enmo1 hey~1->recover managed standby database using current logfile disconnect from session;
media recovery complete.
sys@enmo1 hey~1->select switchover_status from v$database;
switchover_status
——————–
to primary
备库切主库:
sys@enmo2 hey~2->select open_mode,protection_mode,database_role,switchover_status from v$database;
open_mode protection_mode database_role switchover_status
——————– ——————– —————- ——————–
mounted maximum performance physical standby to primary
sys@enmo2 hey~2->alter database commit to switchover to primary with session shutdown;
database altered.
sys@enmo2 hey~2->alter database open;
database altered.
sys@enmo2 hey~2->select switchover_status,database_role from v$database;
switchover_status database_role
——————– —————-
failed destination primary
sys@enmo2 hey~2->select open_mode,protection_mode,database_role from v$database;
open_mode protection_mode database_role
——————– ——————– —————-
read write maximum performance primary
二、备库不同步的问题检查方法
1、检查主备两边的序号
select max(sequence#) from v$log; —检查发现一致
2、备库执行,查看是否有数据未应用
select name,sequence#,applied from v$archived_log order by sequence#;
select sequence#,first_time,next_time ,applied from v$archived_log order by 1;
3、检查备库是否开启实时应用
select recovery_mode from v$archive_dest_status where dest_id=2;
4、检查备库状态
select switchover_status from v$database; –发现状态not allowed
3、看看进程mrp是否存在
ps aux|grep mrp –发现进程不存在
4、如果不存在执行以下:
alter database recover managed standby database using current logfile disconnect;
alter database recover managed standby database disconnect from session; –后台执行
alter database recover managed standby database –前台执行,执行这个可以看到报错的情况
如果有报错,查看alert日志和log.xml日志
5、验证是否正常
select process,status from v$managed_standby;
select process,status,sequence# from v$managed_standby;
如果看到mrp0正常
6、以上步骤处理好后,如果数据还不正常,接着处理
关闭备库,接着处理:
把主库上 undotbs01.dbf 文件,物理的重拷到备库机上以前undotbs01.dbf 所在目录下;
$scp /data/oracle/oradata/voip/undotbs01.dbf 192.168.122.204:/data/oracle/oradata/voip
再在主库上重新生成一个standby control file ,拷到备库机上相应目录下,
alter database create standby controlfile as ‘/data/oracle/oradata/voip/qyqdg01.ctl’
$scp /data/oracle/oradata/voip/qyqdg01.ctl 192.168.122.204:/data/oracle/oradata/voip
$ mv qyqdg01.ctl control01.ctl
$ cp control01.ctl /data/oracle/flash_recovery_area/qyq/
$cd /data/oracle/flash_recovery_area/qyq/
$ mv control01.ctl control02.ctl
接着
startup nomount;
alter database mount standby database;
alter database recover managed standby database disconnect from session;
————————————–
session恢复完成后,重启打开备库;
alter database open read only;