本篇内容介绍了“修改hostname后导致oracle客户端无法连接怎么办”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
虚拟机centos7中刚装了oracle11g,没重启前一切正常
重启后发现客户端无法连接到数据库了
SQL*Plus: Release 11.2.0.1.0 Production on 星期五 11月 16 15:05:18 2018 Copyright (c) 1982, 2010, Oracle. All rights reserved. 请输入用户名: system@orcl 输入口令: ERROR: ORA-12541: TNS: 无监听程序登陆服务器看一下监听状态
[root@lzr ~]# lsnrctl status LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 16-NOV-2018 15:07:55 Copyright (c) 1991, 2009, Oracle. All rights reserved. Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))) STATUS of the LISTENER ------------------------ Alias LISTENER Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production Start Date 16-NOV-2018 15:00:14 Uptime 0 days 0 hr. 7 min. 45 sec Trace Level off Security ON: Local OS Authentication SNMP OFF Listener Parameter File /data/oracle/product/11.2.0/db_1/network/admin/listener.ora Listener Log File /data/oracle/diag/tnslsnr/lzr/listener/alert/log.xml Listening Endpoints Summary... (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521))) Services Summary... Service "ORCL" has 1 instance(s). Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service... The command completed successfully实例ORCL状态为UNKNOWN,有点不太懂了,百度了一下之后
解决办法
发现可能是hostname出现了问题
我在重启之前用命令
#hostnamectl set-hostname lzr修改过hostname
先打开/etc/hosts检查一下
[root@lzr ~]# vi /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6host文件解释
添加新的一行
[root@lzr ~]# vi /etc/hosts 127.0.0.1 lzr 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6然后wq保存退出
现在我将数据库重启
[root@lzr ~]# sqlplus SQL*Plus: Release 11.2.0.1.0 Production on Fri Nov 16 15:25:52 2018 Copyright (c) 1982, 2009, Oracle. All rights reserved. Enter user-name: sys as sysdba Enter password: Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. SQL> startup ORACLE instance started. Total System Global Area 1185853440 bytes Fixed Size 2212776 bytes Variable Size 738200664 bytes Database Buffers 436207616 bytes Redo Buffers 9232384 bytes Database mounted. Database opened.郑重声明:本文版权归原作者所有,转载文章仅为传播更多信息之目的,如作者信息标记有误,请第一时间联系我们修改或删除,多谢。