linux修改主机名后listener无法启动

时间:2022-12-04 08:35:24

为了安装oracle rac我必须修改linux的主机名,然后数据库监听死活都启不起来。

修改vi /etc/hosts

# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 xionglang.mycomputer localhost#文件的三列分别对应IP ,主机名 ,别名。这行一定不能改


在文件中删除其他的行并在文件最后添加一行 10.25.30.77             rac1 然后保存。

修改/etc/sysconfig/network文件

NETWORKING=yes
NETWORKING_IPV6=yes
HOSTNAME=xionglang


修改hostname 的值,改为rac1即可。

修改好主机名后需要重启主机使修改生效。

 我当时就这样,然后觉得数据库可以连接上就没有去管了。第二天,用监听连接时一直说没有监听。在服务器上查看lsnrctl报错。

[oracle@rac1 ~]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-SEP-2012 10:47:06

Copyright (c) 1991, 2007, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
[oracle@rac1 ~]$ lsnrctl start

想了下,除了改了linux主机名,oracle监听还没有改呢,所以改了下listener.ora文件

[oracle@rac1 admin]$ vi listener.ora

# listener.ora Network Configuration File: /opt/ora10g/product/10.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /opt/ora10g/product/10.2.0/db_1)
(PROGRAM = extproc)
)
)

LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = xionglang.mycomputer)(PORT = 1521))
)
)

将host的值改为修改后的主机名rac1。

然后还要修改本机的配置文件tnsnames.ora文件

# tnsnames.ora Network Configuration File: /opt/ora10g/product/10.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = xionglang.mycomputer)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)

EXTPROC_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
(CONNECT_DATA =
(SID = PLSExtProc)
(PRESENTATION = RO)
)
)

~

同样将host的值改为修改的主机名rac1.

[oracle@rac1 admin]$ hostname
rac1

 

只要保证hostname的结果,listener.ora中host的值相同,监听就可以启动起来。

[oracle@rac1 ~]$ lsnrctl start

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-SEP-2012 10:47:58

Copyright (c) 1991, 2007, Oracle. All rights reserved.

TNS-01106: Listener using listener name LISTENER has already been started
[oracle@rac1 ~]$ lsnrctl status

LSNRCTL for Linux: Version 10.2.0.4.0 - Production on 24-SEP-2012 10:48:05

Copyright (c) 1991, 2007, Oracle. All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=rac1)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.4.0 - Production
Start Date 24-SEP-2012 10:47:49
Uptime 0 days 0 hr. 0 min. 16 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /opt/ora10g/product/10.2.0/db_1/network/admin/listener.ora
Listener Log File /opt/ora10g/product/10.2.0/db_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=rac1)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully