oracle19c 静态监听配置
时间: 2023-07-04 13:08:42 浏览: 177
配置oracle监听
4星 · 用户满意度95%
1. 确认Oracle数据库版本:可以通过以下命令查看:
```
$ sqlplus / as sysdba
SQL> select banner from v$version where rownum=1;
```
2. 创建监听文件:在Oracle安装目录下的`NETWORK/ADMIN`目录中创建`listener.ora`文件,内容如下:
```
LISTENER =
(DESCRIPTION_LIST =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 主机名或IP地址)(PORT = 监听端口号))
)
)
```
其中,主机名或IP地址为数据库服务器的主机名或IP地址,监听端口号一般为`1521`。
3. 修改`tnsnames.ora`文件:在同一目录下的`tnsnames.ora`文件中增加以下内容:
```
SERVICE_NAME =
(DESCRIPTION =
(ADDRESS = (PROTOCOL = TCP)(HOST = 主机名或IP地址)(PORT = 监听端口号))
(CONNECT_DATA =
(SERVER = DEDICATED)
(SERVICE_NAME = 数据库实例名)
)
)
```
其中,主机名或IP地址和监听端口号与`listener.ora`中一致,数据库实例名为Oracle数据库实例的名称。
4. 启动监听:执行以下命令启动监听:
```
$ lsnrctl start
```
如果监听已经启动,可以使用以下命令重新加载监听配置文件:
```
$ lsnrctl reload
```
5. 验证监听是否正常工作:执行以下命令验证监听是否正常工作:
```
$ lsnrctl status
```
如果监听正常工作,将输出类似以下内容:
```
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=localhost)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date 19-JUL-2021 10:56:11
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/19.0.0/dbhome_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/localhost/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=localhost)(PORT=1521)))
Services Summary...
Service "ORCLCDB" has 1 instance(s).
Instance "ORCLCDB", status READY, has 1 handler(s) for this service...
Service "ORCLPDB1" has 1 instance(s).
Instance "ORCLCDB", status READY, has 1 handler(s) for this service...
The command completed successfully
```
其中,`Services Summary...`部分列出了Oracle数据库实例的服务名称,如果显示了正确的服务名称,则说明监听正常工作。
阅读全文