cdb 数据库搭建dataguard
https://yq.aliyun.com/articles/630485
oracle 免密码登陆:(启动observer需要配置密钥钱包)
https://yq.aliyun.com/articles/632510
数据库版本:
Release 12.2.0.1.0
192.168.0.196 prod04 主
192.168.0.197 prod05 备
主备数据库已经配置为dataguard模式。
1,主备启动broker
alter system set dg_broker_start=true;
2 ,配置dg broker
[oracle@prod04 ~]$ dgmgrl
DGMGRL for Linux: Release 12.2.0.1.0 - Production on Fri Aug 31 08:39:49 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
Welcome to DGMGRL, type "help" for information.
DGMGRL> connect / as sysdba
Connected to "cdb"
Connected as SYSDBA.
DGMGRL> CREATE CONFIGURATION cdbdg as PRIMARY DATABASE IS cdb CONNECT IDENTIFIER IS cdb;
Configuration "cdbdg" created with primary database "cdb"
DGMGRL> add database sbcdb AS CONNECT IDENTIFIER IS sbcdb;
Database "sbcdb" added
DGMGRL> SHOW CONFIGURATION;
Configuration - cdbdg
Protection Mode: MaxPerformance
Members:
cdb - Primary database
sbcdb - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
DISABLED
DGMGRL> ENABLE CONFIGURATION;
Enabled.
DGMGRL> show CONFIGURATION;
Configuration - cdbdg
Protection Mode: MaxPerformance
Members:
cdb - Primary database
sbcdb - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS (status updated 315 seconds ago)
3 ,检查同步状态
DGMGRL> SHOW DATABASE sbcdb;
Database - sbcdb
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 1 second ago)
Apply Lag: 0 seconds (computed 1 second ago)
Average Apply Rate: 3.00 KByte/s
Real Time Query: ON
Instance(s):
cdb
Database Status:
SUCCESS
4 ,更改数据库保护模式
DGMGRL> SHOW DATABASE VERBOSE sbcdb LogXptMode;
LogXptMode = 'ASYNC'
DGMGRL> SHOW DATABASE VERBOSE cdb LogXptMode;
LogXptMode = 'ASYNC'
DGMGRL> EDIT DATABASE cdb set PROPERTY 'LogXptMode'='sync';
Property "LogXptMode" updated
DGMGRL> EDIT DATABASE sbcdb set PROPERTY 'LogXptMode'='sync';
Property "LogXptMode" updated
DGMGRL> SHOW DATABASE VERBOSE sbcdb LogXptMode;
LogXptMode = 'sync'
DGMGRL> SHOW DATABASE VERBOSE cdb LogXptMode;
LogXptMode = 'sync'
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
Succeeded.
DGMGRL> SHOW CONFIGURATION;
Configuration - cdbdg
Protection Mode: MaxAvailability
Members:
cdb - Primary database
sbcdb - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS (status updated 46 seconds ago)
5,开启快速故障切换
5,1 observer配置
#####
更改数据库保护模式MAXAVAILABILITY:
DGMGRL> EDIT DATABASE cdb set PROPERTY 'LogXptMode'='sync';
Property "LogXptMode" updated
DGMGRL> EDIT DATABASE sbcdb set PROPERTY 'LogXptMode'='sync';
DGMGRL> EDIT DATABASE cdb SET PROPERTY FastStartFailoverTarget=sbcdb;
Property "faststartfailovertarget" updated
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
Succeeded.
#####
主备数据库开启数据库闪回:
ALTER SYSTEM SET UNDO_RETENTION=3600 SCOPE=SPFILE;
ALTER SYSTEM SET UNDO_MANAGEMENT='AUTO' SCOPE=SPFILE;
SHUTDOWN IMMEDIATE;
STARTUP MOUNT;
SHOW PARAMETER UNDO;
ALTER SYSTEM SET DB_FLASHBACK_RETENTION_TARGET=4320 SCOPE=BOTH;
ALTER SYSTEM SET db_recovery_file_dest_size=5G;
ALTER SYSTEM SET db_recovery_file_dest='/u01/app/arc';
ALTER DATABASE FLASHBACK ON;
ALTER DATABASE OPEN;
#####
配置钱包
mkdir –p /u01/app/oracle/wallet/
mkstore –wrl /u01/app/oracle/wallet/ -create
mkstore -wrl /u01/app/oracle/wallet/ -createCredential cdb sys oracle
mkstore -wrl /u01/app/oracle/wallet/ -createCredential sbcdb sys oracle
#####
sqlnet.ora
[oracle@prod04 admin]$ cat sqlnet.ora
NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME,EZCONNECT)
WALLET_LOCATION=(SOURCE=(METHOD=FILE)(METHOD_DATA=(DIRECTORY=/u01/app/oracle/wallet/)))
SQLNET.WALLET_OVERRIDE=TRUE
#####
启动observer
[oracle@prod04 admin]$ dgmgrl sys/oracle
DGMGRL for Linux: Release 12.2.0.1.0 - Production on Fri Aug 31 11:27:23 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected to "cdb"
Connected as SYSDG.
DGMGRL> start observer ob1 in background logfile is '/u01/observerlog' connect identifier is cdb;
Submitted command "START OBSERVER" using connect identifier "cdb"
DGMGRL> show observer
Configuration - cdbdg
Fast-Start Failover: DISABLED
Observer "ob1"
Host Name: prod04
Last Ping to Primary: 2 seconds ago
DGMGRL>
5.2 停止observer
[oracle@prod04 ~]$ dgmgrl sys/oracle
DGMGRL for Linux: Release 12.2.0.1.0 - Production on Fri Aug 31 10:36:30 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected to "cdb"
Connected as SYSDG.
DGMGRL> show observer
Configuration - cdbdg
Fast-Start Failover: DISABLED
Observer "observer01"
Host Name: prod05
Last Ping to Primary: 26 seconds ago
Observer "observer02"
Host Name: prod04
Last Ping to Primary: 15 seconds ago
DGMGRL> stop observer observer01
Observer stopped.
DGMGRL> stop observer observer02
Observer stopped.
DGMGRL> show observer
Configuration - cdbdg
Fast-Start Failover: DISABLED
No observers.
5.3 启动快速故障切换
[oracle@prod05 admin]$ dgmgrl sys/oracle
DGMGRL for Linux: Release 12.2.0.1.0 - Production on Fri Aug 31 11:30:56 2018
Copyright (c) 1982, 2017, Oracle and/or its affiliates. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected to "sbcdb"
Connected as SYSDG.
DGMGRL> show observer;
Configuration - cdbdg
Fast-Start Failover: DISABLED
Observer "ob1"
Host Name: prod04
Last Ping to Primary: 28 seconds ago
DGMGRL> ENABLE FAST_START FAILOVER;
Enabled.
DGMGRL> SHOW FAST_START FAILOVER;
Fast-Start Failover: ENABLED
Threshold: 30 seconds
Target: sbcdb
Observer: ob1
Lag Limit: 30 seconds (not in use)
Shutdown Primary: TRUE
Auto-reinstate: TRUE
Observer Reconnect: (none)
Observer Override: FALSE
Configurable Failover Conditions
Health Conditions:
Corrupted Controlfile YES
Corrupted Dictionary YES
Inaccessible Logfile NO
Stuck Archiver NO
Datafile Write Errors YES
Oracle Error Conditions:
(none)
DGMGRL> SHOW DATABASE cdb FastStartFailoverTarget;
FastStartFailoverTarget = 'sbcdb'
DGMGRL> SHOW DATABASE sbcdb FastStartFailoverTarget;
FastStartFailoverTarget = ''
DGMGRL>