用Broker搭建Oracle Data Guard的必須注意知識點
最近在用Broker 配置和管理Data Guard(Oracle version : 10.2.0.1.0),以前的資料庫都基本不設定db_domain的,當使用database link的時候,啟用了global_names=true,也設定了db_domain,所以以前都能成功順利的用Broker配置和管理Data Guard的設定,現在不行了,我指的不行,是指用broker做switchover的時候,主備庫的instances不自動的啟動,需要手動的去啟動。
當我用show configuration的時候,broker 也提示是successs的,如下所示:
DGMGRL> show configuration;
Configuration
Name: dgmgrl_1
Enabled: YES
Protection Mode: MaxPerformance
Fast-Start Failover: DISABLED
Databases:
prod - Physical standby database
sbdb - Primary database
Current status for "dgmgrl_1":
SUCCESS
但是當我switchover的時候,自動啟動instances失敗如下所示:
DGMGRL> switchover to PROD;
Performing switchover NOW, please wait...
Operation requires shutdown of instance "SBDB" on database "sbdb"
Shutting down instance "SBDB"...
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires shutdown of instance "PROD" on database "prod"
Shutting down instance "PROD"...
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "SBDB" on database "sbdb"
Starting instance "SBDB"...
ORACLE instance started.
Database mounted.
Operation requires startup of instance "PROD" on database "prod"
Starting instance "PROD"...
Unable to connect to database
ORA-12514: TNS:listener does not currently know of service requested in connect descriptor
Failed.
You are no longer connected to ORACLE
Please connect again.
Unable to start instance "PROD"
You must start instance "PROD" manually
Switchover succeeded, new primary is "prod"
從上面的錯誤提示可以看出,肯定是監聽配置的有問題,下面是我以前配置的listener.ora
listener.ora
LISTENER=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=vmoel5u4.oracle.com)(PORT=1521))
)
)
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=PROD_DGMGRL)
(ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
(SID_NAME=PROD)
)
(SID_DESC=
(GLOBAL_DBNAME=PROD)
(ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
(SID_NAME=PROD)
)
)
於是查了下資料庫的db_domain:
SQL> show parameter db_domain;
NAME TYPE VALUE
------------------------------------ -------------------------------- ------------------------------
db_domain string ORACLE.COM
發現db_domain是有指的,改成下面的格式就可以了
listener.ora
LISTENER=
(DESCRIPTION=
(ADDRESS_LIST=
(ADDRESS=(PROTOCOL=tcp)(HOST=vmoel5u4.oracle.com)(PORT=1521))
)
)
SID_LIST_LISTENER=
(SID_LIST=
(SID_DESC=
(GLOBAL_DBNAME=PROD_DGMGRL.ORACLE.COM)
---(大小寫敏感的case sensitive)
(ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
(SID_NAME=PROD)
)
(SID_DESC=
(GLOBAL_DBNAME=PROD)
(ORACLE_HOME=/u01/app/oracle/product/10.2.0/db_1)
(SID_NAME=PROD)
)
)
再次做switchover,這次自動啟動instances成功:
DGMGRL> switchover to PROD;
Performing switchover NOW, please wait...
Operation requires shutdown of instance "SBDB" on database "sbdb"
Shutting down instance "SBDB"...
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires shutdown of instance "PROD" on database "prod"
Shutting down instance "PROD"...
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
Operation requires startup of instance "SBDB" on database "sbdb"
Starting instance "SBDB"...
ORACLE instance started.
Database mounted.
Operation requires startup of instance "PROD" on database "prod"
Starting instance "PROD"...
ORACLE instance started.
Database mounted.
Switchover succeeded, new primary is "prod"
DGMGRL> show configuration;
Configuration
Name: dgmgrl_1
Enabled: YES
Protection Mode: MaxPerformance
Fast-Start Failover: DISABLED
Databases:
prod - Primary database
sbdb - Physical standby database
Current status for "dgmgrl_1":
SUCCESS
Oralce教程上是這麼說的:
To enable the Data Guard broker CLI to restart instances during the course of broker operations,a service with a specific name must be statically registered with the local listener of each instance.The value of the GLOBAL_DBNAME attribute must be set to a concatenation of db_unique_name_DGMGRL.db_domain.