情况是,直接设置监听器别名,Oracle是不认可的。
SQL> alter system set local_listener='my_listener' scope=both;
alter system set local_listener='my_listener' scope=both
*
ERROR at line 1:
ORA-02097: parameter cannot be modified because specified value is invalid
ORA-00119: invalid specification for system parameter LOCAL_LISTENER
ORA-00132: syntax error or unresolved network name 'my_listener'
Oracle不能解析my_listener名称,因为其既不是括号表达式,也不是设置的别名。这里面就比较奇怪,我们分明已经在listener.ora文件中定义了名称。
对00132错误,Oracle官方的解释如下:
[oracle@aaalife admin]$ oerr ora 00132
00132, 00000, "syntax error or unresolved network name '%s'"
// *Cause:? Listener address has syntax error or cannot be resolved.
// *Action: If a network name is specified, check that it corresponds
//? ? ? ? ? to an entry in TNSNAMES.ORA or other address repository
//? ? ? ? ? as configured for your system. Make sure that the entry
//? ? ? ? ? is syntactically correct.
Oracle认为在服务器端的tnsnames.ora文件中,没有能够找到my_listener的对应名称。Tnsnames.ora是我们保存本地连接对应名称的地方,这里是否意味着说此处的别名,是一定在tnsnames.ora文件中进行定义。本地命名别名定义我们是熟悉的。监听器程序别名如何定义?
经过查询Oracle早期文档和治疗,从一个角落找到定义格式和方法。
[oracle@aaalife admin]$ cat tnsnames.ora# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
MY_LISTENER=
(description=
(address=(protocol=tcp)(host=AAALIFE)(port=1531)))
突发奇想,tnsping命令有解析格式的副作用。是否可以成功呢?
[oracle@aaalife admin]$ tnsping my_listener
TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 07-SEP-2015 20:43:58
Copyright (c) 1997, 2013, Oracle.? All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (description= (address=(protocol=tcp)(host=AAALIFE)(port=1531)))
OK (0 msec)
解析成功,起码格式上没有大的问题。
SQL> alter system set local_listener='MY_LISTENER' scope=both;
System altered.
SQL> show parameter local;
NAME? ? ? ? ? ? ? ? ? ? ? ? ? ? ? ? TYPE? ? ? ? VALUE
------------------------------------ ----------- ------------------------------
local_listener? ? ? ? ? ? ? ? ? ? ? string? ? ? MY_LISTENER
log_archive_local_first? ? ? ? ? ? ? boolean? ? TRUE
parallel_force_local? ? ? ? ? ? ? ? boolean? ? FALSE
启动手工注册,查看监听器状态。
SQL> alter system register;
System altered.
[oracle@aaalife admin]$ lsnrctl status my_listener
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 07-SEP-2015 20:50:47
Copyright (c) 1991, 2013, Oracle.? All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1531)))
STATUS of the LISTENER
------------------------
Alias? ? ? ? ? ? ? ? ? ? my_listener
Version? ? ? ? ? ? ? ? ? TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date? ? ? ? ? ? ? ? 07-SEP-2015 19:48:50
Uptime? ? ? ? ? ? ? ? ? ? 0 days 1 hr. 1 min. 59 sec
Trace Level? ? ? ? ? ? ? off
Security? ? ? ? ? ? ? ? ? ON: Local OS Authentication
SNMP? ? ? ? ? ? ? ? ? ? ? OFF
Listener Parameter File? /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File? ? ? ? /u01/app/oracle/diag/tnslsnr/aaalife/my_listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1531)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1531)))
Services Summary...
Service "aaadb" has 1 instance(s).
Instance "aaadb", status READY, has 1 handler(s) for this service...
Service "aaadbXDB" has 1 instance(s).
Instance "aaadb", status READY, has 1 handler(s) for this service...
The command complet