[20170527]12c連線外掛資料庫使用sid
[20170527]12c connect Pluggable database using SID.txt
--//12c 支援所謂的Pluggable database,據說以後oracle的資料庫都是Pluggable型.
--//一些應用連線配置時使用sid,而不是服務名.這樣在連線資料庫時存在問題.
--//透過測試說明:
1.環境:
SCOTT@test01p> @ ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.1.0.1.0 Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
2.測試:
D:\tools\rlwrap>sqlplus /nolog
SQL*Plus: Release 12.1.0.1.0 Production on Tue May 30 08:20:05 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
@> conn scott/btbtms@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = test01p)))
Connected.
SCOTT@test01p> conn scott/btbtms@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA =(SERVER = DEDICATED)(SID = test01p)))
ERROR:
ORA-12505: TNS:listener does not currently know of SID given in connect descriptor
Warning: You are no longer connected to ORACLE.
--//可以發現不再支援使用sid連線資料庫.
--//修改tnsnames.ora,加入如下測試:
D:\app\oracle\product\12.1.0\dbhome_1\NETWORK\ADMIN> cat tnsnames.ora
TEST01P =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = zws)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test01p)
)
)
TEST01PX =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = zws)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = test01p)
)
)
--//測試結果如下:
@> connect scott/btbtms@test01p
Connected.
SCOTT@test01p> connect scott/btbtms@test01px
ERROR:
ORA-12505: TNS:listener does not currently know of SID given in connect descriptor
Warning: You are no longer connected to ORACLE.
D:\tools\rlwrap>lsnrctl status
lsnrctl status
LSNRCTL for 64-bit Windows: Version 12.1.0.1.0 - Production on 30-MAY-2017 08:22:31
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ZWS)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 12.1.0.1.0 - Production
Start Date 30-MAY-2017 08:15:21
Uptime 0 days 0 hr. 7 min. 14 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File D:\app\oracle\product\12.1.0\dbhome_1\network\admin\listener.ora
Listener Log File D:\app\oracle\product\12.1.0\dbhome_1\log\diag\tnslsnr\zws\listener\alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=zws)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=zws)(PORT=5500))(Security=(my_wallet_directory=D:\APP\ORACLE\admin\TEST\xdb_wallet))(Presentation=HTTP)(Session=RAW))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=zws)(PORT=5502))(Security=(my_wallet_directory=D:\APP\ORACLE\admin\TEST\xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "TEST" has 2 instance(s).
Instance "TEST", status UNKNOWN, has 1 handler(s) for this service...
Instance "test", status READY, has 1 handler(s) for this service...
Service "test01p" has 1 instance(s).
Instance "test", status READY, has 1 handler(s) for this service...
Service "testXDB" has 1 instance(s).
Instance "test", status READY, has 1 handler(s) for this service...
The command completed successfully
--//你可以發現僅僅支援服務名test01p,而沒有例項名test01p.透過在監聽配置檔案listener.ora中加入如下:
USE_SID_AS_SERVICE_listener=on
--//再重啟監聽:
D:\tools\rlwrap>sc stop OracleOraDB12Home1TNSListener
SERVICE_NAME: OracleOraDB12Home1TNSListener
TYPE : 10 WIN32_OWN_PROCESS
STATE : 3 STOP_PENDING
(STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x1
WAIT_HINT : 0xfa0
D:\tools\rlwrap>sc start OracleOraDB12Home1TNSListener
SERVICE_NAME: OracleOraDB12Home1TNSListener
TYPE : 10 WIN32_OWN_PROCESS
STATE : 2 START_PENDING
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x2
WAIT_HINT : 0xfa0
PID : 5800
FLAGS :
@> conn scott/btbtms@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA =(SERVER = DEDICATED)(SID = test01p)))
Connected.
SCOTT@test01p> connect scott/btbtms@test01px
Connected.
SCOTT@test01px> connect scott/btbtms@test01p
Connected.
SCOTT@test01p> conn scott/btbtms@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = test01p)))
Connected.
--//這樣就ok了.
--//一些8i的應用配置使用sid來連線,升級到12c後就出現問題,建議還是改用服務名來連線.
--//12c 支援所謂的Pluggable database,據說以後oracle的資料庫都是Pluggable型.
--//一些應用連線配置時使用sid,而不是服務名.這樣在連線資料庫時存在問題.
--//透過測試說明:
1.環境:
SCOTT@test01p> @ ver1
PORT_STRING VERSION BANNER CON_ID
------------------------------ -------------- -------------------------------------------------------------------------------- ----------
IBMPC/WIN_NT64-9.1.0 12.1.0.1.0 Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production 0
2.測試:
D:\tools\rlwrap>sqlplus /nolog
SQL*Plus: Release 12.1.0.1.0 Production on Tue May 30 08:20:05 2017
Copyright (c) 1982, 2013, Oracle. All rights reserved.
@> conn scott/btbtms@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = test01p)))
Connected.
SCOTT@test01p> conn scott/btbtms@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA =(SERVER = DEDICATED)(SID = test01p)))
ERROR:
ORA-12505: TNS:listener does not currently know of SID given in connect descriptor
Warning: You are no longer connected to ORACLE.
--//可以發現不再支援使用sid連線資料庫.
--//修改tnsnames.ora,加入如下測試:
D:\app\oracle\product\12.1.0\dbhome_1\NETWORK\ADMIN> cat tnsnames.ora
TEST01P =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = zws)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = test01p)
)
)
TEST01PX =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = zws)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SID = test01p)
)
)
--//測試結果如下:
@> connect scott/btbtms@test01p
Connected.
SCOTT@test01p> connect scott/btbtms@test01px
ERROR:
ORA-12505: TNS:listener does not currently know of SID given in connect descriptor
Warning: You are no longer connected to ORACLE.
D:\tools\rlwrap>lsnrctl status
lsnrctl status
LSNRCTL for 64-bit Windows: Version 12.1.0.1.0 - Production on 30-MAY-2017 08:22:31
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ZWS)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for 64-bit Windows: Version 12.1.0.1.0 - Production
Start Date 30-MAY-2017 08:15:21
Uptime 0 days 0 hr. 7 min. 14 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File D:\app\oracle\product\12.1.0\dbhome_1\network\admin\listener.ora
Listener Log File D:\app\oracle\product\12.1.0\dbhome_1\log\diag\tnslsnr\zws\listener\alert\log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=zws)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(PIPENAME=\\.\pipe\EXTPROC1521ipc)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=zws)(PORT=5500))(Security=(my_wallet_directory=D:\APP\ORACLE\admin\TEST\xdb_wallet))(Presentation=HTTP)(Session=RAW))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=zws)(PORT=5502))(Security=(my_wallet_directory=D:\APP\ORACLE\admin\TEST\xdb_wallet))(Presentation=HTTP)(Session=RAW))
Services Summary...
Service "CLRExtProc" has 1 instance(s).
Instance "CLRExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "TEST" has 2 instance(s).
Instance "TEST", status UNKNOWN, has 1 handler(s) for this service...
Instance "test", status READY, has 1 handler(s) for this service...
Service "test01p" has 1 instance(s).
Instance "test", status READY, has 1 handler(s) for this service...
Service "testXDB" has 1 instance(s).
Instance "test", status READY, has 1 handler(s) for this service...
The command completed successfully
--//你可以發現僅僅支援服務名test01p,而沒有例項名test01p.透過在監聽配置檔案listener.ora中加入如下:
USE_SID_AS_SERVICE_listener=on
--//再重啟監聽:
D:\tools\rlwrap>sc stop OracleOraDB12Home1TNSListener
SERVICE_NAME: OracleOraDB12Home1TNSListener
TYPE : 10 WIN32_OWN_PROCESS
STATE : 3 STOP_PENDING
(STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x1
WAIT_HINT : 0xfa0
D:\tools\rlwrap>sc start OracleOraDB12Home1TNSListener
SERVICE_NAME: OracleOraDB12Home1TNSListener
TYPE : 10 WIN32_OWN_PROCESS
STATE : 2 START_PENDING
(NOT_STOPPABLE, NOT_PAUSABLE, IGNORES_SHUTDOWN)
WIN32_EXIT_CODE : 0 (0x0)
SERVICE_EXIT_CODE : 0 (0x0)
CHECKPOINT : 0x2
WAIT_HINT : 0xfa0
PID : 5800
FLAGS :
@> conn scott/btbtms@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA =(SERVER = DEDICATED)(SID = test01p)))
Connected.
SCOTT@test01p> connect scott/btbtms@test01px
Connected.
SCOTT@test01px> connect scott/btbtms@test01p
Connected.
SCOTT@test01p> conn scott/btbtms@(DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 127.0.0.1)(PORT = 1521)) (CONNECT_DATA =(SERVER = DEDICATED)(SERVICE_NAME = test01p)))
Connected.
--//這樣就ok了.
--//一些8i的應用配置使用sid來連線,升級到12c後就出現問題,建議還是改用服務名來連線.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2140061/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- IDEA安裝外掛【Database navigation】並連線資料庫IdeaDatabaseNavigation資料庫
- 使用Sequelize連線資料庫資料庫
- 使用JPA連線資料庫資料庫
- 12C資料庫連線ORA-28040問題資料庫
- 使用C#連線資料庫C#資料庫
- 使用Python連線資料庫Python資料庫
- 資料庫連線池的使用資料庫
- 使用hostname方式連線資料庫!資料庫
- PROXOOL資料庫連線池使用資料庫
- 使用cmd連線mysql資料庫MySql資料庫
- 資料庫外連線,自然連線,內連線,條件連線,等值連線關係及詳解資料庫
- 【資料庫】使用DBever連線人大金倉資料庫資料庫
- 用Navicat連線資料庫-資料庫連線(MySQL演示)資料庫MySql
- Django使用pymysql連線MySQL資料庫DjangoMySql資料庫
- 使用PETAPOCO連線MYSQL資料庫MySql資料庫
- Laravel 使用多個資料庫連線Laravel資料庫
- 使用instantclient連線oracle資料庫clientOracle資料庫
- 使用ABP EntityFramework連線MySQL資料庫FrameworkMySql資料庫
- idea使用資料庫連線工具Idea資料庫
- MFC 使用VS 連線 MySQL資料庫MySql資料庫
- 使用psql連線Postgres資料庫SQL資料庫
- 連線資料庫資料庫
- 資料庫連線資料庫
- 【MySQL】自定義資料庫連線池和開源資料庫連線池的使用MySql資料庫
- 請關掉你的資料庫連線!並且請使用資料庫連線池資料庫
- 資料庫–如何連線RDS例項,使用雲資料庫?資料庫
- 使用RMySQL包來連線MySQL資料庫MySql資料庫
- java資料庫連線池dbcp的使用Java資料庫
- 使用oracle Transparent gateway 連線 sybase 資料庫OracleGateway資料庫
- 使用ssh tunnels加密連線oracle資料庫加密Oracle資料庫
- 使用DBever連線人大金倉資料庫資料庫
- 資料庫中字串連線符的使用資料庫字串
- JDBC連線資料庫JDBC資料庫
- java連線資料庫Java資料庫
- Mybatis連線資料庫MyBatis資料庫
- Mongodb資料庫連線MongoDB資料庫
- mysqli連線資料庫MySql資料庫
- 資料庫的連線資料庫