这里的想法是能够使用服务名称而不是 SID 连接到我的数据库。这是我的tnsnames.ora
:
# tnsnames.ora Network Configuration File: C:\Users\jj\Downloads\WINDOWS.X64_193000_db_home\NETWORK\ADMIN\tnsnames.ora
# Generated by Oracle configuration tools.
LISTENER_ORCL =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
ORACLR_CONNECTION_DATA =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
(CONNECT_DATA =
(SID = CLRExtProc)
(PRESENTATION = RO)
)
)
ORCL =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = orcl.myDomain.int)
)
)
DB_PBD =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = myServiceName)
)
)
这是我的listener.ora
:
# listener.ora Network Configuration File: C:\Users\jj\Downloads\WINDOWS.X64_193000_db_home\NETWORK\ADMIN\listener.ora
# Generated by Oracle configuration tools.
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = CLRExtProc)
(ORACLE_HOME = C:\Users\jj\Downloads\WINDOWS.X64_193000_db_home)
(PROGRAM = extproc)
(ENVS = "EXTPROC_DLLS=ONLY:C:\Users\jj\Downloads\WINDOWS.X64_193000_db_home\bin\oraclr19.dll")
)
(SID_DESC =
(GLOBAL_DBNAME = orcl)
(ORACLE_HOME = C:\Users\jj\Downloads\WINDOWS.X64_193000_db_home)
(SID_NAME = orcl)
)
(SID_DESC =
(GLOBAL_DBNAME = DB_PBD)
(ORACLE_HOME = C:\Users\jj\Downloads\WINDOWS.X64_193000_db_home)
(SID_NAME = orcl)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost)(PORT = 1521))
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
)
)
到目前为止,我可以使用和ORCL
建立连接。orcl.myDomain.int
DB_PBD
但是,当我尝试使用myServiceName
which is SERVICE_NAME
of the entry连接到它时DB_PBD
,我收到以下错误:
TNS-12514: TNS:listener does not currently know of service requested in connect descriptor
myServiceName 的定义方式有问题吗?
编辑:当我在我的数据库中查看我的服务列表时,我没有找到 myServiceName:
SQL> select name from V$SERVICES;
NAME
----------------------------------------------------------------
orclXDB
SYS$BACKGROUND
orcl.myDomain.int
SYS$USERS
orclpdb
我也应该在这里添加它吗?