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



相关推荐
The_Ticker8 分钟前
CFD平台如何接入实时行情源
java·大数据·数据库·人工智能·算法·区块链·软件工程
Elastic 中国社区官方博客14 分钟前
Elasticsearch 开放推理 API 增加了对 IBM watsonx.ai Slate 嵌入模型的支持
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
企鹅侠客18 分钟前
ETCD调优
数据库·etcd
Json_1817901448024 分钟前
电商拍立淘按图搜索API接口系列,文档说明参考
前端·数据库
煎饼小狗36 分钟前
Redis五大基本类型——Zset有序集合命令详解(命令用法详解+思维导图详解)
数据库·redis·缓存
永乐春秋1 小时前
WEB-通用漏洞&SQL注入&CTF&二次&堆叠&DNS带外
数据库·sql
打鱼又晒网1 小时前
【MySQL】数据库精细化讲解:内置函数知识穿透与深度学习解析
数据库·mysql
王小小鸭2 小时前
【开发小技巧11】用经典报表实现badge list效果,根据回显内容用颜色加以区分
oracle·oracle apex
大白要努力!2 小时前
android 使用SQLiteOpenHelper 如何优化数据库的性能
android·数据库·oracle
tatasix2 小时前
MySQL UPDATE语句执行链路解析
数据库·mysql