[20140420]使用dgmgrl管理dataguard(8).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/
http://blog.itpub.net/267265/viewspace-1143480/
http://blog.itpub.net/267265/viewspace-1144742/
http://blog.itpub.net/267265/viewspace-1145573/
-- 我的测试环境:primary的tnsnames别名test,standby主机的tnsnames别名testdg。数据库版本:
$ rldgmgrl
DGMGRL for Linux: Version 11.2.0.3.0 - 64bit Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected.
DGMGRL> switchover to testdg;
Performing switchover NOW, please wait...
New primary database "testdg" is opening...
Operation requires shutdown of instance "test" on database "test"
Shutting down instance "test"...
ORA-24327: need explicit attach before authenticating a user
Warning: You are no longer connected to ORACLE.
Please complete the following steps to finish switchover:
shut down instance "test" of database "test"
start up instance "test" of database "test"
--更正上个星期测试的问题.
$ oerr ora 24327
24327, 00000, "need explicit attach before authenticating a user"
// *Cause: A server context must be initialized before creating a session.
// *Action: Create and initialize a server handle.
实际上只要connect 连接数据库,在执行切换就没有问题,不管是连test还是testdg.好像是不支持这样外部认证(再切换时).
另外注意的问题,就是切换的主库并没有打开force logging功能,切记切换后要打开这个功能.或者先打开它.
SYS@testdg> select database_role,open_mode,protection_mode from v$database;
DATABASE_ROLE OPEN_MODE PROTECTION_MODE
---------------- -------------------- --------------------
PRIMARY READ WRITE MAXIMUM PERFORMANCE
SYS@testdg> select name,force_logging from v$database;
NAME FOR
-------------------- ---
TEST NO
--可以发现testdg并没有打开force_logging.必须执行alter database force logging;
--有点乱,重新测试看看:
$ alias rldgmgrl
alias rldgmgrl='/usr/local/bin/rlwrap -s 9999 -r -i -f /home/oracle11g/dgmgrl.txt dgmgrl /@test'
$ rldgmgrl
DGMGRL for Linux: Version 11.2.0.3.0 - 64bit Production
Copyright (c) 2000, 2009, Oracle. All rights reserved.
Welcome to DGMGRL, type "help" for information.
Connected.
DGMGRL> show configuration
Configuration - study
Protection Mode: MaxPerformance
Databases:
testdg - Primary database
test - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
DGMGRL> connect sys/btbtms@testdg
Connected.
DGMGRL> switchover to test;
Performing switchover NOW, please wait...
New primary database "test" is opening...
Operation requires shutdown of instance "testdg" on database "testdg"
Shutting down instance "testdg"...
ORACLE instance shut down.
Operation requires startup of instance "testdg" on database "testdg"
Starting instance "testdg"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "test"
DGMGRL> show configuration
Configuration - study
Protection Mode: MaxPerformance
Databases:
test - Primary database
testdg - Physical standby database
Fast-Start Failover: DISABLED
Configuration Status:
SUCCESS
--可以发现并没有出现上面的ORA-24327错误.
SYS@testdg> select database_role,open_mode,protection_mode,force_logging from v$database;
DATABASE_ROLE OPEN_MODE PROTECTION_MODE FOR
---------------- -------------------- -------------------- ---
PHYSICAL STANDBY MOUNTED MAXIMUM PERFORMANCE NO
--可以发现testdg的force_logging=NO.
DGMGRL> switchover to testdg;
Performing switchover NOW, please wait...
New primary database "testdg" is opening...
Operation requires shutdown of instance "test" on database "test"
Shutting down instance "test"...
ORACLE instance shut down.
Operation requires startup of instance "test" on database "test"
Starting instance "test"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "testdg"
SYS@testdg> select database_role,open_mode,protection_mode,force_logging from v$database;
DATABASE_ROLE OPEN_MODE PROTECTION_MODE FOR
---------------- -------------------- -------------------- ---
PRIMARY READ WRITE MAXIMUM PERFORMANCE NO
--这样看来事先在安装好dg时就打开force logging.
alter database force logging;