天天看點

ORA-12514:TNS:listener does not currently know of service requested in connect descriptor

jdbc連接配接oracle報錯資訊:

oracle ORA-12514:TNS:listener does not currently know of service requested in connect descriptor
           
[[email protected] samples]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 28-OCT-2019 14:38:34

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

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS:operate timed out
...
...
...
           

發現監聽沒有啟動成功。

原因是我修改了虛拟機的ip位址,原先的虛拟機ip位址是192.168.100.100,後來更改為192.168.1.100

#su - root
[[email protected] samples]$ vi /etc/hosts
192.168.100.100 abc
修改為本機的ip位址
192.168.1.100 abc
           

重新開機資料庫

SQL>shutdown immediate
...
...
...
SQL>startup
Total System Global Area .....
Fixed Size ...
...
...
Database opened.

           

重新開機監聽

[[email protected] samples]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 28-OCT-2019 14:38:34

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

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                28-OCT-2019 14:30:18
Uptime                    0 days 0 hr. 8 min. 16 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /home/oracle/app/oracle/diag/tnslsnr/abc/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=abc)(PORT=1521)))
The listener supports no services
The command completed successfully
           

注意:

這裡The listener supports no services ,一定要看一下監聽狀态,

有可能開了監聽,不可能立刻傳回結果

也有可能是動态監聽,也不會立刻傳回,本例就是動态監聽

 檢視狀态

[[email protected] samples]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 28-OCT-2019 14:38:34

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

Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                28-OCT-2019 14:30:18
Uptime                    0 days 0 hr. 8 min. 16 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Log File         /home/oracle/app/oracle/diag/tnslsnr/abc/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=abc)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "test" has 1 instance(s).
  Instance "test", status READY, has 1 handler(s) for this service...
The command completed successfully
[[email protected] samples]$