Environment Overview: Good Dataguard, build reference: http://blog.51cto.com/snowhill/1923591
Source: db_name:db RAC
Preparation: DB_NAME:SBDB1 stand-alone
1 Enable DGMGRL
Related parameters:
Dg_broker_start
Dg_broker_config_file1
Configuration:
alter system set dg_broker_start=true scope=both;
At this point the database will increase the Dmon process
[[email protected] ~]$ ps -ef|grep -i _dmon|grep -v greporacle 2699 1 0 06:57 ? 00:00:01 ora_dmon_db1
But at this point, use
DGMGRL> show configurationORA-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 addDGMGRL>add database "SBDB1" as connect identifier is "sbdb1" maintained as physical;DGMGRL>enable configuration
Add database ' SBDB1 ', where the DG refers to the database Db_unique_name, and as connect identifier is SBDB1 here SBDB1 refers to Tnsname.ora connected to standby The net service name for database.
Note the size, default is lowercase;
Check the Alert_$oracle_sid.log log to see:
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=‘*‘;
Check 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:38Broker 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)
Two check configuration:
DGMGRL> show database sbdb1Object "sbdb1" was not foundDGMGRL> show database SBDB1 Object "sbdb1" was not found
Note case
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
Three snapshot standby test
Method without DGMRL See: http://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
Here from Alert_sbdb1.log, the database does not restart, but the session was killed;
3.1 Do not open database flashback on test :
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 POINT ONLYSQL> truncate table system.test; Table truncated. SQL> select count(*) from system.test; COUNT(*)---------- 0 DGMGRL>convet database ‘SBDB1‘ to physical standby;Unable to connect to databaseORA-12545: Connect failed because target host or object does not exist Failed.Warning: You are no longer connected to ORACLE. Please complete the following steps and reissue the CONVERT command: shut down instance "SBDB1" of database "SBDB1" start up and mount instance "SBDB1" of database "SBDB1"
Manually start the standby to Mount state, the rear dgmgrl automatically revert to sbdb1, but in the open process will often die in the last step, the relevant log is as follows:
ALTER DATABASE CONVERT to Physical STANDBY (SBDB1) Killing 3 processes with PIDs 3013,3017,3019 (all RFS) in order to Disal Low current and the future RFS connections. Requested by OS process 3025Flashback restore startflashback restore Completedrop guaranteed restore point guaranteed rest Ore point droppedclearing Standby activation ID 1736364983 (0X677ED3B7) The primary database Controlfile is created using The ' maxlogfiles 192 ' clause. There is space for up to 188 standby redo Logfilesuse The following SQL commands on the standby database to Createstandby Redo logfiles that match the primary Database:alter database ADD STANDBY LOGFILE ' srl1.f ' SIZE 52428800; ALTER DATABASE ADD STANDBY LOGFILE ' srl2.f ' SIZE 52428800; ALTER DATABASE ADD STANDBY LOGFILE ' srl3.f ' SIZE 52428800; ALTER DATABASE ADD STANDBY LOGFILE ' srl4.f ' SIZE 52428800; ALTER DATABASE ADD STANDBY LOGFILE ' srl5.f ' SIZE 52428800; Waiting-non-current orls to be archived ... All Non-current Orls has been archived. Clearing online REdo logfile 1/u01/app/oracle/oradata/sbdb1/sbdb1/onlinelog/o1_mf_1_fd4wmho5_.logclearing online log 1 of thread 1 Sequence number 3Clearing online redo logfile 1 completeclearing online redo logfile 2/u01/app/oracle/oradata/sbdb1/sbdb1 /onlinelog/o1_mf_2_fd4wmjq3_.logclearing online log 2 of thread 1 sequence number 4Clearing online redo logfile 2 complete Completed:alter database Convert to physical standbywed APR 01:15:50 2018Primary database was in MAXIMUM performance mo DERFS[3]: Assigned to RFS process 3029rfs[3]: Selected log 5 for thread 1 sequence dbid 1729483220 branch 965667412Wed APR 01:16:11 2018rfs[4]: Assigned to RFS process 3031rfs[4]: Selected log 6 for thread 1 sequence dbid 1729483220 BR Anch 965667412Wed Apr 01:16:11 2018Expanded controlfile section one from $203 recordsrequested to grow by 175 Recor ds Added 7 blocks of recordsarchived Log entry added for thread 1 sequence ID 0x6715d4d4 dest 1:wed Apr 04 01:16:13 201 8arc2:becoming the activeHeartbeat archwed APR 01:17:13 2018alter database openData Guard Broker initializing ...
The last step will be suspended animation, it doesn't matter, directly shutdown abort, then start, on it; because of DGMGRL, he will automatically fill in the command, as shown in:
SQL> select open_mode, database_role, protection_mode,flashback_on from v$database; OPEN_MODE DATABASE_ROLE PROTECTION_MODE FLASHBACK_ON-------------------- ---------------- -------------------- ------------------READ ONLY WITH APPLY PHYSICAL STANDBY MAXIMUM PERFORMANCE NOSQL> select count(*) from system.test; COUNT(*)---------- 15386
Why automatic, check database configuration:
DGMGRL> show database verbose ‘SBDB1‘; Database - SBDB1 Role: PHYSICAL STANDBY Intended State: APPLY-ON Transport Lag: 0 seconds (computed 1 second ago) Apply Lag: 0 seconds (computed 1 second ago) Apply Rate: 0 Byte/s Real Time Query: ON
Four DGMGRL adjustment parameters:
4.1 Adjusting Application Latency
DGMGRL> edit database ‘SBDB1‘ set property DelayMins=1 ;
This is actually the following command:
ALTER SYSTEM SET log_archive_dest_2=‘service="sbdb1"‘,‘LGWR ASYNC NOAFFIRM delay=1 optional compression=disable max_failure=0 max_connections=1 reopen=300 db_unique_name="SBDB1" net_timeout=30‘,‘valid_for=(all_logfiles,primary_role)‘ SCOPE=BOTH;ALTER SYSTEM SWITCH ALL LOGFILE start (db1)ALTER SYSTEM SWITCH ALL LOGFILE complete (db1)DGMGRL> edit database ‘SBDB1‘ set property LogXptMode=sync;
4.2 Adjusting Asynchronous Synchronous mode
DGMGRL> edit database ‘SBDB1‘ set property LogXptMode=sync;
The corresponding commands are as follows:
ALTER SYSTEM SET log_archive_dest_2=‘service="sbdb1"‘,‘LGWR SYNC AFFIRM delay=1 optional compression=disable max_failure=0 max_connections=1 reopen=300 db_unique_name="SBDB1" net_timeout=30‘,‘valid_for=(all_logfiles,primary_role)‘ SCOPE=BOTH;
Oracle 11g Dataguard DGMGRL