本篇內(nèi)容介紹了“修改hostname后導致oracle客戶端無法連接怎么辦”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!
創(chuàng)新互聯(lián)公司專注于蚌山企業(yè)網(wǎng)站建設,自適應網(wǎng)站建設,商城網(wǎng)站建設。蚌山網(wǎng)站建設公司,為蚌山等地區(qū)提供建站服務。全流程按需規(guī)劃網(wǎng)站,專業(yè)設計,全程項目跟蹤,創(chuàng)新互聯(lián)公司專業(yè)和態(tài)度為您提供的服務虛擬機centos7中剛裝了oracle11g,沒重啟前一切正常
重啟后發(fā)現(xiàn)客戶端無法連接到數(shù)據(jù)庫了
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: 無監(jiān)聽程序
登陸服務器看一下監(jiān)聽狀態(tài)
[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狀態(tài)為UNKNOWN,有點不太懂了,百度了一下之后
解決辦法
發(fā)現(xiàn)可能是hostname出現(xiàn)了問題
我在重啟之前用命令
#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.localdomain6
host文件解釋
添加新的一行
[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保存退出
現(xiàn)在我將數(shù)據(jù)庫重啟
[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.
再將監(jiān)聽重啟,查看狀態(tài)
[root@lzr ~]# lsnrctl LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 16-NOV-2018 15:31:17 Copyright (c) 1991, 2009, Oracle. All rights reserved. Welcome to LSNRCTL, type "help" for information. LSNRCTL> stop Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521))) The command completed successfully LSNRCTL> start Starting /data/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait... TNSLSNR for Linux: Version 11.2.0.1.0 - Production System parameter file is /data/oracle/product/11.2.0/db_1/network/admin/listener.ora Log messages written to /data/oracle/diag/tnslsnr/lzr/listener/alert/log.xml Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=lzr)(PORT=1521))) 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:31:21 Uptime 0 days 0 hr. 0 min. 5 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=lzr)(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 LSNRCTL> status 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:31:21 Uptime 0 days 0 hr. 0 min. 8 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=lzr)(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
好像和之前沒有什么變化
去數(shù)據(jù)庫中注冊一下監(jiān)聽
[root@lzr ~]# sqlplus SQL*Plus: Release 11.2.0.1.0 Production on Fri Nov 16 15:32:54 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> alter system register 2 ; System altered.
再出來查看一下監(jiān)聽狀態(tài)
[root@lzr ~]# lsnrctl LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 16-NOV-2018 15:33:35 Copyright (c) 1991, 2009, Oracle. All rights reserved. Welcome to LSNRCTL, type "help" for information. LSNRCTL> status 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:31:21 Uptime 0 days 0 hr. 2 min. 15 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=lzr)(PORT=1521))) Services Summary... Service "ORCL" has 2 instance(s). Instance "ORCL", status UNKNOWN, has 1 handler(s) for this service... Instance "orcl", status READY, has 1 handler(s) for this service... Service "orclXDB" has 1 instance(s). Instance "orcl", status READY, has 1 handler(s) for this service... The command completed successfully
看上去正常了,status ready
現(xiàn)在回到客戶端中測試一下連接
C:\Users\lzr>sqlplus SQL*Plus: Release 11.2.0.1.0 Production on 星期五 11月 16 15:34:10 2018 Copyright (c) 1982, 2010, Oracle. All rights reserved. 請輸入用戶名: system@orcl 輸入口令: 連接到: 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> show user USER 為 "SYSTEM"
可以正常使用客戶端連接了
“修改hostname后導致oracle客戶端無法連接怎么辦”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關的知識可以關注創(chuàng)新互聯(lián)-成都網(wǎng)站建設公司網(wǎng)站,小編將為大家輸出更多高質量的實用文章!