我们在安装ORACLE RAC的时候,很多时候没有选择安装EM,或是RAC运行一段时间后,EM失效!为了方便对数据库进行监控,这个时候我们需要手动部署Oracle RAC EM,然而在部署过程中,经常会报错:

WARNING: Error during db connection : ORA-12514
或是:
OracleRAC version:11.2.0.2.7
手动执行部署RAC EM,抛出
WARNING:Error during db connection : ORA-12514: TNS:listener does not currently know ofservice requested in connect descriptor错误。

以下是部署的过程,oracle用户执行如下命令:

$emca -config dbcontrol db -repos create -cluster
Enter thefollowing information:
Databaseunique name: racdb
Servicename: racdb
Listenerport number: 1521
ListenerORACLE_HOME [ /u01/11.2.0/grid ]:
Password forSYS user:
Password forDBSNMP user:
Password forSYSMAN user:
Clustername: racdb-cluster
Emailaddress for notifications (optional):
OutgoingMail (SMTP) server for notifications (optional):
ASMORACLE_HOME [ /u01/11.2.0/grid ]:
ASM port [1521 ]:
ASM username[ ASMSNMP ]:
ASM userpassword:
WARNING:Error during db connection : ORA-12514: TNS:listener does not currently know of service requested in connect descriptor

在这个版本内,相比 11.2.0.1的rac好像改动了一些,不会依赖tnsnames.ora了。
在11.2.0.1的版本内,Listener ORACLE_HOME [/u01/11.2.0/grid ]: 这里默认的话,会抛出

Invalid username/password or database/scan listener not up ordatabase service is not registered with scan listener错误,

原因是:因为grid用户的ORACLE_HOME/network/admin下并无tnsnames.ora文件,需要修改为oracle用户的ORACLE_HOME,或者tnsnames.ora拷贝至grid用户的ORACLE HOME/network/admin下并无tnsnames.ora文件,需要修改为oracle用户的ORACLE HOME,或者tnsnames.ora拷贝至grid用户的ORACLE_HOME/network/admin下。

以上错误正文:
1.默认ASM实例只注册本地监听,而非scan监听

SQL> show parameter listener
NAME TYPE VALUE
----------------------------------------------- ------------------------------
local_listener string (DESCRIPTION=(ADDRESS_LIST=(AD
DRESS=(PROTOCOL=TCP)(HOST=192.
168.3.121)(PORT=1521))))
remote_listener string
SQL> show parameter listener

NAME                                 TYPE        VALUE

----------------------------------------------- ------------------------------

local_listener                       string      (DESCRIPTION=(ADDRESS_LIST=(AD

                                                  DRESS=(PROTOCOL=TCP)(HOST=192.

                                                  168.3.121)(PORT=1521))))

remote_listener                      string

2.EM默认配置的时候会去找scan监听

ListeningEndpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.3.131)(PORT=1521)))
ServicesSummary...
Service"racdb" has 2 instance(s).
Instance "racdb1", status READY,has 1 handler(s) for this service...
Instance "racdb2", status READY,has 1 handler(s) for this service...
Service"racdbXDB" has 2 instance(s).
Instance "racdb1", status READY,has 1 handler(s) for this service...
Instance "racdb2", status READY,has 1 handler(s) for this service...
The commandcompleted successfully

SCAN监听并无ASM实例注册信息
3.向SCAN监听注册asm实例
SQL>alter system set remote_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.3.131)(PORT=1521))))' scope=both sid='+ASM1';
Systemaltered.
SQL>alter system set remote_listener='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.3.131)(PORT=1521))))' scope=both SID='+ASM2';
Systemaltered.
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
ListeningEndpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER_SCAN1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.3.131)(PORT=1521)))
ServicesSummary...
Service"+ASM" has 2 instance(s).
Instance "+ASM1", status READY, has1 handler(s) for this service...
Instance "+ASM2", status READY, has1 handler(s) for this service...
Service"racdb" has 2 instance(s).
Instance "racdb1", status READY,has 1 handler(s) for this service...
Instance "racdb2", status READY,has 1 handler(s) for this service...
Service"racdbXDB" has 2 instance(s).
Instance "racdb1", status READY,has 1 handler(s) for this service...
Instance "racdb2", status READY,has 1 handler(s) for this service...
The commandcompleted successfully
已动态注册。

4.再次执行部署

$emca -configdbcontrol db -repos create -cluster
Enter thefollowing information:
Databaseunique name: racdb
Servicename: racdb
Listenerport number: 1521
ListenerORACLE_HOME [ /u01/11.2.0/grid ]:
Password forSYS user:
Password forDBSNMP user:
Password forSYSMAN user:
Clustername: racdb-cluster
Emailaddress for notifications (optional):
OutgoingMail (SMTP) server for notifications (optional):
ASMORACLE_HOME [ /u01/11.2.0/grid ]:
ASM port [1521 ]:
ASM username[ ASMSNMP ]:
ASM userpassword:
-----------------------------------------------------------------
You havespecified the following settings
DatabaseORACLE_HOME ................ /u01/app/oracle/product/11.2.0/db_1
Databaseinstance hostname ................ Listener ORACLE_HOME ................/u01/11.2.0/grid
Listenerport number ................ 1521
Cluster name................ racdb-cluster
Databaseunique name ................ racdb
Emailaddress for notifications ...............
OutgoingMail (SMTP) server for notifications ...............
ASMORACLE_HOME ................ /u01/11.2.0/grid
ASM port................ 1521
ASM userrole ................ SYSDBA
ASM username................ ASMSNMP
-----------------------------------------------------------------
Do you wishto continue? [yes(Y)/no(N)]: Y
………..
………..
***********************************************************
Enterprise Manager configuration completed successfully

执行部署EM
5.忘记ASMSNMP密码?
进入ASM实例修改

SQL> alter user asmsnmp identified by oracle123;
SQL> alter user asmsnmp identified by oracle123;

修改完后,会自动同步其他节点的ASM密码文件。