oracle 侦听器侦听错误的主机(本地主机)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11181586/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Listerner listening on wrong host (localhost)
提问by Bruno
I created a listener (using netca) called listener.
我创建了一个名为 listener 的侦听器(使用 netca)。
When I start the listener (using lsnrctl start) I have the following log.
当我启动侦听器(使用 lsnrctl start)时,我有以下日志。
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 24-JUN-2012 17:56:35 Copyright (c) 1991, 2009, Oracle. All rights reserved. Starting /opt/oracle/eesrv/11.2.0/db1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 11.2.0.1.0 - Production System parameter file is /opt/oracle/network/listener.ora Log messages written to /opt/oracle/diag/tnslsnr/sakura/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=sakura)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 24-JUN-2012 17:56:35 Uptime 0 days 0 hr. 0 min. 10 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /opt/oracle/network/listener.ora Listener Log File /opt/oracle/diag/tnslsnr/sakura/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) The listener supports no services The command completed successfully
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 24-JUN-2012 17:56:35 Copyright (c) 1991, 2009, Oracle. All rights reserved. Starting /opt/oracle/eesrv/11.2.0/db1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 11.2.0.1.0 - Production System parameter file is /opt/oracle/network/listener.ora Log messages written to /opt/oracle/diag/tnslsnr/sakura/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=sakura)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 24-JUN-2012 17:56:35 Uptime 0 days 0 hr. 0 min. 10 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /opt/oracle/network/listener.ora Listener Log File /opt/oracle/diag/tnslsnr/sakura/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost.localdomain)(PORT=1521))) The listener supports no services The command completed successfully
Q. Why is the listener listening on localhost and not on sakura ?!?
问:为什么侦听器在 localhost 而不是在 sakura 上收听?!?
Here is my listener.ora file (where I clearly specify to use sakura):
这是我的 listener.ora 文件(我在其中明确指定使用 sakura):
TRACE_DIRECTORY_PROD = /var/opt/oracle/otk/1.0/log/network/trace
SUBSCRIBE_FOR_NODE_DOWN_EVENT_PROD = OFF
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = sakura)(PORT = 1521)) ) )
ADR_BASE_LISTENER = /opt/oracle
LOG_DIRECTORY_PROD = /var/opt/oracle/otk/1.0/log/network
TRACE_DIRECTORY_PROD = /var/opt/oracle/otk/1.0/log/network/trace
SUBSCRIBE_FOR_NODE_DOWN_EVENT_PROD = 关闭
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = sakura)(PORT = 1521))) )
ADR_BASE_LISTENER = /opt/oracle
LOG_DIRECTORY_PROD = /var/opt/oracle/otk/1.0/log/network
Why did I do wrong ?
为什么我做错了?
Thanks
谢谢
回答by Alex Poole
Expanded from comment
从评论展开
It appears that sakurais resolving to the same address as localhost.localdomain, i.e. 127.0.0.1. This suggests that there is an entry in the /etc/hoststhat is mapping sakurato 127.0.0.1.
似乎sakura正在解析到与 相同的地址localhost.localdomain,即127.0.0.1。这表明 中有一个条目/etc/hosts映射sakura到127.0.0.1。
You can either:
您可以:
- remove that mapping;
- change it to show an external IP address, if it doesn't resolve to one automatically;
- change your
listener.orato use a fully-qualified domain name if you have one that resolves to the external IP, e.g.sakura.example.com; - or change your
listener.orato use the external IP address directly with no lookup.
- 删除该映射;
- 如果它没有自动解析为一个,请将其更改为显示一个外部 IP 地址;
listener.ora如果您有一个解析为外部 IP 的域名,请更改为使用完全限定的域名,例如sakura.example.com;- 或更改
listener.ora为直接使用外部 IP 地址而无需查找。
The last option might be the simplest, unless you have a DHCP-assigned IP address; and os what @dseibert suggested.
最后一个选项可能是最简单的,除非您有一个 DHCP 分配的 IP 地址;以及@dseibert 建议的内容。
回答by RodH
If you change your hostname: {newHostName}
如果您更改主机名:{newHostName}
Step 1. Check environment vars:
步骤 1. 检查环境变量:
> export ORACLE_HOSTNAME={newHostName}
> export ORACLE_UNQNAME=ORCL
> export ORACLE_BASE=/oracle
> export ORACLE_HOME=$ORACLE_BASE/product/12.1.0/db_1
> export ORACLE_SID=ORCL
Step 2. Find in oracle installation dir (e.g. /oracle ) about "oldHostName" (e.g oracle_12C.localdomain) to view your hostname:
步骤2.在oracle安装目录(例如/oracle)中找到“oldHostName”(例如oracle_12C.localdomain)以查看您的主机名:
hostname grep -r "oracle_12C" /oracle
主机名 grep -r "oracle_12C" /oracle
In my case I found these files to change it manually "oracle_12C.localdomain" with new "newHostName":
就我而言,我发现这些文件使用新的“newHostName”手动更改“oracle_12C.localdomain”:
File 1) /oracle/product/12.1.0/db_1/install/chainedInstall/globalcontext.xml
File 2) /oracle/product/12.1.0/db_1/inventory/Components21/oracle.rdbms.scheduler/12.2.0.1.0/context.xml
File 3) /oracle/product/12.1.0/db_1/inventory/Components21/oracle.ldap.client/12.2.0.1.0/context.xml
File 4) /oracle/product/12.1.0/db_1/inventory/Components21/oracle.server/12.2.0.1.0/context.xml
File 5) /oracle/product/12.1.0/db_1/inventoy/Clone/clone.xml
Step 3. Start instance: Go to sqlplus:
步骤 3. 启动实例:转到 sqlplus:
cd $ORACLE_HOME/bin sqlplus / AS SYSDBA SQL> STARTUP
cd $ORACLE_HOME/bin sqlplus / AS SYSDBA SQL> STARTUP
Step 4. start listener {SID} e.g.:
步骤 4. 启动监听器 {SID} 例如:
cd $ORACLE_HOME/bin lsnrctl start ORCL
cd $ORACLE_HOME/bin lsnrctl 启动 ORCL
Step 5. Check result in console ... Service "ORCL" has 1 instance(s). ...
步骤 5. 检查控制台中的结果...服务“ORCL”有 1 个实例。...

