1 启用dgmgrl
相关参数:
dg_broker_start
dg_broker_config_file1
配置:
alter system set dg_broker_start=true scope=both;
此时数据库会增加dmon进程
[oracle@12crac2 ~]$ ps -ef|grep -i _dmon|grep -v grep
oracle 2699 1 0 06:57 ? 00:00:01 ora_dmon_db1
对应log:$ORACLE_BASE/diag/rdbms/xxx/xxxx/drc$ORACLE_SID.log
但此时使用是用不了的,如下所示:
DGMGRL> show configuration
ORA-16532: Data Guard broker configuration does not exist
需手动配置添加:
DGMGRL> help create
DGMGRL> create configuration 'db' as primary database is db connect identifier is db;
DGMGRL>help add
DGMGRL>add database "SBDB1" as connect identifier is "sbdb1" maintained as physical;
DGMGRL>enable configuration
注:add database 'SBDB1' ,这里的dg是指database的dbuniquename,而as connect identifier is sbdb1这里的sbdb1是指tnsname.ora连接到standby database的net service name.注意区分大小,默认为小写;
同时检查alert_$ORACLE_SID.log日志可以看到:
RSM0 started with pid=48, OS id=34551
ALTER SYSTEM SET log_archive_dest_1='location=USE_DB_RECOVERY_FILE_DEST','valid_for=(ALL_LOGFILES, ALL_ROLES)' SCOPE=BOTH;
ALTER SYSTEM SET log_archive_trace=0 SCOPE=BOTH SID='db1';
ALTER SYSTEM SET log_archive_format='%t_%s_%r.dbf' SCOPE=SPFILE SID='db1';
ALTER SYSTEM SET standby_file_management='AUTO' SCOPE=BOTH SID='*';
ALTER SYSTEM SET archive_lag_target=0 SCOPE=BOTH SID='*';
ALTER SYSTEM SET log_archive_max_processes=4 SCOPE=BOTH SID='*';
ALTER SYSTEM SET log_archive_min_succeed_dest=1 SCOPE=BOTH SID='*';
检查drc$ORACLE_SID.log:
Creating Data Guard Broker Monitor Process (DMON)
04/03/2018 23:26:33
>> Starting Data Guard Broker bootstrap <<
Broker Configuration File Locations:
dg_broker_config_file1 = "/u01/app/oracle/product/11.2.0/dbhome_1/dbs/dr1SBDB1.dat"
dg_broker_config_file2 = "/u01/app/oracle/product/11.2.0/dbhome_1/dbs/dr2SBDB1.dat"
04/03/2018 23:26:38
Broker Configuration: "db"
Protection Mode: Maximum Performance
Fast-Start Failover (FSFO): Disabled, flags=0x0, version=0
Primary Database: db (0x01010000)
Standby Database: SBDB1, Enabled Physical Standby (0x02010000)
所有配置完成,这玩意只能用在企业版
二 检查配置:
DGMGRL> show database sbdb1
Object "sbdb1" was not found
DGMGRL> show database SBDB1
Object "sbdb1" was not found
注意大小写
DGMGRL> show database 'SBDB1'
Database - SBDB1
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds (computed 0 seconds ago)
Apply Lag: 0 seconds (computed 0 seconds ago)
Apply Rate: 0 Byte/s
Real Time Query: ON
Instance(s):
SBDB1
Database Status:
SUCCESS
三 相关测试:snapshot standby,switchover
3.1不开database flashback on 测试:
不用dgmrl的方法参见:https://blog.51cto.com/snowhill/2047857
DGMGRL> convert database 'SBDB1' to snapshot standby;
Converting database "SBDB1" to a Snapshot Standby database, please wait...
Database "SBDB1" converted successfully
这里从alert_sbdb1.log里看,数据库并没有发生重启,只是将会话杀掉了;
SQL> select open_mode, database_role, protection_mode,flashback_on from v$database;
OPEN_MODE DATABASE_ROLE PROTECTION_MODE FLASHBACK_ON
-------------------- ---------------- -------------------- ------------------
READ WRITE SNAPSHOT STANDBY MAXIMUM PERFORMANCE **RESTORE