本帖最后由 lins 于 2023-12-13 11:33 编辑
## Question
```shell
TNS-12541: TNS:no listener
TNS-12560: TNS:protocol adapter error
TNS-00511: No listener
Linux Error: 111: Connection refused
```
## Resolve
- 切换用户
```shell
[root@dbserver ~]# su - oracle
[oracle@dbserver ~]$
```
- 切换环境变量 `
```shell
[oracle@dbserver ~]$ . oraenv
ORACLE_SID = [orcl] ? orcl
The Oracle base remains unchanged with value /u01/app/oracle
```
- 登录数据库
```shell
[oracle@dbserver ~]$ sqlplus / as sysdba
SQL*Plus: Release 19.0.0.0.0 - Production on Wed Dec
Version 19.21.0.0.0
Copyright (c) 1982, 2022, Oracle. All rights reserved.
Connected to:
Oracle Database 19c Standard Edition 2 Release 19.0.0.0.0 - Production
Version 19.21.0.0.0
```
- 显示服务名
```shell
SYS@orcl >show parameter service_names;
NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
service_names string orcl
```
- 强制注册服务
```shell
SYS@orcl >alter system register;
System altered.
```
- 查看监听状态
```shell
[oracle@dbserver ~]$ lsnrctl status listener
LSNRCTL for Linux: Version 19.0.0.0.0 - Production on
Copyright (c) 1991, 2023, Oracle. All rights reserved.
Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=dbserver)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias LISTENER
Version TNSLSNR for Linux: Version 19.0.0.0.0 - Production
Start Date
Uptime 0 days 0 hr. 50 min. 42 sec
Trace Level off
Security ON: Local OS Authentication
SNMP OFF
Listener Parameter File /u01/app/oracle/product/19.21/db_1/network/admin/listener.ora
Listener Log File /u01/app/oracle/diag/tnslsnr/dbserver/listener/alert/log.xml
Listening Endpoints Summary...
(DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=dbserver)(PORT=1521)))
(DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "0c4b59438c6b17f3e0637885a8c04522" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
Service "86b637b62fdf7a65e053f706e80a27ca" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
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...
Service "pdb" has 1 instance(s).
Instance "orcl", status READY, has 1 handler(s) for this service...
The command completed successfully
```
http://bbs.cqsztech.com/forum.php?mod=attachment&aid=NDU0NnwxZmMyM2I2M2VkOWY2ODhlM2Q4YmJjOTZlYzI1NzkyMHwxNzMwNDIwMTcz&request=yes&_f=.pdf
|