修改服務端監聽器埠號為1526

skyin_1603發表於2016-11-03
----修改服務端監聽的埠號為1526:

--配置服務端listener.ora檔案:
[oracle@enmo admin]$ vi listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LSNR2 =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = enmo)(PORT = 1526))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1526))
    )
  )
  
--配置服務端tnsnames.ora檔案:
[oracle@enmo admin]$ vi tnsnames.ora 
LSNR2 =
    (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = enmo)(PORT = 1526))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1526))
    )
  )
~

--修改服務端的預設監聽:
SQL> alter system set local_listener='LSNR2';
System altered.

--啟動埠號為1526的監聽:
[oracle@enmo admin]$ lsnrctl
LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 03-NOV-2016 23:31:36
Copyright (c) 1991, 2013, Oracle.  All rights reserved.
Welcome to LSNRCTL, type "help" for information.
LSNRCTL> 
LSNRCTL> start lsnr2
Starting /u01/app/oracle/product/11.2.0/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/dbhome_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/enmo/lsnr2/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=enmo.oracle.com)(PORT=1526)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1526)))


Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=enmo)(PORT=1526)))
STATUS of the LISTENER
------------------------
Alias                     lsnr2
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                03-NOV-2016 23:31:54
Uptime                    0 days 0 hr. 0 min. 1 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/enmo/lsnr2/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=enmo.oracle.com)(PORT=1526)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1526)))
The listener supports no services
The command completed successfully
LSNRCTL> 

--主動註冊資料庫到監聽器:
SQL> alter system register;
System altered.

--再次檢視監聽的狀態:
LSNRCTL> status lsnr2
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=enmo)(PORT=1526)))
STATUS of the LISTENER
------------------------
Alias                     lsnr2
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                03-NOV-2016 23:31:54
Uptime                    0 days 0 hr. 1 min. 44 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/enmo/lsnr2/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=enmo.oracle.com)(PORT=1526)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1526)))
Services Summary...
Service "PROD" has 1 instance(s).
  Instance "PROD", status READY, has 1 handler(s) for this service...
Service "PRODXDB" has 1 instance(s).
  Instance "PROD", status READY, has 1 handler(s) for this service...
The command completed successfully
LSNRCTL> 
#看到埠號為1526的監聽器正常工作。

--客戶端配置tnsnames.ora檔案:
[oracle@host01 admin]$ vi tnsnames.ora 
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.
ORA11 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.6)(PORT = 1526))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = PROD)
    )
  )
  
--嘗試使用連線串tnsping通服務端:
 [oracle@host01 admin]$ tnsping ora11

TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 03-NOV-2016 23:36:33
Copyright (c) 1997, 2013, Oracle.  All rights reserved.

Used parameter files:
/u01/app/oracle/product/11.2.0/dbhome_1/network/admin/sqlnet.ora

Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.2.6)(PORT = 1526)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = PROD)))
OK (0 msec)
[oracle@host01 admin]$ 
[oracle@host01 admin]$ 

--嘗試連線服務端資料庫PROD庫:
[oracle@host01 admin]$ sqlplus sys/oracle@ora11 as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Thu Nov 3 23:37:52 2016
Copyright (c) 1982, 2013, 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

SQL> show parameter service
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      PROD
SQL> 

--在Windows使用EZCONNECT連線:
C:\Users\Asus>
C:\Users\Asus>sqlplus sys/oracle@192.168.2.6:1526/PROD as sysdba
SQL*Plus: Release 11.2.0.1.0 Production on 星期四 11月 3 23:40:45 2016
Copyright (c) 1982, 2010, Oracle.  All rights reserved.

連線到:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show parameter service
NAME                                 TYPE
------------------------------------ ----------------------
VALUE
------------------------------
service_names                        string
PROD
SQL>
修改成功。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/31392094/viewspace-2127791/,如需轉載,請註明出處,否則將追究法律責任。

相關文章