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

  2. 通过图形化添加

通过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,然后根据向导添加监听进程关联的数据库



相关推荐
奶糖趣多多1 小时前
Redis知识点
数据库·redis·缓存
CoderIsArt2 小时前
Redis的三种模式:主从模式,哨兵与集群模式
数据库·redis·缓存
师太,答应老衲吧4 小时前
SQL实战训练之,力扣:2020. 无流量的帐户数(递归)
数据库·sql·leetcode
Channing Lewis5 小时前
salesforce case可以新建一个roll up 字段,统计出这个case下的email数量吗
数据库·salesforce
毕业设计制作和分享6 小时前
ssm《数据库系统原理》课程平台的设计与实现+vue
前端·数据库·vue.js·oracle·mybatis
ketil276 小时前
Redis - String 字符串
数据库·redis·缓存
Hsu_kk7 小时前
MySQL 批量删除海量数据的几种方法
数据库·mysql
编程学无止境7 小时前
第02章 MySQL环境搭建
数据库·mysql
knight-n7 小时前
MYSQL库的操作
数据库·mysql
包饭厅咸鱼8 小时前
QML----复制指定下标的ListModel数据
开发语言·数据库