环境:
os:rhel6.3_64bit
DB:Oracle10gR2
总是感觉对他越来越是朦胧,算是对搞了几天dataguard发一些感慨吧,下一步研究Oracle 11gdataguard的一些特征,期待着早些把dataguard从10g到12c弄明白跟大家一块分享,好了不多说了还是来研究下10gR2的dataguard的fast-start failover吧!
————————————————————broker配置保护级别————————————————————
protect-mode redo-transport standby-redo-log-files-needs used with fast-start failover
MAXPROTECTION SYNC Yes No
MAXAVAILABILITY SYNC Yes Yes
MAXPERFORMANC ASYNC/ARCH Yes for ASYNC No
配置 standby
DGMGRL> show database verbose 'ora'
Database
Name: ora
Role: PHYSICAL STANDBY
Enabled: YES
Intended State: ONLINE
Instance(s):
ora
Properties:
InitialConnectIdentifier = 'ora'
ObserverConnectIdentifier = ''
LogXptMode = 'ASYNC'
Dependency = ''
DelayMins = '0'
Binding = 'OPTIONAL'
MaxFailure = '0'
MaxConnections = '1'
ReopenSecs = '300'
NetTimeout = '180'
LogShipping = 'ON'
PreferredApplyInstance = ''
ApplyInstanceTimeout = '0'
ApplyParallel = 'AUTO'
StandbyFileManagement = 'auto'
ArchiveLagTarget = '0'
LogArchiveMaxProcesses = '3'
LogArchiveMinSucceedDest = '1'
DbFileNameConvert = '/opt/oracle/product/oradata/stdy, /opt/oracle/product/oradata/ora'
LogFileNameConvert = '/opt/oracle/product/oradata/stdy, /opt/oracle/product/oradata/ora'
FastStartFailoverTarget = ''
StatusReport = '(monitor)'
InconsistentProperties = '(monitor)'
InconsistentLogXptProps = '(monitor)'
SendQEntries = '(monitor)'
LogXptStatus = '(monitor)'
RecvQEntries = '(monitor)'
HostName = 'eagle'
SidName = 'ora'
LocalListenerAddress = '(ADDRESS=(PROTOCOL=TCP)(HOST=eagle)(PORT=15321))'
StandbyArchiveLocation = 'dgsby_ora'
AlternateLocation = ''
LogArchiveTrace = '0'
LogArchiveFormat = '%t_%s_%r.dbf'
LatestLog = '(monitor)'
TopWaitEvents = '(monitor)'
Current status for "ora":
SUCCESS
DGMGRL> edit database 'ora' SET PROPERTY 'LogXptMode'='SYNC';
Property "LogXptMode" updated
DGMGRL> EDIT CONFIGURATION SET PROTECTION MODE AS MAXAVAILABILITY;
Succeeded.
检查保护级别
DATABASE_ROLE INSTANCE OPEN_MODE PROTECTION_MODE PROTECTION_LEVEL SWITCHOVER_STATUS
---------------- ------------------------------ ---------- -------------------- -------------------- --------------------
PHYSICAL STANDBY ora MOUNTED MAXIMUM AVAILABILITY MAXIMUM AVAILABILITY SESSIONS ACTIVE
检查数据库配置是否有错误
DGMGRL> show database 'ora' 'statusreport'
STATUS REPORT
INSTANCE_NAME SEVERITY ERROR_TEXT
查看日志模式
DGMGRL> show database 'ora' 'LogXptMode'
LogXptMode = 'SYNC'
————————————————————配置 fast-start failover————————————————————————
dataguard的保护模式为MaxAvailability
启动闪回数据库
主库备库LogXptMode='SYNC';
备库闪回
SQL> select FLASHBACK_ON from v$database;
FLASHBACK_ON
------------------
NO
SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-38706: Cannot turn on FLASHBACK DATABASE logging.
ORA-38709: Recovery Area is not enabled.
SQL> alter system set db_recovery_file_dest_size=2g scope=both;
System altered.
SQL> alter system set db_recovery_file_dest='/opt/oracle/ora_arch' scope=both;
System altered.
SQL> alter database flashback on;
alter database flashback on
*
ERROR at line 1:
ORA-01153: an incompatible media recovery is active
SQL> select process,pid,status,client_process from v$managed_standby;
PROCESS STATUS THREAD# SEQUENCE# BLOCK# BLOCKS
--------- ------------ ---------- ---------- ---------- ----------
ARCH CLOSING 1 23 1 436
ARCH CLOSING 1 22 1 20
ARCH CLOSING 1 21 8193 98
RFS IDLE 0 0 0 0
RFS IDLE 0 0 0 0
MRP0 APPLYING_LOG 1 24 81 102400
RFS IDLE 1 24 82 1
14 rows selected.
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> SQL> alter database flashback on;
Database altered.
SQL> select FLASHBACK_ON from v$database;
FLASHBACK_ON
------------------
YES
SQL> alter database recover managed standby database disconnect from session;
Database altered
主库闪回
SQL> select FLASHBACK_ON from v$database;
FLASHBACK_ON
------------------
NO
SQL> alter system set db_recovery_file_dest_size=2g scope=both;
System altered.
SQL> show parameter recover
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest string
db_recovery_file_dest_size big integer 2G
recovery_parallelism integer 0
SQL> alter system set db_recovery_file_dest='/opt/oracle/stdy_arch' scope=both;
System altered.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 213909504 bytes
Fixed Size 2095152 bytes
Variable Size 92276688 bytes
Database Buffers 113246208 bytes
Redo Buffers 6291456 bytes
Database mounted.
SQL> alter database flashback on;
Database altered.
SQL> ALTER database open;
ALTER database open
*
ERROR at line 1:
ORA-01531: a database already open by the instance
SQL> select instance_name,status from v$instance;
INSTANCE_NAME STATUS
---------------- ------------
stdy OPEN
DGMGRL> edit database 'ora' set property faststartfailovertarget='stdy';
Property "faststartfailovertarget" updated
DGMGRL> edit database 'stdy' set property faststartfailovertarget='ora';
Property "faststartfailovertarget" updated
DGMGRL> EDIT CONFIGURATION SET PROPERTY FastStartFailoverThreshold = 45
> ;
Property "faststartfailoverthreshold" updated
DGMGRL> ENABLE FAST_START FAILOVER;
DGMGRL> show database 'ora' 'LogXptMode';
LogXptMode = 'sync'
DGMGRL> show database 'stdy' 'logxptmode';
LogXptMode = 'sync'
DGMGRL> show configuration verbose
Configuration
Name: dg_config
Enabled: YES
Protection Mode: MaxAvailability
Fast-Start Failover: DISABLED
Databases:
ora - Physical standby database
stdy - Primary database
Current status for "dg_config":
SUCCESS
DGMGRL> show configuration verbose
Configuration
Name: dg_config
Enabled: YES
Protection Mode: MaxAvailability
Fast-Start Failover: ENABLED
Databases:
ora - Physical standby database
- Fast-Start Failover target
stdy - Primary database
Fast-Start Failover
Threshold: 45 seconds
Observer: eagle
Shutdown Primary: TRUE
Current status for "dg_config":
SUCCESS
DGMGRL> start OBSERVER;
Observer started
启动后会一直监控整个dataguard的状态,可以通过任何一个client连上执行stop OBSERVER后停止监控。
日志在alert日志一级目录下面的droracle_sid.log
[show fast_start failover]
查看归档终点是否有异常:
col dest_name for a30
col error for a20
select dest_name,status,target,archiver,error,process from v$archive_dest;
启动broker:
DGMGRL> connect sys/oracle@ora
创建中介配置:
DGMGRL> create configuration 'testBroker' as primary database is 'ora' connect identifier is 78;
在中介配置中添加备用数据库:
DGMGRL> add database 'aux1' as connect identifier is 250 maintained as physical;
查看broker配置状态:
DGMGRL> show configuration verbose;
查看主从数据库的配置:
DGMGRL> show database verbose 数据库唯一名;
DGMGRL> show database verbose 数据库唯一名;
确认主从数据库属性为LogXptMode='sync' :
DGMGRL> edit database ora set property LogXptMode = 'sync';
启动broker配置:
DGMGRL> enable configuration;
修改快速故障转移的延迟时间(默认为30秒,有些少!):
DGMGRL> edit configuration set property FastStartFailoverThreshold=120;
启动快速故障转移:
DGMGRL> ENABLE FAST_START FAILOVER;
启动Observer监视器:
DGMGRL> start observer;
启动之后,该前台进程不会退出,会一直挂在这。 直到从其他窗口关闭!
在新的窗口再启动一个dgmgrl,查看快速转移配置:
DGMGRL> show configuration verbose;
DGMGRL> show database verbose 数据库唯一名;
DGMGRL> show database verbose 数据库唯一名;
在数据库中查看快速转移状态:
ora@ SYS> col FS_FAILOVER_OBSERVER_HOST for a20
ora@ SYS> select fs_failover_observer_present,fs_failover_observer_host,fs_failover_threshold from v$database;
FS_FAIL FS_FAILOVER_OBSERVER FS_FAILOVER_THRESHOLD
------- -------------------- ---------------------
YES alvin 0
aux1@ SYS> col FS_FAILOVER_OBSERVER_HOST for a20
aux1@ SYS> select fs_failover_observer_present,fs_failover_observer_host,fs_failover_threshold from v$database;
FS_FAIL FS_FAILOVER_OBSERVER FS_FAILOVER_THRESHOLD
------- -------------------- ---------------------
YES alvin 45