[20140416]使用dgmgrl管理dataguard(5).txt
参考链接:
http://blog.itpub.net/267265/viewspace-1142649/
http://blog.itpub.net/267265/viewspace-1143027/
http://blog.itpub.net/267265/viewspace-1143058/
http://blog.itpub.net/267265/viewspace-1143126/
前面我提到一旦使用dgmgrl,就一直使用它,除非禁用它。
你使用dgmgrl来管理,你必须一直使用它来管理dataguard,而不要使用sqlplus来修改相关参数,这样会出现一些参数不一致的问题。
我的测试环境:primary的tnsnames别名test,standby主机的tnsnames别名testdg。数据库版本:
SCOTT@test> @ver
BANNER
--------------------------------------------------------------------------------
Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
--但是有点意外的是执行edit database test set property RedoCompression='ENABLE';参数log_archive_dest_2并没有变化。
--依旧是SERVICE=testdg LGWR SYNC AFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=testdg。
--下午想了一下,才发现自己犯了一个低级错误。也许应该设置的是testdg.
DGMGRL> edit database testdg set property RedoCompression='enable';
Property "redocompression" updated
SYS@test> show parameter log_archive_dest_2
NAME TYPE VALUE
------------------- ------- ----------------------------------------------------------------------------------------------------
log_archive_dest_2 string service="testdg", LGWR SYNC AFFIRM delay=0 optional compression=enable max_failure=0 max_connections
=1 reopen=300 db_unique_name="testdg" net_timeout=30, valid_for=(all_logfiles,primary_role)
--可以发现这回生效了。缺省的参数全部出现。
--从这里再次说明,一旦使用dgmgrl管理,最好一直使用它,避免出现参数不一致的情况。
-- 另外我修改edit database test set property RedoCompression='ENABLE';应该在dataguard上的参数log_archive_dest_2会发生变化了。也许
-- 是还没有使用的原因吗?
--其他命令的学习:
1.暂停和启动dg应用:
DGMGRL> show database testdg
Database - testdg
Role: PHYSICAL STANDBY
Intended State: APPLY-ON
Transport Lag: 0 seconds
Apply Lag: 0 seconds
Real Time Query: ON
Instance(s):
testdg
Database Status:
SUCCESS
--暂停dg日志应用:
DGMGRL> edit database testdg set state="APPLY-OFF";
Succeeded.
DGMGRL> show database testdg
Database - testdg
Role: PHYSICAL STANDBY
Intended State: APPLY-OFF
Transport Lag: 0 seconds
Apply Lag: 6 seconds
Real Time Query: OFF
Instance(s):
testdg
Database Status:
SUCCESS
--启动dg日志应用:
DGMGRL> edit database testdg set state="APPLY-ON";
Succeeded.
2.设置dg数据库只读。
DGMGRL> edit database testdg set state='read-only';
Succeeded.
DGMGRL> show database testdg
Database - testdg
Role: PHYSICAL STANDBY
Intended State: READ-ONLY
Transport Lag: 0 seconds
Apply Lag: 36 seconds
Real Time Query: OFF
Instance(s):
testdg
Database Status:
SUCCESS
--再修改回来edit database testdg set state="APPLY-ON";
3.停止主库到从库的日志传送
DGMGRL> show database test
Database - test
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
test
Database Status:
SUCCESS
DGMGRL> edit database test set state='transport-off';
Succeeded.
DGMGRL> show database test
Database - test
Role: PRIMARY
Intended State: TRANSPORT-OFF
Instance(s):
test
Database Status:
SUCCESS
DGMGRL> edit database test set state='transport-on';
Succeeded.
DGMGRL> show database test
Database - test
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
test
Database Status:
SUCCESS
4.将主库离线:
DGMGRL> edit database test set state='offline';
Operation requires shutdown of instance "test" on database "test"
Shutting down instance "test"...
ORA-01031: insufficient privileges
Warning: You are no longer connected to ORACLE.
Please complete the following steps to finish the operation:
shut down instance "test" of database "test"
--好像现在并不能关闭数据库。也许要使用shutdown命令。我的测试这个命令无用。
--因为dg还在接收应用日志。即使使用如下命令看:
DGMGRL> show database test
Database - test
Role: PRIMARY
Intended State: OFFLINE
Instance(s):
test
Database Status:
SHUTDOWN
--但是我看到dg还在接收应用日志。
DGMGRL> help shutdown
Shuts down a currently running Oracle database instance
Syntax:
SHUTDOWN [NORMAL | IMMEDIATE | ABORT];
DGMGRL> edit database test set state='online';
Succeeded.
DGMGRL> show database test
Database - test
Role: PRIMARY
Intended State: TRANSPORT-ON
Instance(s):
test
Database Status:
SUCCESS
5.其他命令
--禁用配置
disable configuration
--禁用某个备用库
disable database 'test';
--从配置中删除备用库
remove database 'test'
--删除配置
remove configuration
--这些内容参考了http://blog.itpub.net/193161/viewspace-50176/。