このエラーの解決策は非常に簡単です。まず、このエラーが発生する理由を理解しましょう。基本的に次の 2 つの理由があります:
1) データベースとサービス名が Oracle 環境で適切に設定されていません。どこでも同じである必要があります。以下のパラメータ値を確認してください
-ORACLE_SID in oracle environment.
-SID_NAME in tnsnames.ora file.
-SERVICE_NAME in listener.ora file.
2) ホスト名/IP アドレスが欠落している、正しくない、またはスペルミスがあるため、以下を確認してください。
-Check the IP ADDRESS in /etc/hosts file.
-It should be same in listener.ora and tnsnames.ora file
-And it should be able to ping from the local and remote server.
私も同じ問題に直面し、解決しました:
[[email protected] Desktop]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jul 12 22:52:29 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 970895360 bytes
Fixed Size 1340636 bytes
Variable Size 713034532 bytes
Database Buffers 251658240 bytes
Redo Buffers 4861952 bytes
Database mounted.
Database opened.
SQL>
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[[email protected] Desktop]$
[[email protected] Desktop]$ lsnrctl
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 12-JUL-2017 22:54:51
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ole1)(PORT=1521)))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
LSNRCTL> LSNRCTL> start
Starting /home/oracle/app/oracle/product/11.2.0/dbhome_1//bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /home/oracle/app/oracle/diag/tnslsnr/OLE1/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ole1)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 12-JUL-2017 22:55:43
Uptime 0 days 0 hr. 0 min. 23 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /home/oracle/app/oracle/diag/tnslsnr/OLE1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ole1)(PORT=1521)))
The listener supports no services
The command completed successfully
LSNRCTL> [[email protected] Desktop]$
[[email protected] Desktop]$
[[email protected] Desktop]$ echo $ORACLE_SID
orcl
[[email protected] Desktop]$
[[email protected] admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = ole1)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
[[email protected] admin]$
[[email protected] admin]$ cat listener.ora
# listener.ora Network Configuration File: /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
(ADDRESS = (PROTOCOL = TCP)(HOST = ole1 )(PORT = 1521))
)
)
ADR_BASE_LISTENER = /home/oracle/app/oracle
[[email protected] admin]$
[[email protected] admin]$ cat /etc/hosts
127.0.0.1 localhost
::1 localhost
192.168.244.128 ole1
[[email protected] admin]$
[[email protected] ~]$ tnsping orcl
TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 12-JUL-2017 22:57:14
Copyright (c) 1997, 2009, Oracle. All rights reserved.
Used parameter files:
/home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ole1)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl)))
TNS-12541: TNS:no listener
[[email protected] ~]$
[[email protected] ~]$ lsnrctl
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 12-JUL-2017 23:01:48
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL>
LSNRCTL>
LSNRCTL> reload
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
LSNRCTL>
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 12-JUL-2017 22:55:43
Uptime 0 days 0 hr. 6 min. 37 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /home/oracle/app/oracle/diag/tnslsnr/OLE1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ole1)(PORT=1521)))
The listener supports no services
The command completed successfully
LSNRCTL> stop
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
LSNRCTL> start
Starting /home/oracle/app/oracle/product/11.2.0/dbhome_1//bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /home/oracle/app/oracle/diag/tnslsnr/OLE1/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ole1)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 12-JUL-2017 23:03:10
Uptime 0 days 0 hr. 0 min. 21 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /home/oracle/app/oracle/diag/tnslsnr/OLE1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ole1)(PORT=1521)))
The listener supports no services
The command completed successfully
LSNRCTL>
[[email protected] ~]$
[[email protected] ~]$
[[email protected] ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on Wed Jul 12 23:04:37 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select name from v$database;
NAME
---------
ORCL
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[[email protected] ~]$
[[email protected] admin]$ cat /etc/hosts
127.0.0.1 localhost
::1 localhost
192.168.244.128 ole1
[[email protected] admin]$ ping ole1
PING ole1 (192.168.244.128) 56(84) bytes of data.
^C
--- ole1 ping statistics ---
14 packets transmitted, 0 received, 100% packet loss, time 13710ms
[[email protected] admin]$
注: ここで、IP アドレス構成に問題があり、ping を実行していないことがわかりました。そのため、VMware マシンの OS の eth1 ドライバーにいくつかの変更を加えました。
[[email protected] admin]$ ping ole1
PING ole1 (192.168.244.128) 56(84) bytes of data.
64 bytes from ole1 (192.168.244.128): icmp_seq=1 ttl=64 time=0.694 ms
64 bytes from ole1 (192.168.244.128): icmp_seq=2 ttl=64 time=0.187 ms
64 bytes from ole1 (192.168.244.128): icmp_seq=3 ttl=64 time=4.96 ms
64 bytes from ole1 (192.168.244.128): icmp_seq=4 ttl=64 time=0.121 ms
64 bytes from ole1 (192.168.244.128): icmp_seq=5 ttl=64 time=0.082 ms
64 bytes from ole1 (192.168.244.128): icmp_seq=6 ttl=64 time=0.166 ms
64 bytes from ole1 (192.168.244.128): icmp_seq=7 ttl=64 time=0.126 ms
^C
--- ole1 ping statistics ---
7 packets transmitted, 7 received, 0% packet loss, time 6996ms
rtt min/avg/max/mdev = 0.082/0.905/4.963/1.668 ms
[[email protected] admin]$
[[email protected] admin]$
[[email protected] admin]$ lsnrctl
LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 12-JUL-2017 23:09:37
Copyright (c) 1991, 2009, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> stop
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully
LSNRCTL>
LSNRCTL>
LSNRCTL> start
Starting /home/oracle/app/oracle/product/11.2.0/dbhome_1//bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.1.0 - Production
System parameter file is /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Log messages written to /home/oracle/app/oracle/diag/tnslsnr/OLE1/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ole1)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 12-JUL-2017 23:09:45
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /home/oracle/app/oracle/diag/tnslsnr/OLE1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ole1)(PORT=1521)))
The listener supports no services
The command completed successfully
LSNRCTL>
LSNRCTL>
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date 12-JUL-2017 23:09:45
Uptime 0 days 0 hr. 2 min. 17 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /home/oracle/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File /home/oracle/app/oracle/diag/tnslsnr/OLE1/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ole1)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
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
[[email protected] admin]$
[[email protected] admin]$
[[email protected] admin]$ sqlplus scott/[email protected]
SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 13 00:15:48 2017
Copyright (c) 1982, 2009, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL>
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[[email protected] admin]$
今は問題なく動作しています。お役に立てば幸いです。
ありがとう!