出现这种情况,一般证明不是主动监听的,而是静态加载的,无法获取到数据库示例的状态(服务启动还是未启动)
静态加载配置(*/admin/listener.ora):多添加了这个配置,就会静态加载
LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) (ADDRESS = (PROTOCOL = TCP)(HOST =192.168.3.100)(PORT = 1521)) ) )
一般情况下,我不喜欢这样,总是想要把它搞成主动动态加载,毕竟是监听嘛,要不就很不爽
自己经历的用过的手段
1.检查配置文件
/admin/listener.ora
# listener.ora Network Configuration File: /data/u01/app/oracle/product/19/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = $hotst)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)# 根据自己的配置
ADR_BASE_LISTENER = /data/u01/app/oracle
/admin/tnsnames.ora 配置数据库的服务名
$ cat $ORACLE_HOME/network/admin/tnsnames.ora
# tnsnames.ora Network Configuration File: /opt/oracle/product/11.2.0/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.198.132)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl)
)
)
2.重启监听
lsnrctl stop
lsnrctl start
3.重启数据库服务或者(已经启动时alter system register)
4.查看监听状态,查看服务是否被正常监听
lsnrctl stop
lsnrctl start
5.如果没有被监听成功,继续检查 /etc/hosts配置(使用root用户修改),这一步很重要
127.0.0.1 改为 localhost
192.168.198.132 添加上自己虚拟机的ip地址 (IP ADDR 或者IFCONFIG查看)
# 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4
# ::1 localhost localhost.localdomain localhost6 localhost6.localdomain
127.0.0.1 localhost
192.168.198.132 localhost.localdomain
修改完成后保存
6.重复2、3、4的操作步骤,查看效果,
7.如果还没有成功,朕也无能为力,最后一招,看log.xml(oracle/diag/tnslsnr/localhost/listener/alert/log.xml)自行解决