OCP-042之:Oracle网络服务

2. Oracle网络服务

2.1 默认监听进程

如果客户端想要连接数据库并管理数据库,需要在服务器端开启监听服务,默认监听的进程LISTENER:

[oracle@ora-server ~]$ cd $ORACLE_HOME/network/admin
[oracle@ora-server admin]$ ll
total 16
-rw-r-----. 1 oracle oinstall  334 Nov 16 16:16 listener.ora
drwxr-xr-x. 2 oracle oinstall   64 Nov 15 15:17 samples
-rw-r--r--. 1 oracle oinstall 1441 Aug 28  2015 shrept.lst
-rw-r-----. 1 oracle oinstall  198 Nov 16 16:16 sqlnet.ora
-rw-r-----. 1 oracle oinstall  406 Nov 16 16:18 tnsnames.ora

[oracle@ora-server admin]$ vim listener.ora 
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = ora-server)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

默认监听进程的管理

[oracle@ora-server admin]$ lsnrctl status	

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 18-NOV-2022 15:16:03

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora-server)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                17-NOV-2022 09:30:59
Uptime                    1 days 5 hr. 45 min. 4 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/ora-server/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora-server)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=ora-server)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/admin/orcl/xdb_wallet))(Presentation=HTTP)(Session=RAW))
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

[oracle@ora-server admin]$ lsnrctl stop

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 18-NOV-2022 15:16:59

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora-server)(PORT=1521)))
The command completed successfully
[oracle@ora-server admin]$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 18-NOV-2022 15:17:05

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora-server)(PORT=1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 111: Connection refused
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=EXTPROC1521)))
TNS-12541: TNS:no listener
 TNS-12560: TNS:protocol adapter error
  TNS-00511: No listener
   Linux Error: 2: No such file or directory

[oracle@ora-server admin]$ lsnrctl start

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 18-NOV-2022 15:17:19

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

Starting /u01/app/oracle/product/12.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/12.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/ora-server/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora-server)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=ora-server)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                18-NOV-2022 15:17:19
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/12.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/ora-server/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=ora-server)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

web监控页面登陆:

先安装Flash插件,然后使用浏览器输入https://192.168.100.19:5500/em

在这里插入图片描述
在这里插入图片描述

Oracle SQL Developer数据库连接:

在这里插入图片描述

2.2 自定义监听进程

我们要连接Oracle数据库,需要知道三要素:服务器IP、端口号和库名

通常的做法是,不使用默认的监听进程,而创建一个自定义进程,然后把数据库指定给这个进程,这样可以实现不同的库使用不同的监听进程

  1. 通过修改配置的方式创建进程:
[oracle@ora-server admin]$ vim listener.ora 

# 定义监听进程
L1 =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.19.130)(PORT = 10000))
    )
  )

# 定义数据库映射
SID_LIST_L1 =
   (SID_LIST =
      (SID_DESC =
         (GLOBAL_DBNAME = orcl)
         (ORACLE_HOME = /u01/app/oracle/product/12.2.0/db_1)
         (SID_NAME = orcl)
      )
   )

[oracle@ora-server admin]$ lsnrctl start L1

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 18-NOV-2022 15:20:39

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

Starting /u01/app/oracle/product/12.2.0/db_1/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/12.2.0/db_1/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/ora-server/l1/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.19.130)(PORT=10000)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC10000)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.19.130)(PORT=10000)))
STATUS of the LISTENER
------------------------
Alias                     L1
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                18-NOV-2022 15:20:39
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/12.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/ora-server/l1/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=192.168.19.130)(PORT=10000)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC10000)))
Services Summary...
Service "orcl" has 1 instance(s).
  Instance "orcl", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully

  1. 通过图形化添加

通过Oracle登陆操作系统图形化界面,调出终端,输入netca,进入导航

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

完成后系统会直接将监听进程启动起来

Oracle Net Services Configuration:
Configuring Listener:L2
Listener configuration complete.
Oracle Net Listener Startup:
    Running Listener Control: 
      /u01/app/oracle/product/12.2.0/db_1/bin/lsnrctl start L2
    Listener Control complete.
    Listener started successfully.
Oracle Net Services configuration successful. The exit code is 0

在终端中输入netmgr,然后根据向导添加监听进程关联的数据库

在这里插入图片描述
在这里插入图片描述
在这里插入图片描述

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

-风中叮铃-

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值