修改hostname后导致oracle客户端无法连接怎么办
本篇内容介绍了“修改hostname后导致oracle客户端无法连接怎么办”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
虚拟机centos7中刚装了oracle11g,没重启前一切正常
重启后发现客户端无法连接到数据库了
SQL*Plus:Release11.2.0.1.0Productionon星期五11月1615:05:182018Copyright(c)1982,2010,Oracle.Allrightsreserved.请输入用户名:system@orcl输入口令:ERROR:ORA-12541:TNS:无监听程序
登陆服务器看一下监听状态
[root@lzr~]#lsnrctlstatusLSNRCTLforLinux:Version11.2.0.1.0-Productionon16-NOV-201815:07:55Copyright(c)1991,2009,Oracle.Allrightsreserved.Connectingto(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))STATUSoftheLISTENER------------------------AliasLISTENERVersionTNSLSNRforLinux:Version11.2.0.1.0-ProductionStartDate16-NOV-201815:00:14Uptime0days0hr.7min.45secTraceLeveloffSecurityON:LocalOSAuthenticationSNMPOFFListenerParameterFile/data/oracle/product/11.2.0/db_1/network/admin/listener.oraListenerLogFile/data/oracle/diag/tnslsnr/lzr/listener/alert/log.xmlListeningEndpointsSummary...(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=127.0.0.1)(PORT=1521)))ServicesSummary...Service"ORCL"has1instance(s).Instance"ORCL",statusUNKNOWN,has1handler(s)forthisservice...Thecommandcompletedsuccessfully
实例ORCL状态为UNKNOWN,有点不太懂了,百度了一下之后
解决办法
发现可能是hostname出现了问题
我在重启之前用命令
#hostnamectlset-hostnamelzr
修改过hostname
先打开/etc/hosts检查一下
[root@lzr~]#vi/etc/hosts127.0.0.1localhostlocalhost.localdomainlocalhost4localhost4.localdomain4::1localhostlocalhost.localdomainlocalhost6localhost6.localdomain6
host文件解释
添加新的一行
[root@lzr~]#vi/etc/hosts127.0.0.1lzr127.0.0.1localhostlocalhost.localdomainlocalhost4localhost4.localdomain4::1localhostlocalhost.localdomainlocalhost6localhost6.localdomain6
然后wq保存退出
现在我将数据库重启
[root@lzr~]#sqlplusSQL*Plus:Release11.2.0.1.0ProductiononFriNov1615:25:522018Copyright(c)1982,2009,Oracle.Allrightsreserved.Enteruser-name:sysassysdbaEnterpassword:Connectedto:OracleDatabase11gEnterpriseEditionRelease11.2.0.1.0-64bitProductionWiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptionsSQL>shutdownimmediateDatabaseclosed.Databasedismounted.ORACLEinstanceshutdown.SQL>startupORACLEinstancestarted.TotalSystemGlobalArea1185853440bytesFixedSize2212776bytesVariableSize738200664bytesDatabaseBuffers436207616bytesRedoBuffers9232384bytesDatabasemounted.Databaseopened.
再将监听重启,查看状态
[root@lzr~]#lsnrctlLSNRCTLforLinux:Version11.2.0.1.0-Productionon16-NOV-201815:31:17Copyright(c)1991,2009,Oracle.Allrightsreserved.WelcometoLSNRCTL,type"help"forinformation.LSNRCTL>stopConnectingto(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))ThecommandcompletedsuccessfullyLSNRCTL>startStarting/data/oracle/product/11.2.0/db_1/bin/tnslsnr:pleasewait...TNSLSNRforLinux:Version11.2.0.1.0-ProductionSystemparameterfileis/data/oracle/product/11.2.0/db_1/network/admin/listener.oraLogmessageswrittento/data/oracle/diag/tnslsnr/lzr/listener/alert/log.xmlListeningon:(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lzr)(PORT=1521)))Connectingto(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))STATUSoftheLISTENER------------------------AliasLISTENERVersionTNSLSNRforLinux:Version11.2.0.1.0-ProductionStartDate16-NOV-201815:31:21Uptime0days0hr.0min.5secTraceLeveloffSecurityON:LocalOSAuthenticationSNMPOFFListenerParameterFile/data/oracle/product/11.2.0/db_1/network/admin/listener.oraListenerLogFile/data/oracle/diag/tnslsnr/lzr/listener/alert/log.xmlListeningEndpointsSummary...(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lzr)(PORT=1521)))ServicesSummary...Service"ORCL"has1instance(s).Instance"ORCL",statusUNKNOWN,has1handler(s)forthisservice...ThecommandcompletedsuccessfullyLSNRCTL>statusConnectingto(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))STATUSoftheLISTENER------------------------AliasLISTENERVersionTNSLSNRforLinux:Version11.2.0.1.0-ProductionStartDate16-NOV-201815:31:21Uptime0days0hr.0min.8secTraceLeveloffSecurityON:LocalOSAuthenticationSNMPOFFListenerParameterFile/data/oracle/product/11.2.0/db_1/network/admin/listener.oraListenerLogFile/data/oracle/diag/tnslsnr/lzr/listener/alert/log.xmlListeningEndpointsSummary...(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lzr)(PORT=1521)))ServicesSummary...Service"ORCL"has1instance(s).Instance"ORCL",statusUNKNOWN,has1handler(s)forthisservice...Thecommandcompletedsuccessfully
好像和之前没有什么变化
去数据库中注册一下监听
[root@lzr~]#sqlplusSQL*Plus:Release11.2.0.1.0ProductiononFriNov1615:32:542018Copyright(c)1982,2009,Oracle.Allrightsreserved.Enteruser-name:sysassysdbaEnterpassword:Connectedto:OracleDatabase11gEnterpriseEditionRelease11.2.0.1.0-64bitProductionWiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptionsSQL>altersystemregister2;Systemaltered.
再出来查看一下监听状态
[root@lzr~]#lsnrctlLSNRCTLforLinux:Version11.2.0.1.0-Productionon16-NOV-201815:33:35Copyright(c)1991,2009,Oracle.Allrightsreserved.WelcometoLSNRCTL,type"help"forinformation.LSNRCTL>statusConnectingto(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))STATUSoftheLISTENER------------------------AliasLISTENERVersionTNSLSNRforLinux:Version11.2.0.1.0-ProductionStartDate16-NOV-201815:31:21Uptime0days0hr.2min.15secTraceLeveloffSecurityON:LocalOSAuthenticationSNMPOFFListenerParameterFile/data/oracle/product/11.2.0/db_1/network/admin/listener.oraListenerLogFile/data/oracle/diag/tnslsnr/lzr/listener/alert/log.xmlListeningEndpointsSummary...(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lzr)(PORT=1521)))ServicesSummary...Service"ORCL"has2instance(s).Instance"ORCL",statusUNKNOWN,has1handler(s)forthisservice...Instance"orcl",statusREADY,has1handler(s)forthisservice...Service"orclXDB"has1instance(s).Instance"orcl",statusREADY,has1handler(s)forthisservice...Thecommandcompletedsuccessfully
看上去正常了,status ready
现在回到客户端中测试一下连接
C:\Users\lzr>sqlplusSQL*Plus:Release11.2.0.1.0Productionon星期五11月1615:34:102018Copyright(c)1982,2010,Oracle.Allrightsreserved.请输入用户名:system@orcl输入口令:连接到:OracleDatabase11gEnterpriseEditionRelease11.2.0.1.0-64bitProductionWiththePartitioning,OLAP,DataMiningandRealApplicationTestingoptionsSQL>showuserUSER为"SYSTEM"
可以正常使用客户端连接了
“修改hostname后导致oracle客户端无法连接怎么办”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!
声明:本站所有文章资源内容,如无特殊说明或标注,均为采集网络资源。如若本站内容侵犯了原著者的合法权益,可联系本站删除。