1、adg standby
temp可调整
redo可调整
2、无gap但mrp延迟
io慢
切换快
3、投递error
alter system set log_archive_dest_state_1=defer;
alter system set log_archive_dest_state_1=enable;
4、保护归档
CONF ARCH DEL POLICY TO APPLIED ON ALL STANDBY
5、解决GAP问题
alter database register logfile '/arc2/a_1_160_821829622.arc';
alter database recover managed standby database cancel;
alter database recover managed standby database disconnect from session;
select max(sequence#) from v$archived_log;
161
6、搭建备库restore后检查
(1)SQL>restore config test;
(2)然后检查alert日志
7、11g flush redo DG failover时小化数据丢失
(1) 确认主库是否mount状态
(2)备库redo apply是否启用
(3)ALTER SYSTEM FLUSH REDO TO 'shsnc_standby';
8、主备延迟
(1)主动测试是否延迟:
主库> alter system switch logfile;
主库> select max(sequence#) from v$archived_log;
28
备库:通过alert.log确认
(2)通过DG Broker来查看主备延迟
DGMGRL> show database verbose sol;
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 3 minutes 37 seconds
Apply Lag: 3 minutes 37 seconds
Real Time Query: ON
(3)select * from v$dataguard_stats
2 apply lag +00 12:20:27 day(2) to second(0) interval28-MAY-2018 07:22:45
5 transport lag+00 00:00:00 day(2) to second(0) interval28-MAY-2018 07:22:45
TRANSPORT LAG为0,但是APPLY LAG却不为0
(4)select process, status, sequence# , ACTIVE_AGENTS from gv$managed_standby;
mrp0进程信息
rfs进程信息
arch进程信息
(5)select DEST_NAME,status,TARGET,ARCHIVER,LOG_SEQUENCE,DESTINATION,ERROR from v$archive_dest where status<>'INACTIVE';
9、延迟物理备库(分钟?)
方法1:
alter database recover managed standby database delay 120 disconnect from session;
方法2:
alter system set log_archive_dest_3='service=db3 lgwr async delay=120 valid_for=(all_logfiles,all_roles)db_unique_name=db3';
10、三种保护模式
(1)大保护,就是发现当redo log没法传到至少一个备库时,主库上就不执行这条命令、且shutdown。性能低安全。
至少一个 standby库redo被同步写入
(2)大性能,就是不管redo log能不能传到至少一个备库,主库都会执行这条命令。性能高不安全。
(3)大可用,当 redo log可以传到至少一个备库时,和大保护模式相同。但如果不能传到至少一个备库是,就自动转到大性能模式既执行这条命令。性能和安全性取中间。
11、启用Data Guard重做传输压缩
(1)LOG_ARCHIVE_DEST_2='SERVICE=b COMPRESSION=ENABLE DB_UNIQUE_NAME=b'
(3)用Data Guard Broker设置
DGMGRL> EDIT DATABASE 'b' SET PROPERTY 'RedoCompression' = ENABLE;
(3)重做压缩可以:
减少重做传输滞后来提高数据保护
降低网络利用率
提供更快的重做间隙分辨率
减少重做传输时间
12、切换为snapshot standby
alter system set db_recovery_file_dest='/dt/rec';
alter system set db_recovery_file_dest_size=99G;
alter database convert to snapshot standby;
alter database open;
13、从snapshot恢复到正常adg备库
startup mount;
alter database convert to physical standby;
14、Standby Redo Log
standby用standby redologs可以打开real-time apply,这样dg就不需要再等待接收完归档文件,只要rfs将 redo数据写入Standby RedoLogs,即可通过MRP/LSP实时写向standby。语句:
ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE ;
15、SWITCHOVER
(1)提前准备tns、srl
(2)主库:
alter database commit to switchover to physical standby with session shutdown;
(3)备库:
alter database commit to switchover to primary;
16、failover
(1)主库挂掉
Failover指由于Primary故障无法短时间恢复,Standby不得不充当Primay的角色,如果处于高性能模式,这种切换很有可能导致数据丢失。
(2)备库注册gap的归档并apply
(3)备库上停止Redo Apply
alter database recover managed standby database cancel;
(4)备库上finish applying
alter database recover managed standby database finish;
(5)备库开始switchover
alter database commit to switchover to primary with session shutdown;
17、DG参数
(1)standby_file_management
设为auto,主库增删文件会相应地自动在备库做出修改;
设为manual,当在primary执行drop tablespace .. including contents and datafiles,standby 只在控制文件中删除,还需手动将物理文件删除
(2)db_file_name_convert写全名
(3)db_create_file_dest要留意
(4)主备密码文件要相同
(5)alter system set log_archive_config = 'DG_CONFIG=(pri,std)';
(6)fal_server和fal_client
一旦产生了gap,fal_client会自动向fal_server请求传输gap的archivelog。
fal_client设为自身的service name,
fal_server设为远端的service name。
fal_server可以设置多个值。
primary:
*.fal_server='dev01dg'
*.fal_client='dev01'
standby:
*.fal_server='dev01'
*.fal_client='dev01dg'
(6)name规划
db_name:videodb DG的主备库相同
db_unique_name:shvideo DG主备库之间不能相同
service_names:videodb, shvideo 对业务来说,不能觉得有变化
(7)convert=主,本备库,主,本备库
*.db_file_name_convert='+DATA01/cadxdb/','+DATA01/cadxdb_dg/','+DATA02/cadxdb/','+DATA01/cadxdb_dg/','+DATA01/cadxdb/datafile/','+DATA01/cadxdb_dg/datafile/','+DATA02/cadxdb/datafile/','+DATA01/cadxdb_dg/datafile/'
*.log_file_name_convert='+DATA01/cadxdb/','+DATA01/cadxdb_dg/'
--如果日志有其他磁盘组的成员,注意再添加路径转换内容
18、故障案例
(1)'./dbs/UNNAMED00005'
(2)改standby_file_management
(3)alter database create datafile './dbs/UNNAMED00005' as './test.dbf';
(4)改standby_file_management
动力小刚于2019年5月 个人邮箱:zcs0237#163.com