Oracle修改数据库监听的端口号

Oracle修改数据库监听的端口号

先停止监听

[oracle@oracle admin]$ lsnrctl stop

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 06-MAY-2018 16:09:51

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
The command completed successfully

修改listener.ora配置文件,将端口号1521修改为1526

[oracle@oracle admin]$ cat listener.ora
# listener.ora Network Configuration File: /oracle/11g/product/11.2.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.101)(PORT = 1526))
    )
  )

ADR_BASE_LISTENER = /oracle/11g


SID_LIST_LISTENER =
    (SID_LIST =
        (SID_DESC =
            (GLOBAL_DBNAME = orcl1)
            (ORACLE_HOME = /oracle/11g/product/11.2.0/dbhome_1)
            (SID_NAME =orcl)
        )
    )

登录并修改local_listener参数

[oracle@oracle admin]$ sqlplus / as sysdba

SQL> show parameter local_listener;             ##查出来应该是空值

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string

##修改参数
SQL> alter system set local_listener="(address = (protocol = tcp)(host = 10.10.10.101)(port = 1526))";

System altered.

SQL> show parameter local_listener;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
local_listener                       string      (address = (protocol = tcp)(ho
                                                 st = 10.10.10.101)(port = 1526
                                                 ))

启动监听,查看状态

[oracle@oracle admin]$ lsnrctl start

[oracle@oracle admin]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.1.0 - Production on 06-MAY-2018 16:17:17

Copyright (c) 1991, 2009, Oracle.  All rights reserved.

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.1.0 - Production
Start Date                06-MAY-2018 16:16:21
Uptime                    0 days 0 hr. 0 min. 56 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /oracle/11g/product/11.2.0/dbhome_1/network/admin/listener.ora
Listener Log File         /oracle/11g/diag/tnslsnr/oracle/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.10.10.101)(PORT=1526)))       ##修改成了1526
Services Summary...
Service "oracle.orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
Service "orcl1" has 1 instance(s).
  Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
Service "orclXDB.orcl" has 1 instance(s).
  Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully

检查端口

[oracle@oracle admin]$ netstat -tlunp |grep 1521                            ##1521不存在了
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
[oracle@oracle admin]$
[oracle@oracle admin]$ netstat -tlunp |grep 1526                            ##改到1526上了
(Not all processes could be identified, non-owned process info
will not be shown, you would have to be root to see it all.)
tcp        0      0 10.10.10.101:1526       0.0.0.0:*               LISTEN      21080/tnslsnr      

远程连接,注意方通1526端口的防火墙限制

[oracle@mysql-master-1003306 admin]$ cat tnsnames.ora

orcl1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.10.10.101)(PORT = 1526))             ##这里端口写1526
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = orcl1)
    )
  )

[oracle@mysql-master-1003306 admin]$ tnsping orcl1

TNS Ping Utility for Linux: Version 11.2.0.1.0 - Production on 07-MAY-2018 02:13:36

Copyright (c) 1997, 2009, Oracle.  All rights reserved.

Used parameter files:
/oracle/11g/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 = 10.10.10.101)(PORT = 1526)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = orcl1)))
OK (10 msec)                                    ##tnsping 结果为OK


[oracle@mysql-master-1003306 admin]$ sqlplus  sys/Oracle_1@orcl1 as sysdba              ##连接成功

SQL*Plus: Release 11.2.0.1.0 Production on Mon May 7 02:15:02 2018

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options   

转载请注明来源,欢迎对文章中的引用来源进行考证,欢迎指出任何有错误或不够清晰的表达。可以在下面评论区评论,也可以邮件至 289211569@qq.com