[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/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 資料庫的連線串資料庫
- [zt] JDBC連線Oracle RAC的連線串配置JDBCOracle
- Mybatis配置資料庫連線MyBatis資料庫
- solr連線資料庫配置Solr資料庫
- PLSQL連線oracle資料庫配置SQLOracle資料庫
- JNDI配置資料庫連線池資料庫
- .net 資料庫連線池配置資料庫
- SQL server資料庫連線不上SQLServer資料庫
- 用Navicat連線資料庫-資料庫連線(MySQL演示)資料庫MySql
- 【LISTENER】資料庫連線串的幾種寫法資料庫
- [20170825]不啟動監聽遠端能連線資料庫嗎2資料庫
- 連線資料庫資料庫
- 資料庫連線資料庫
- MySQL顯示連線的資料庫名MySql資料庫
- 這樣也能連線資料庫[zt]資料庫
- mysql資料庫連線池配置教程MySql資料庫
- ORACLE 配置連線遠端資料庫Oracle資料庫
- SSH服務連線
- JavaWeb之事務&資料庫連線池JavaWeb資料庫
- Oracle 11g RAC通過SCAN IP連線資料庫 - JDBC連線串問題Oracle資料庫JDBC
- [資料庫連線字串] Access 連線字串(轉)資料庫字串
- [資料庫連線字串]Access連線字串(轉)資料庫字串
- 各種連線資料庫的連線字串資料庫字串
- 資料庫外連線,自然連線,內連線,條件連線,等值連線關係及詳解資料庫
- PostgreSQL連線串URI配置(libpq相容配置)SQL
- 配置檔案中的資料庫連線串加密了,你以為我就挖不出來嗎?資料庫加密
- 【全域性資料庫名、連線描述符】資料庫
- 2.6 Laravel配置多個資料庫連線Laravel資料庫
- jive的資料庫連線配置問題資料庫
- [求助]資料庫連線池配置問題資料庫
- 網站連線資料庫配置檔案網站資料庫
- 網站連線資料庫配置錯誤網站資料庫
- JDBC連線資料庫時,Oracle9i的連線引數配置JDBC資料庫Oracle
- JDBC連線資料庫JDBC資料庫
- java連線資料庫Java資料庫
- Mybatis連線資料庫MyBatis資料庫
- Mongodb資料庫連線MongoDB資料庫
- mysqli連線資料庫MySql資料庫