首页 > 其他分享 >默认及非默认端口的动态监听/静态监听实验汇总

默认及非默认端口的动态监听/静态监听实验汇总

时间:2023-07-24 21:07:11浏览次数:37  
标签:DESCRIPTION 端口 bys 默认 bys3 listener ADDRESS 监听 ora


步骤大致是:
实验1.配置一个非默认和默认的动态监听同时存在,非默认监听运行在1525端口
实验2:配置一个非默认端口的动态监听--使用local_listener=的值服务器端的tnsnames.ora里的本地名的方法
实验3.配置一个静态监听,运行在1526端口

数据库内一些参数:
SYS@ bys3>show parameter service
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
service_names                        string      bys3
SYS@ bys3>show parameter db_na
NAME                                TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_name                              string      bys3
SYS@ bys3>show parameter db_unique
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_unique_name                       string      bys3
SYS@ bys3>show parameter db_domain
NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_domain                            string
SYS@ bys3>show parameter instance_na

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
instance_name                        string      bys3
关于这几个参数的设置及替换,详见:ORACLE监听之动态监听与静态监听特点

配置默认监听加非默认动态监听示例

1.配置listener.ora,增加非默认动态监听的地址、端口条目

[oracle@bys3 admin]$ more 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.

 LISTENER =

   (DESCRIPTION_LIST =

     (DESCRIPTION =

       (ADDRESS = (PROTOCOL = TCP)(HOST = bys3.bys.com)(PORT = 1525))

       (ADDRESS = (PROTOCOL = TCP)(HOST = bys3.bys.com)(PORT = 1521))

     )

   )

 ADR_BASE_LISTENER = /u01



2.在数据库中配置 local_listener参数,语句如下:--就是把listener.ora中的几行复制过来,注意换行的括号不要少了。

alter system set local_listener='(
DESCRIPTION =

       (ADDRESS = (PROTOCOL = TCP)(HOST = bys3.bys.com)(PORT = 1525))

       (ADDRESS = (PROTOCOL = TCP)(HOST = bys3.bys.com)(PORT = 1521)))';

 SYS@ bys3>alter system register;  --手动注册,或者等上一分钟,让PMON自动进行动态监听注册。


因为这里是local_listener的值是两行ADDRESS,要把DESCRIPTION =也加上。如果是一行,不需要加。如:alter system set local_listener='(ADDRESS = (PROTOCOL = TCP)(HOST = bys3.bys.com)(PORT = 1525))';


3.查看监听状态,动态监听已经注册成功:


[oracle@bys3 ~]$ lsnrctl status

 LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 14-JAN-2014 22:20:16

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

 Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bys3.bys.com)(PORT=1525)))

 STATUS of the LISTENER

 ------------------------

 Alias                     LISTENER

 Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production

 Start Date                14-JAN-2014 22:02:22

 Uptime                    0 days 0 hr. 17 min. 54 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/diag/tnslsnr/bys3/listener/alert/log.xml

 Listening Endpoints Summary...

   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=bys3.bys.com)(PORT=1525)))

   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=bys3.bys.com)(PORT=1521)))

 Services Summary...

 Service "bys3" has 1 instance(s).

   Instance "bys3", status READY, has 1 handler(s) for this service...

 The command completed successfully


4.使用SQLPLUS进行登陆测试:
 [oracle@bys3 admin]$ cat tnsnames.ora 

 bys3 =

   (DESCRIPTION =

     (ADDRESS = (PROTOCOL = TCP)(HOST = bys3.bys.com)(PORT =1521))

     (CONNECT_DATA =

       (SERVER = DEDICATED)

       (SERVICE_NAME = bys3)

     )

   )

test =

   (DESCRIPTION =

     (ADDRESS = (PROTOCOL = TCP)(HOST = bys3.bys.com)
(PORT =1525))

     (CONNECT_DATA =

       (SERVER = DEDICATED)

       (SERVICE_NAME = bys3)

     )

   )

[oracle@bys3 admin]$ tnsping test

 TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 14-JAN-2014 22:30:42

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

 Used parameter files:

 Used TNSNAMES adapter to resolve the alias

 Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = bys3.bys.com
)(PORT =1525)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = bys3)))

OK (0 msec)

 [oracle@bys3 admin]$ tnsping bys3

 TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 14-JAN-2014 22:30:46

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

 Used parameter files:

 Used TNSNAMES adapter to resolve the alias

Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = bys3.bys.com)(PORT =1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = bys3)))
 OK (10 msec)

 [oracle@bys3 admin]$ sqlplus bys/bys@bys3

 SQL*Plus: Release 11.2.0.4.0 Production on Tue Jan 14 22:32:02 2014

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

 Connected to:

 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production

 With the Partitioning, OLAP, Data Mining and Real Application Testing options

BYS@ bys3>exit


[oracle@bys3 admin]$ sqlplus bys/bys@test
 BYS@ test>exit

 ###################################################


配置单一一个非默认监听的示例:--参数local_listener值改为tnsnames.ora中的本地名
 

1.需要把非默认的监听器添加到listener.ora:
 [oracle@bys3 admin]$ cat listener.ora

 LISTENER =

   (DESCRIPTION_LIST =

     (DESCRIPTION =

       (ADDRESS = (PROTOCOL = TCP)(HOST = bys3.bys.com)(PORT = 1529))

     )

   )

   

2.服务器端的tnsnames.ora里添加:
 [oracle@bys3 admin]$ cat tnsnames.ora

 hello =

   (DESCRIPTION =

     (ADDRESS = (PROTOCOL = TCP)(HOST = bys3.bys.com)(PORT =1529))

     (CONNECT_DATA =

       (SERVER = DEDICATED)

       (SERVICE_NAME = hello)

     )

   )

 在这个实验中,local_listener='hello';这样配置时,tnsnames.ora中 (SERVICE_NAME = hello)这一行是无效的,也就是不会应用这个服务名。。  sqlplus aa/bb@hello  这样用本地名连接时,当然会用到了。


3.修改local_listener=的值为服务器端的tnsnames.ora里的本地名
 SYS@ bys3>alter system set local_listener='hello';

 System altered.

 SYS@ bys3>show parameter local_l

 NAME                                 TYPE        VALUE

 ------------------------------------ ----------- ------------------------------

local_listener                       string      hello

 
注意注意:如果在配置好之后,tnsnames.ora里内容发生了变化,hello =本地名被删改了总之是找不到这个字段,重启数据库会报错:

ORA-00119: invalid specification for system parameter LOCAL_LISTENER

 ORA-00132: syntax error or unresolved network name 'aa'

 但是如果数据库未重启,而删除tnsnames.ora或hello =本地名的字段是没影响的,应该是信息已经加载到内存了。


4.重启监听后查看监听状态:  --这里的服务名还是来自数据库参数service_names
 [oracle@bys3 admin]$ lsnrctl status

 LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 17-JAN-2014 13:53:14

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

 Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bys3.bys.com)(PORT=1529)))

 STATUS of the LISTENER

 ------------------------

 Alias                     LISTENER

 Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production

 Start Date                17-JAN-2014 13:51:10

 Uptime                    0 days 0 hr. 2 min. 4 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/diag/tnslsnr/bys3/listener/alert/log.xml

 Listening Endpoints Summary...

   (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=bys3.bys.com)(PORT=1529)))

 Services Summary...

Service "bys3" has 1 instance(s).
   Instance "bys3", status READY, has 1 handler(s) for this service...

 The command completed successfully

 #################

配置静态监听:
1.配置listener.ora,增加相应条目
 [oracle@bys3 admin]$ cat 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.


 LISTENER =

   (DESCRIPTION_LIST =

     (DESCRIPTION =

       (ADDRESS = (PROTOCOL = TCP)(HOST = bys3.bys.com)(PORT = 1525))

       (ADDRESS = (PROTOCOL = TCP)(HOST = bys3.bys.com)(PORT = 1521))

     )

   )


l3 =
   (DESCRIPTION_LIST =
     (DESCRIPTION =
       (ADDRESS = (PROTOCOL = TCP)(HOST = bys3.bys.com)(PORT = 1526))
     )
   )
 SID_LIST_l3=
   (SID_LIST= 
    (SID_DESC=
    (GLOBAL_DBNAME=bys9)
     (SID_NAME=bys3)
     (ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1)))
 ADR_BASE_LISTENER = /u01

2.启动监听,查看状态:

[oracle@bys3 ~]$

lsnrctl status l3


LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 14-JAN-2014 22:19:49


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


Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=bys3.bys.com)(PORT=1526)))


STATUS of the LISTENER


------------------------


Alias                     l3


Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production


Start Date                14-JAN-2014 22:15:15


Uptime                    0 days 0 hr. 4 min. 34 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/diag/tnslsnr/bys3/l3/alert/log.xml


Listening Endpoints Summary...


  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=bys3.bys.com)(PORT=1526)))


Services Summary...


Service "bys9" has 1 instance(s).

  Instance "bys3", status UNKNOWN, has 1 handler(s) for this service...

The command completed successfully


#################


3.使用SQLPLUS进行登陆测试

[oracle@bys3 admin]$ cat tnsnames.ora 

test9 =

   (DESCRIPTION =

     (ADDRESS = (PROTOCOL = TCP)(HOST 
= bys3.bys.com)(PORT =1526))

     (CONNECT_DATA =

       (SERVER = DEDICATED)

       (SERVICE_NAME = bys9)

         )

   )

 [oracle@bys3 ~]$
 tnsping test9

 TNS Ping Utility for Linux: Version 11.2.0.4.0 - Production on 14-JAN-2014 22:37:56

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

 Used parameter files:

 Used TNSNAMES adapter to resolve the alias

 Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = bys3.bys.com
)(PORT =1526))(CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = bys9)))

OK (10 msec)

 [oracle@bys3 ~]$
 sqlplus bys/bys@test9

 SQL*Plus: Release 11.2.0.4.0 Production on Tue Jan 14 22:38:05 2014

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

 Connected to:

 Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - Production

With the Partitioning, OLAP, Data Mining and Real Application Testing options
 BYS@ test9>

标签:DESCRIPTION,端口,bys,默认,bys3,listener,ADDRESS,监听,ora
From: https://blog.51cto.com/u_1652968/6839146

相关文章

  • HTTP请求时哪些请求头是默认携带的?
    提起HTTP的请求头和响应头总是一头雾水,因为总是看上去一大堆,好多还不知道是什么意思。今天我们先研究请求头,我就想,如果我们能弄清楚,在我们什么都不做的情况下,一个最简单的HTTP请求会携带哪些请求头,那么复杂的情况无非是在这上面做加法,我们对请求头就能做到心中有数了。我从以下4......
  • Tool-Gitlab-502-端口占用
    安装Gitlab后,登陆报错502,端口占用卸载一、卸载GitLab及其依赖1、首先停止GitLab的运行命令:sudogitlab-ctlstop2、卸载GitLab:sudoapt-getremovegitlab-ce3、卸载GitLab依赖:sudoapt-getautoremove-y4、移除GitLab相关的文件:sudorm-rf/opt/gitlabtail日志sud......
  • 端口未被占用,但是却提示端口无法使用
    端口未被占用,但是却提示端口无法使用​#问题记录#​环境:Windows10问题如下:Anattemptwasmadetoaccessasocketinawayforbiddenbyitsaccesspermissions。1.通过netstat-aon|findstr“3306”​并没有看到端口占用2.通过netshintipv4showdynamicporttcp......
  • 怎么在MYSQL显示默认值
    项目方案:在MySQL中显示默认值1.简介在MySQL中,可以为表的列设置默认值,以确保在插入新记录时,如果没有提供该列的值,将使用默认值作为替代。本项目旨在提供一个方案,用于在MySQL中显示默认值。2.实现方案2.1创建表格首先,我们需要创建一个包含默认值的表格。可以使用以下代码在My......
  • 怎么关闭windwos的mysql端口
    如何关闭Windows的MySQL端口MySQL是一个常用的关系型数据库管理系统。通常情况下,MySQL使用默认的端口号3306来监听客户端连接请求。然而,在某些情况下,您可能希望关闭MySQL的端口,例如在进行一些网络安全配置或调试时。本文将介绍如何在Windows操作系统上关闭MySQL的端口。方案概述......
  • Spring管理事务默认回滚的异常是什么?
    问题:Spring管理事务默认(即没有rollBackFor的情况下)可以回滚的异常是什么? 回答:RuntimeException或者Error。抛出运行时异常,是否回滚?Yes@TransactionalpublicbooleanrollbackOn(Throwableex){returnnewRuntimeException();}抛出错误,是否回滚? Yes@Transact......
  • docker 对外开放端口
    Docker对外开放端口的步骤概述在使用Docker部署应用时,有时候需要将容器内部的某个端口对外开放,以便能够通过网络访问该端口。本文将介绍如何在Docker中实现对外开放端口的操作步骤,并给出相应的代码示例。步骤下面是实现Docker对外开放端口的步骤,以及每一步所需要做的操......
  • minipc使用frp端口映射
    参考官网文档使用frp配置内网访问宝塔面板部署frp内网穿透FRP内网穿透实战使用场景之前购买的云服务器硬盘比较小,很快满了,加上希望将数据放本地服务器。故此某宝买了minipc,安装了Ubuntuserver。以下使用腾讯云轻量服务器centos安装frps,本地minipc系统Ubuntu安装frpc,记录......
  • linux 开放端口
    参照  https://www.dbs724.com/149223.html 这篇文章,做个笔记1、使用系统命令检查主机是否运行了防火墙,可以使用如下命令:systemctlstatusfirewalld  在查看到active(running)的状态之后,即表示主机上已经运行了防火墙服务。2.如果防火墙服务正常运行,执行以下命......
  • python+playwright 学习-68 事件监听console 内容
    前言playwright可以通过page.on()监听console内容console事件当我们打开百度页面,f12打开控制台,会看到console输出的内容playwright可以通过page.on()监听console,获取到console的内容page.on()监听示例代码fromplaywright.sync_apiimportsync_playwright"......