oracle監聽動態註冊與靜態註冊
client端如果想要連線到遠端的資料庫伺服器,首先資料庫伺服器必須啟動監聽器
oracle監聽器的配置在$ORACLE_HOME/network/admin/listener.ora,開啟這個檔案,我們看到配置如下:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0.1)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
)
動態註冊:oracle instance的pmon程式會在instance啟動之後自動將instance_name和service_name註冊到1521埠中,我們只需要在listener中修改配置如下,即可實現
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.102)(PORT = 1521))
)
)
注意我們不用修改SID_LIST_LISTENER中的配置
我們首先啟動監聽器 lsnrctl
LSNRCTL> start
Starting /u01/app/oracle/product/10.2.0.1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/10.2.0.1/network/admin/listener.ora
Log messages written to /u01/app/oracle/product/10.2.0.1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.102)(PORT=1521)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 22-FEB-2012 07:40:42
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/10.2.0.1/network/admin/listener.ora
Listener Log File /u01/app/oracle/product/10.2.0.1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.102)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
由於我們沒有啟動instance,所以沒有instance的註冊資訊
啟動oracle例項
[oracle@localhost ~]$ export ORACLE_SID=prod
[oracle@localhost ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Feb 22 07:42:49 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 180355072 bytes
Fixed Size 1218364 bytes
Variable Size 88082628 bytes
Database Buffers 83886080 bytes
Redo Buffers 7168000 bytes
Database mounted.
Database opened.
prod instance已經啟動,稍等一會我們檢視監聽器狀態
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 22-FEB-2012 07:40:42
Uptime 0 days 0 hr. 3 min. 15 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/10.2.0.1/network/admin/listener.ora
Listener Log File /u01/app/oracle/product/10.2.0.1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.102)(PORT=1521)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
Service "prod" has 1 instance(s).
Instance "prod", status READY, has 1 handler(s) for this service...
Service "prod_XPT" has 1 instance(s).
Instance "prod", status READY, has 1 handler(s) for this service...
The command completed successfully
發現prod服務已經被動態註冊進去,其中status為READY說明動態註冊成功
靜態註冊:由於oracle的pmon程式會自動將instance的instance_name和service_name註冊到1521埠,如果我們想把instance 註冊到1521之外的埠,我們只能使用靜態註冊
下面我們修改listener.ora配置如下:
SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = PLSExtProc)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0.1)
(PROGRAM = extproc)
)
)
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
)
)
staticReg =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.102)(PORT = 1522))
)
)
SID_LIST_staticReg =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME= prod)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0.1)
(SID_NAME = prod)
)
)
我們首先增加了監聽配置:
staticReg =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.102)(PORT = 1522))
)
)
不同於動態註冊,我們必須指定listenername,這裡為staticReg
然後增加了SID_LIST關於staticReg的指定配置
SID_LIST_staticReg =
(SID_LIST =
(SID_DESC =
(GLOBAL_DBNAME= prod)
(ORACLE_HOME = /u01/app/oracle/product/10.2.0.1)
(SID_NAME = prod)
)
)
由於是非標準埠號,我們必須指定SID_LIST配置
儲存之後,啟動監聽:
[oracle@localhost admin]$ lsnrctl
LSNRCTL for Linux: Version 10.2.0.1.0 - Production on 22-FEB-2012 07:51:03
Copyright (c) 1991, 2005, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> start
Starting /u01/app/oracle/product/10.2.0.1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/10.2.0.1/network/admin/listener.ora
Log messages written to /u01/app/oracle/product/10.2.0.1/network/log/listener.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 22-FEB-2012 07:51:06
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/10.2.0.1/network/admin/listener.ora
Listener Log File /u01/app/oracle/product/10.2.0.1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
之後啟動instance prod
[oracle@localhost ~]$ export ORACLE_SID=prod
[oracle@localhost ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on Wed Feb 22 07:42:49 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 180355072 bytes
Fixed Size 1218364 bytes
Variable Size 88082628 bytes
Database Buffers 83886080 bytes
Redo Buffers 7168000 bytes
Database mounted.
Database opened.
無論我們等待多久,檢視狀態都是下面顯示的內容
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 22-FEB-2012 07:51:06
Uptime 0 days 0 hr. 1 min. 37 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/10.2.0.1/network/admin/listener.ora
Listener Log File /u01/app/oracle/product/10.2.0.1/network/log/listener.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1)))
Services Summary...
Service "PLSExtProc" has 1 instance(s).
Instance "PLSExtProc", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
由於我們採用的監聽埠是1522,pmon程式是不會自動註冊是1521之外的埠
我們需要啟動1522埠的監聽
LSNRCTL> start staticReg
Starting /u01/app/oracle/product/10.2.0.1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 10.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/10.2.0.1/network/admin/listener.ora
Log messages written to /u01/app/oracle/product/10.2.0.1/network/log/staticreg.log
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.102)(PORT=1522)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.1.102)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias staticReg
Version TNSLSNR for Linux: Version 10.2.0.1.0 - Production
Start Date 22-FEB-2012 07:56:18
Uptime 0 days 0 hr. 0 min. 0 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/10.2.0.1/network/admin/listener.ora
Listener Log File /u01/app/oracle/product/10.2.0.1/network/log/staticreg.log
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.1.102)(PORT=1522)))
Services Summary...
Service "prod" has 1 instance(s).
Instance "prod", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
由於prod採用的是靜態註冊,所以狀態永遠都是UNKNOW
等一會,我們就可以直接採用sqlplus連線,當然客戶端必須有對應的tnsname的配置
C:\Users\lei_dong>sqlplus sys/prod@port1522 as sysdba
SQL*Plus: Release 10.2.0.1.0 - Production on 星期三 2月 22 23:58:06 2012
Copyright (c) 1982, 2005, Oracle. All rights reserved.
連線到:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL>
連線成功,
最後我們需要在client端配置tnsname,這時無論啟動的是1521還是其他埠的監聽,差別都不大,基本上只有埠號的差異
linux =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.102)(PORT = 1521))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = prod)
)
)
port1522 =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.102)(PORT = 1522))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = prod)
)
)
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/24558279/viewspace-758523/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- oracle的靜態註冊和動態註冊Oracle
- 動態註冊和靜態註冊
- rac監聽不能動態註冊
- Oracle 19C 監聽無法動態註冊例項Oracle
- Android廣播之靜態註冊Android
- Android中動態註冊Android
- vue動態註冊元件Vue元件
- 一次Oracle監聽無法動態註冊處理過程排查分析Oracle
- oracle靜態監聽Oracle
- js 註冊事件的兩種方式詳解,傳統註冊事件與方法監聽註冊事件(addEventListener)JS事件dev
- Nacos - 事件的註冊、取消與監聽(EventDispatcher)事件
- 實現Oracle非1521標準埠動態註冊Oracle
- Servlet – Upload、Download、Async、動態註冊Servlet
- ORACLE之手動註冊監聽listener。alter system set local_listener="XXX"Oracle
- vue 動態註冊路由 require.contextVue路由UIContext
- SpringBoot基礎篇Bean之動態註冊Spring BootBean
- 如何向Spring IOC 容器 動態註冊beanSpringBean
- spring動態註冊bean會使AOP失效?SpringBean
- 使用JavaScript給物件修改註冊監聽器JavaScript物件
- oracle 12c 新增的LREG程式及其動態註冊的過程Oracle
- SpringBoot中根據屬性動態註冊Spring BeanSpring BootBean
- @EnableDiscoveryClient與Nacos自動註冊client
- 自動註冊appleidAPP
- zabbix自動註冊
- [20190201]測試服務名支援靜態和動態註冊的情況下優先選擇那個.txt
- 原始碼分析 — Activity的清單註冊校驗及動態注入原始碼
- oracle 12c 資料庫例項監聽無法註冊問題一例Oracle資料庫
- springboot註冊Spring Boot
- Dubbo系列之 (二)Registry註冊中心-註冊(1)
- Dubbo系列之 (二)Registry註冊中心-註冊(2)
- 註冊中心 Eureka 原始碼解析 —— 應用例項註冊發現(一)之註冊原始碼
- 元件註冊與畫布渲染元件
- 【SpringBoot】服務對註冊中心的註冊時機Spring Boot
- 資料庫無法註冊至監聽服務解決辦法資料庫
- [20180509]配置靜態監聽服務與ORA-12514
- 【ASK_ORACLE】Oracle 12.2 Bug導致網路卡出現故障後RAC庫未向TCP註冊本地VIP監聽OracleTCP
- Oracle靜態監聽中SID_NAME區分大小寫嗎?Oracle
- VMware註冊碼
- winform註冊功能ORM