【Oracle Database】数据库监听与连接
admin
2023-04-19 01:03:31
0
服务名  --根据业务需求修改
[oracle@wallet01 ~]$ sqlplus / as sysdba
SQL> show parameter service_names;
NAME                                 TYPE                              VALUE
------------------------------------ --------------------------------- ------------------------------
service_names                        string                            wallet

实例名  --允许修改不建议修改
SQL> show parameter instance_name

NAME                                 TYPE                              VALUE
------------------------------------ --------------------------------- ------------------------------
instance_name                        string                            wallet

数据库名 --不允许修改
SQL> show parameter db_name

NAME                                 TYPE                              VALUE
------------------------------------ --------------------------------- ------------------------------
db_name                              string                            wallet

监听器
[oracle@wallet01 ~]$ cd $ORACLE_HOME/network/admin
[oracle@wallet01 admin]$ cat listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
# Generated by Oracle configuration tools.
LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = wallet01)(PORT = 1521))  --协议,主机,端口
    )
  )
ADR_BASE_LISTENER = /u01/app/oracle

[oracle@wallet01 ~]$ lsnrctl start

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 09-MAY-2019 10:43:13

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

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

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=wallet01)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                09-MAY-2019 10:43:13
Uptime                    0 days 0 hr. 0 min. 5 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/wallet01/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=wallet01)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
The listener supports no services
The command completed successfully

[oracle@wallet01 ~]$ lsnrctl status

LSNRCTL for Linux: Version 11.2.0.4.0 - Production on 09-MAY-2019 10:44:44

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=wallet01)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 11.2.0.4.0 - Production
Start Date                09-MAY-2019 10:43:13
Uptime                    0 days 0 hr. 1 min. 31 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/11.2.0/db_1/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/wallet01/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=wallet01)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "wallet" has 1 instance(s).
  Instance "wallet", status READY, has 1 handler(s) for this service...
Service "walletXDB" has 1 instance(s).
  Instance "wallet", status READY, has 1 handler(s) for this service...
The command completed successfully

客户端(本地命名方式)
[oracle@wallet02 ~]$ cd $ORACLE_HOME/network/admin
[oracle@wallet02 admin]$ cat tnsnames.ora 
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/11.2.0/db_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

wallet =     --连接字符串(网络服务名)根据业务需求修改
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.1.201)(PORT = 1521))   --协议,主机,端口
    (CONNECT_DATA =
      (SERVER = DEDICATED)   --专用服务器模式
      (SERVICE_NAME = wallet)    --与服务名保持一致
    )
  )

[oracle@wallet02 ~]$ sqlplus sys/oracle@wallet as sysdba    --用户名/密码@连接字符串(网络服务名)

SQL*Plus: Release 11.2.0.4.0 Production on Fri Jun 29 10:06:52 2018

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

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

SQL> select * from dual;

DUM
---
X

总结:listener.ora文件中的协议,主机,端口,与通过PMON动态注册的服务名,
与tnsnames.ora文件中的协议,主机,端口,服务名需要保持一致,客户端才可以正常连接数据库服务器。



相关内容

热门资讯

苏州率先打造数据流通利用新范式 数据,作为第五大生产要素 具有流动性强、非消耗性、非均质性等特点 苏州率先打造数据流通利用新范式 夯...
伊媒披露伊美新一轮谈判5个先决... 当地时间5月12日,据伊朗法尔斯通讯社援引知情人士消息报道,伊朗对与美国新一轮谈判提出的5个先决条件...
英国将向霍尔木兹海峡多国护航行... 当地时间12日,总台记者从英国国防部获悉,英国将向在霍尔木兹海峡执行任务的多国护航行动提供无人机、战...
强化技术引领场景培育政策保障 ... 5月11日,省长叶建春就脑机接口技术与产业创新工作开展专题调研。他强调,脑机接口是培育未来产业发展新...
上海交大王如竹教授领衔撰写的“... 4月30日,国际制冷学会(IIR,International Institute of Refrig...
非人类身份蔓延:智能体AI真正... 长期以来,企业依赖服务账户、API密钥、OAuth令牌等各类非人类身份凭证,使不同服务能够在数字环境...
脑机接口“狂飙” 从病房走向多... (记者 陈锦锋)当大脑的神经信号能够直接与外部设备对话,“心想事成”便从科幻走向现实。近日,中南大学...
中巴外长通话,王毅:希望巴方保... 2026年5月12日晚,中共中央政治局委员、外交部长王毅同巴基斯坦副总理兼外长达尔通电话。达尔介绍了...
美参议院投票批准凯文·沃什出任... △凯文·沃什(资料图)当地时间5月12日,美国参议院投票批准凯文·沃什出任美联储主席,目前相关投票程...
缺油!日本快撑不住了 日本零食巨头卡乐比为节省油墨竟将原本漂亮的包装改成了黑白两色,从“喜食”变得看上去像“丧食”。日本石...