[20190102]連線串不配置服務名能連線資料庫嗎.txt
[20190102]連線串不配置服務名能連線資料庫嗎.txt
--//如果連線串裡面沒有配置服務名或者sid能連線資料庫嗎?
--//這個問題就像別人問我不啟動監聽遠端能連線資料庫嗎?
--//我的第一回答是不行,實際上不啟動監聽是可以的,參考連線:
--//http://blog.itpub.net/267265/viewspace-1816211/ =>[20151023]不啟動監聽遠端能連線資料庫嗎?
--// 連線串不配置服務名也可以連線資料庫, 透過例子說明問題:
1.環境:
SCOTT@book> @ ver1
PORT_STRING VERSION BANNER
------------------------------ -------------- --------------------------------------------------------------------------------
x86_64/Linux 2.4.xx 11.2.0.4.0 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
--//連線串在tnsnames.ora的配置如下:
78=
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.78)(PORT = 1521))
)
(SDU = 32768)
(CONNECT_DATA =
(SERVER = DEDICATED)
# (SERVICE_NAME = book)
)
)
--//註解了服務名.
2.測試:
d:\>tnsping 78 2
TNS Ping Utility for 64-bit Windows: Version 12.2.0.1.0 - Production on 02-JAN-2019 14:48:54
Copyright (c) 1997, 2016, Oracle. All rights reserved.
Used parameter files:
E:\app\oracle\product\12.2.0\dbhome_1\NETWORK\ADMIN\sqlnet.ora
Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.100.78)(PORT = 1521))) (SDU = 32768) (CONNECT_DATA = (SERVER = DEDICATED)))
OK (0 msec)
OK (0 msec)
--//tnsping沒有問題,並不說明client段能連上.僅僅說明開啟了1521埠.
d:\>sqlplus -l scott/book@78
SQL*Plus: Release 12.2.0.1.0 Production on Wed Jan 2 14:49:55 2019
Copyright (c) 1982, 2016, Oracle. All rights reserved.
ERROR:
ORA-12504: TNS:listener was not given the SERVICE_NAME in CONNECT_DATA
SP2-0751: Unable to connect to Oracle. Exiting SQL*Plus
3.實際上只要在伺服器監聽加入如下:
DEFAULT_SERVICE_LISTENER=book
--//再重啟啟動監聽,客戶端就可以連線資料庫.
$ grep DEFAULT_SERVICE_LISTENER listener.ora
DEFAULT_SERVICE_LISTENER=book
$ lsnrctl stop ;sleep 1 ; lsnrctl start
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 02-JAN-2019 14:51:44
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(ARGV0=LLLLLL)(HOST=0.0.0.0)(PORT=1521)(ARGV0=KKKKK)))
The command completed successfully
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 02-JAN-2019 14:51:50
Copyright (c) 1991, 2013, Oracle. All rights reserved.
Starting /u01/app/oracle/product/11.2.0.4/dbhome_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.4.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/product/11.2.0.4/dbhome_1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(ARGV0=LLLLLL)(HOST=0.0.0.0)(PORT=1521)(ARGV0=KKKKK)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date 02-JAN-2019 14:51:50
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Default Service book
Listener Parameter File /u01/app/oracle/product/11.2.0.4/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/product/11.2.0.4/dbhome_1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=0.0.0.0)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "booK123" has 1 instance(s).
Instance "book", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
d:\>sqlplus -l scott/book@78
SQL*Plus: Release 12.2.0.1.0 Production on Wed Jan 2 14:52:10 2019
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SCOTT@78> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
---- ---------- ------------------------ --------- ----- --- ---------- ---------------------------------------------
41 299 9484:9912 DEDICATED 60928 27 108 alter system kill session '41,299' immediate;
--//測試使用ezconnect方式看看:
d:\>sqlplus scott/book@192.168.100.78:1521
SQL*Plus: Release 12.2.0.1.0 Production on Wed Jan 2 14:53:01 2019
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SCOTT@192.168.100.78:1521> select sysdate from dual ;
SYSDATE
-------------------
2019-01-02 14:53:07
SCOTT@192.168.100.78:1521> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
--- ---------- ------------------------ --------- ----- --- ---------- ---------------------------------------------
262 71 9640:7508 SHARED 58907 20 1 alter system kill session '262,71' immediate;
--//連線模式=SHARED.這個問題源於配置引數dispatchers,加入了服務名book.
SCOTT@book> show parameter dispatchers
NAME TYPE VALUE
--------------- -------- -------------------------------------
dispatchers string (PROTOCOL=TCP) (SERVICE=book,bookXDB)
max_dispatchers integer
d:\>sqlplus scott/book@192.168.100.78:1521/:DEDICATED
SQL*Plus: Release 12.2.0.1.0 Production on Wed Jan 2 14:54:47 2019
Copyright (c) 1982, 2016, Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SCOTT@192.168.100.78:1521/:DEDICATED> @ spid
SID SERIAL# PROCESS SERVER SPID PID P_SERIAL# C50
--- ---------- ------------------------ --------- ----- --- ---------- ---------------------------------------------
41 297 9472:9520 DEDICATED 60916 27 107 alter system kill session '41,297' immediate;
--//連線模式=DEDICATED.
4.收尾:
--//還原配置.僅僅知道這些就足夠了.
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/267265/viewspace-2287143/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- [20210428]資料庫連線加密.txt資料庫加密
- Mybatis配置資料庫連線MyBatis資料庫
- [20181224]使用odbc連線oracle資料庫.txtOracle資料庫
- 用Navicat連線資料庫-資料庫連線(MySQL演示)資料庫MySql
- [20200218]連線串與專用模式.txt模式
- [20200218]ENABLE=BROKEN在連線串中.txt
- ORACLE 配置連線遠端資料庫Oracle資料庫
- mysql資料庫連線池配置教程MySql資料庫
- 連線資料庫資料庫
- [20181128]toad連線資料庫的問題.txt資料庫
- JavaWeb之事務&資料庫連線池JavaWeb資料庫
- spring boot 不連線資料庫啟動Spring Boot資料庫
- python 連線 mongo 資料庫連線超時PythonGo資料庫
- 配置檔案中的資料庫連線串加密了,你以為我就挖不出來嗎?資料庫加密
- 網站連線資料庫配置錯誤網站資料庫
- 網站連線資料庫配置檔案網站資料庫
- druid資料庫連線池的配置類UI資料庫
- 2.6 Laravel配置多個資料庫連線Laravel資料庫
- 資料庫連線池-Druid資料庫連線池原始碼解析資料庫UI原始碼
- mysqli連線資料庫MySql資料庫
- Mongodb資料庫連線MongoDB資料庫
- Android 連線資料庫Android資料庫
- java連線資料庫Java資料庫
- 連線資料庫-mysql資料庫MySql
- jmeter連線資料庫JMeter資料庫
- Mybatis連線資料庫MyBatis資料庫
- JSP連線資料庫JS資料庫
- JDBC連線資料庫JDBC資料庫
- Flask連線資料庫Flask資料庫
- [20230306]os認證連線資料庫問題.txt資料庫
- iis網站怎麼連線資料庫連線網站資料庫
- SSH服務連線
- 《四 資料庫連線池原始碼》手寫資料庫連線池資料庫原始碼
- [20200218]ENABLE=BROKEN在連線串中4.txt
- [20210201]dblink建立連線串使用ENABLE=BROKEN.txt
- openGauss資料庫JDBC環境連線配置(Eclipse)資料庫JDBCEclipse
- linux 資料庫localhostl連線成功127.0.0.1連線失敗Linux資料庫localhost127.0.0.1
- Kettle自定義資料庫連線型別連線HGDB資料庫型別