ERROR:ORA-12543: TNS:destination host unreachable

环境ORACLE Linux8(其他环境也可以参考这个步骤)

1.测试使用TNSNAMES tnsping无法连接到主机

[oracle@dguard2 admin]$ tnsping dguard

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 11-JUL-2022 10:03:44

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

Used parameter files:
/u01/app/oracle/product/19.3.0/dbhome_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.43.92)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = dguard)))
TNS-12543: TNS:destination host unreachable

2.查看主机是否可以Ping 通,结果是可以PING 通

[oracle@dguard2 admin]$ ping 192.168.43.92
PING 192.168.43.92 (192.168.43.92) 56(84) bytes of data.
64 bytes from 192.168.43.92: icmp_seq=1 ttl=64 time=0.530 ms
64 bytes from 192.168.43.92: icmp_seq=2 ttl=64 time=0.431 ms
64 bytes from 192.168.43.92: icmp_seq=3 ttl=64 time=0.408 ms
64 bytes from 192.168.43.92: icmp_seq=4 ttl=64 time=0.255 ms
^C
--- 192.168.43.92 ping statistics ---
4 packets transmitted, 4 received, 0% packet loss, time 3108ms
rtt min/avg/max/mdev = 0.255/0.406/0.530/0.098 ms
[oracle@dguard2 admin]$
 

3.直接使用IP连接数据库看看是否可以链接,如果这样可以连接可能是TNS设置问题。结果是同样报ORA-12543
[oracle@dguard2 ~]$ sqlplus sys/[email protected]:1521/dguard

SQL*Plus: Release 19.0.0.0.0 - Production on Mon Jul 11 10:06:54 2022
Version 19.3.0.0.0

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

ERROR:
ORA-12543: TNS:destination host unreachable

4.查看是否SQLNET配置问题,SQLNET包含了所有可以使用的方式,不是SQLNET问题[oracle@dguard admin]$ cat sqlnet.ora
# sqlnet.ora Network Configuration File: /u01/app/oracle/product/19.3.0/dbhome_1/network/admin/sqlnet.ora
# Generated by Oracle configuration tools.

NAMES.DIRECTORY_PATH= (TNSNAMES, ONAMES, HOSTNAME)


5.查看是否Oralce相应端口未开放,结果是LISTNER 正在1521监听TCP协议的连接

[root@dguard ~]# netstat  -anop |grep 1521
tcp        0      0 192.168.43.92:1521      0.0.0.0:*               LISTEN      3599/tnslsnr         off (0.00/0/0)
unix  2      [ ACC ]     STREAM     LISTENING     53432    3599/tnslsnr         /var/tmp/.oracle/sEXTPROC1521
[root@dguard ~]#

6.查看防火墙状态,防火墙状态为开启状态
[root@dguard init.d]# systemctl status firewalld.service

● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: active (running) since Mon 2022-07-11 09:44:32 CST; 29min ago
     Docs: man:firewalld(1)
 Main PID: 987 (firewalld)
    Tasks: 2 (limit: 22958)
   Memory: 30.9M
   CGroup: /system.slice/firewalld.service
           └─987 /usr/libexec/platform-python -s /usr/sbin/firewalld --nofork --nopid

Jul 11 09:44:31 dguard systemd[1]: Starting firewalld - dynamic firewall daemon...
Jul 11 09:44:32 dguard systemd[1]: Started firewalld - dynamic firewall daemon.
Jul 11 09:44:33 dguard firewalld[987]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will be removed in a future release. Please consider d>

7.关闭防火墙并检查状态
[root@dguard init.d]# systemctl stop firewalld.service
[root@dguard init.d]# systemctl status firewalld.service

● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; enabled; vendor preset: enabled)
   Active: inactive (dead) since Mon 2022-07-11 10:14:07 CST; 9s ago
     Docs: man:firewalld(1)
  Process: 987 ExecStart=/usr/sbin/firewalld --nofork --nopid $FIREWALLD_ARGS (code=exited, status=0/SUCCESS)
 Main PID: 987 (code=exited, status=0/SUCCESS)

Jul 11 09:44:31 dguard systemd[1]: Starting firewalld - dynamic firewall daemon...
Jul 11 09:44:32 dguard systemd[1]: Started firewalld - dynamic firewall daemon.
Jul 11 09:44:33 dguard firewalld[987]: WARNING: AllowZoneDrifting is enabled. This is considered an insecure configuration option. It will be removed in a future release. Please consider d>
Jul 11 10:14:07 dguard systemd[1]: Stopping firewalld - dynamic firewall daemon...
Jul 11 10:14:07 dguard systemd[1]: firewalld.service: Succeeded.
Jul 11 10:14:07 dguard systemd[1]: Stopped firewalld - dynamic firewall daemon.
lines 1-13/13 (END)

8.TNSPING 看看是或否可以连接,结果是可以正常的TNSPING 数据库了

[oracle@dguard2 admin]$ tnsping dguard

TNS Ping Utility for Linux: Version 19.0.0.0.0 - Production on 11-JUL-2022 10:19:41

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

Used parameter files:
/u01/app/oracle/product/19.3.0/dbhome_1/network/admin/sqlnet.ora


Used TNSNAMES adapter to resolve the alias
Attempting to contact (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.43.92)(PORT = 1521)) (CONNECT_DATA = (SERVER = DEDICATED) (SERVICE_NAME = dguard)))
OK (10 msec)


 

你可能感兴趣的:(oracle,数据库)