Linux下配置Oracle 监听

时间:2021-07-12 01:38:26

1. 修改监听器配置文件

Linux下Oracle监听器配置文件在:$ ORACLE_HOME/network/admin/listerer.ora, 如:
 /bank/oracle/oracle10g/product/10.2.0/network/admin/listener.ora
 
修改并配置要监听SID的相关信息,如:

#listener.ora Network Configuration File: /bank/oracle/oracle10g/product/10.2.0/network/admin/listener.ora
# Generated by Oracle configuration tools.

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = PLSExtProc)
      (ORACLE_HOME = /bank/oracle/oracle10g/product/10.2.0)
      (PROGRAM = extproc)
    )

    (SID_DESC =
      (GLOBAL DBNAME = bkserver)
      (SID_NAME = bkserver)
    )

  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.19.213)(PORT =1521))
    )
  )
 
2. 启动监听器

(1). 切换至oracle安装用户(一般为oracle)
su - oracle  

(2). 启动监听器
lsnrctl start  

另:停止监听器
lsnrctl stop

3. 测试监听器是否运行正常

在客户端修改tnsnames.ora配置文件就访问Oracle数据库,如:

BKSERVER =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.19.213)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = BKSERVER)
    )
  )
 
通过命令tnsping测试是否能访问到监听器,如:

M:\>tnsping bkserver

TNS Ping Utility for 32-bit Windows: Version 10.2.0.1.0 - Production on 12-8月 -
2010 17:11:04

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

已使用的参数文件:
D:\oracle\product\10.2.0\client_1\network\admin\sqlnet.ora


已使用 TNSNAMES 适配器来解析别名
Attempting to contact (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)
(HOST = 10.7.13.242)(PORT = 1521))) (CONNECT_DATA = (SERVER = DEDICATED) (SERVIC
E_NAME = BKSERVER)))
OK (20 毫秒)

注意: 监听器是否能被tnsping通跟数据库的开启/关闭无关,所以就算可以tnsping通监听器但未必能连接到数据库,这时请检查listener.ora文件配置信息是否正确,还有数据库是否已经被开启。

关闭服务端的防火墙。