如果静态监听中ORACLE_SID不注意大小写的话,可能导致数据库连接不上的问题。如下案例所示: $ sqlplus system/***@GPSUAT
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Sep 18 15:48:37 2024
Version 19.24.0.0.0
Copyright (c) 1982, 2024, Oracle. All rights reserved.
ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux-x86_64 Error: 2: No such file or directory
Additional information: 4480
Additional information: -1989017509
Process ID: 0
Session ID: 0 Serial number: 0
Enter user-name:
ERROR:
ORA-01017: invalid username/password; logon denied
检查数据库实例正常。使用tnsping检查服务的网络是否正常,如下所示: $ tnsping GPSUAT
TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 07-NOV-2023 08:35:42
Copyright (c) 1997, 2022, Oracle. All rights reserved.
Used parameter files:
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.9.40)(PORT = 15021)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = GPSUAT)))
OK (10 msec)
数据库中tnsnames.ora的配置如下所示: GPSUAT =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.9.40)(PORT = 15021))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = GPSUAT)
)
)
此时,监听的配置如下 $ more listener.ora
GPS =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = GPS))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.9.40)(PORT = 15021))
(ADDRESS = (PROTOCOL = TCPS)(HOST =192.168.9.40)(PORT = 15022))
)
)
SID_LIST_GPS =
(SID_LIST =
(SID_DESC =
(SID_NAME = GPS)
(ORACLE_HOME=/opt/oracle19c/product/19.3.0/db_1)
)
(SID_DESC =
(GLOBAL_DBNAME = GPSUAT)
(SID_NAME = GPS)
(ORACLE_HOME=/opt/oracle19c/product/19.3.0/db_1)
)
(SID_DESC =
(GLOBAL_DBNAME = GPSUAT2)
(SID_NAME = GPS)
(ORACLE_HOME=/opt/oracle19c/product/19.3.0/db_1)
)
)
SECURE_REGISTER_GPS = (IPC)
SECURE_CONTROL_GPS =(TCPS,IPC)
ADMIN_RESTRICTIONS_GPS = ON
DIAG_ADR_ENABLED_GPS = OFF
正确的配置如下(SID_NAME必须使用小写,跟实例的大小写一致。这里ORACLE_SID值为gps) $ more listener.ora
GPS =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = GPS))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.9.40)(PORT = 15021))
(ADDRESS = (PROTOCOL = TCPS)(HOST =192.168.9.40)(PORT = 15022))
)
)
SID_LIST_GPS =
(SID_LIST =
(SID_DESC =
(SID_NAME = gps)
(ORACLE_HOME=/opt/oracle19c/product/19.3.0/db_1)
)
(SID_DESC =
(GLOBAL_DBNAME = GPSUAT)
(SID_NAME = gps)
(ORACLE_HOME=/opt/oracle19c/product/19.3.0/db_1)
)
(SID_DESC =
(GLOBAL_DBNAME = GPSUAT2)
(SID_NAME = gps)
(ORACLE_HOME=/opt/oracle19c/product/19.3.0/db_1)
)
)
SECURE_REGISTER_GPS = (IPC)
SECURE_CONTROL_GPS =(TCPS,IPC)
ADMIN_RESTRICTIONS_GPS = ON
结论如下所示: 在监听静态注册的环境中,listener.ora文件中写的实例名,要区分大小写,否则虽然远程telnet 监听端口是通的,但依旧会报出数据库不可用的问题。 之所以会报出数据库不可用问题,是由于远程连接通过监听连到的是另外一个库,而该库没有启动或者不存在。 总结:以后在处理问题中,注意区分实例名大小写问题,在监听层面,动态监听和静态监听很容易混淆实例名问题,尤其当服务器上存在大小写不同的数据库时候。
|