創(chuàng)建偵聽(tīng)器
偵聽(tīng)器在listener.ora文件中定義,這個(gè)文件的默認(rèn)存儲(chǔ)位置為ORACLE_HOME/network/admin目錄。listener.ora文件至少必須聲明一個(gè)偵聽(tīng)器的名稱(chēng)及其使用的協(xié)議與偵聽(tīng)地址??梢栽谝粋€(gè)文件中配置多個(gè)偵聽(tīng)器,不過(guò)這些偵聽(tīng)器必須具有不同的名稱(chēng)與地址。
與其他用于配置Oracle Net 的文件一樣,listener.ora文件非常在意看似很小的語(yǔ)法問(wèn)題。
[oracle@localhost admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
ADR_BASE_LISTENER = /u01/app/oracle
[oracle@localhost admin]$ vi ./listener.ora
[oracle@localhost admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1521))
)
ADR_BASE_LISTENER = /u01/app/oracle
WYH =
(DESCRIPTION =
(ADDRESS_LIST =
(ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1522))
)
)
[oracle@localhost admin]$
數(shù)據(jù)庫(kù)注冊(cè)
向數(shù)據(jù)庫(kù)注冊(cè)實(shí)例的方法有靜態(tài)注冊(cè)和動(dòng)態(tài)注冊(cè)兩種。對(duì)于靜態(tài)注冊(cè)來(lái)說(shuō),我們可以將一列實(shí)例硬編碼在listener.ora文件中。動(dòng)態(tài)注冊(cè)意味著實(shí)例在啟動(dòng)時(shí)需要定位偵聽(tīng)器并注冊(cè)到偵聽(tīng)器中。
1、靜態(tài)注冊(cè)
在listener.ora文件中添加條目
SID_LIST_WYH =
(SID_LIST =
(SID_DESC =
(ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1)
(SID_NAME = orcl)
)
)
測(cè)試靜態(tài)注冊(cè)
[oracle@localhost admin]$ lsnrctl
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 14-APR-2016 11:17:49
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> start WYH
Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/wyh/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1522)))
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias WYH
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 14-APR-2016 11:17:58
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/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/wyh/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1522)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL>
2、動(dòng)態(tài)測(cè)試
初始化參數(shù)local_listener會(huì)告知實(shí)例其應(yīng)當(dāng)進(jìn)行聯(lián)系的,從而能夠查找到注冊(cè)實(shí)例的偵聽(tīng)器的網(wǎng)絡(luò)地址。在啟動(dòng)實(shí)例時(shí),PMON進(jìn)程會(huì)使用該參數(shù)來(lái)定位一個(gè)偵聽(tīng)器,并向其通知實(shí)例名稱(chēng)以及實(shí)例提供的服務(wù)名稱(chēng)。
[oracle@localhost admin]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 14 12:12:37 2016
Copyright (c) 1982, 2011, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora'
ORACLE instance started.
Total System Global Area 1436389376 bytes
Fixed Size 2228384 bytes
Variable Size 855641952 bytes
Database Buffers 570425344 bytes
Redo Buffers 8093696 bytes
Database mounted.
Database opened.
SQL> alter system register ;
System altered.
SQL> ho lsnrctl
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 14-APR-2016 12:14:17
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
LSNRCTL> start
Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 14-APR-2016 12:14:38
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/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
The listener supports no services
The command completed successfully
LSNRCTL> start
TNS-01106: Listener using listener name LISTENER has already been started
LSNRCTL> status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 14-APR-2016 12:14:38
Uptime 0 days 0 hr. 0 min. 43 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL>
[oracle@localhost admin]$ sqlplus /nolog
SQL*Plus: Release 11.2.0.3.0 Production on Thu Apr 14 12:12:37 2016
Copyright (c) 1982, 2011, Oracle. All rights reserved.
SQL> conn / as sysdba
Connected to an idle instance.
SQL> startup pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora'
ORACLE instance started.
Total System Global Area 1436389376 bytes
Fixed Size 2228384 bytes
Variable Size 855641952 bytes
Database Buffers 570425344 bytes
Redo Buffers 8093696 bytes
Database mounted.
Database opened.
SQL> alter system register ;
System altered.
SQL> ho lsnrctl
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 14-APR-2016 12:14:17
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
LSNRCTL> start
Starting /u01/app/oracle/product/11.2.0/db_1/bin/tnslsnr: please wait...
TNSLSNR for Linux: Version 11.2.0.3.0 - Production
System parameter file is /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 14-APR-2016 12:14:38
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/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
The listener supports no services
The command completed successfully
LSNRCTL> start
TNS-01106: Listener using listener name LISTENER has already been started
LSNRCTL> status
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 14-APR-2016 12:14:38
Uptime 0 days 0 hr. 0 min. 43 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
Services Summary...
Service "orcl" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL>
LSNRCTL>
LSNRCTL> exit
SQL> alter system set local_listener='(address=(pro=tcp)(host=localhost.localdomain)(port=1522))';
System altered.
SQL> ho lsnrctl
LSNRCTL for Linux: Version 11.2.0.3.0 - Production on 14-APR-2016 12:20:35
Copyright (c) 1991, 2011, Oracle. All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> stop
Connecting to (ADDRESS=(PROTOCOL=tcp)(HOST=)(PORT=1521))
The command completed successfully
LSNRCTL> start WYH
TNS-01106: Listener using listener name WYH has already been started
LSNRCTL> status
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost.localdomain)(PORT=1522)))
STATUS of the LISTENER
------------------------
Alias WYH
Version TNSLSNR for Linux: Version 11.2.0.3.0 - Production
Start Date 14-APR-2016 11:23:13
Uptime 0 days 0 hr. 58 min. 5 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/wyh/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1522)))
Services Summary...
Service "orcl" has 2 instance(s).
Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orclXDB" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL>
LSNRCTL> exit
SQL>
SQL>
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORA-00119: invalid specification for system parameter LOCAL_LISTENER
ORA-00132: syntax error or unresolved network name '((ADDRESS_LIST= (ADDRESS = (PROTOCOL = TCP)(HOST = localhost.localdomain)(PORT = 1522)))'
SQL> startup pfile='/u01/app/oracle/product/11.2.0/db_1/dbs/initorcl.ora'
ORACLE instance started.
Total System Global Area 1436389376 bytes
Fixed Size 2228384 bytes
Variable Size 855641952 bytes
Database Buffers 570425344 bytes
Redo Buffers 8093696 bytes
Database mounted.
Database opened.
SQL> create spfile from pfile ;
File created.
SQL>
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 1436389376 bytes
Fixed Size 2228384 bytes
Variable Size 855641952 bytes
Database Buffers 570425344 bytes
Redo Buffers 8093696 bytes
Database mounted.
Database opened.
SQL> create pfile from spfile ;
File created.
SQL>
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)cdcxhl.cn,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線(xiàn),公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性?xún)r(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專(zhuān)為企業(yè)上云打造定制,能夠滿(mǎn)足用戶(hù)豐富、多元化的應(yīng)用場(chǎng)景需求。