转载:https://blog.csdn.net/haha_201510/article/details/88119587
centOS环境下的解决方案:
查看监听状态lsnrctl status
如果有监听,则如下图,显示有服务orcl(服务名)监听。
如果没有监听,查看监听文件
cd
/u01/app/oracle/product/11.2.0/db_1/network/admin
tnsnames.ora:用于客户端,提示客户端从哪个监听实例连接。
LISTENER_ORCL = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521)) ORCL = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl) ) )
listener.ora:用于服务端,用于提示服务端监听哪些实例。
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST =localhost.localdomain)(PORT = 1521)) # (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.0.105)(PORT = 1521)) ) ) SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = orcl) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1/) (SID_NAME = ORCL) ) ) #PS: 这里面的SID_NAME是oracle实例名,GLOBAL_DBNAME是全局的dbname,是db_unique_name LISTENER = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521)) ) ADR_BASE_LISTENER = /u01/app/oracle
其中HOST为当前主机名(可以使用本机的IP地址)。
注意:当前我的hosts文件的配置如下
[root@192 etc]# vim /etc/hosts
127.0.0.1 localhost localhost.localdomain ::1 localhost localhost.localdomain