sqlplus / as sysdba 连接数据库报错:ORA-12547: TNS:lost contact
案例概要:
一套19c RAC的准生产环境,今天用sqlplus / as sysdba登录数据库时,竟然报错ORA-12547: TNS:lost contact. 简要记录下可能的原因。
处理过程:
1、检查当前的环境变量。 $ORACLE_BASE, $ORACLE_HOME, $ORACLE_SID. 这三个环境变量的设置都是正确的。
2、检查oracle执行文件的权限及所组。
| [oracle@ynuyktdb1 ~]$ ll $ORACLE_HOME/bin/oracle -rwsr-s--x 1 oracle asmadmin 460668032 Mar 8 12:14 /u01/app/oracle/product/19.0.0/dbhome_1/bin/oracle [grid@ynuyktdb1 ~]$ ll $ORACLE_HOME/bin/oracle -rwsr-s--x 1 grid oinstall 438006280 Mar 8 12:18 /u01/app/19.0.0/grid/bin/oracle |
oracle执行文件的权限及所组一切正常。
3、检查ulimits,发现oracle用户的open files是默认值1024,重新设置/etc/security/limits.conf文件,将open files设置成65536,并使其生效。 但故障依旧,说明不是open files太小所导致。
4、使用strace命令跟踪了sqlplus报错的整个过程,但未找到具体原因。
| $ truss -aefo sqlplus.trc $ORACLE_HOME/bin/sqlplus / as sysdba - OR - $ strace -f -o sqlplus.trc $ORACLE_HOME/bin/sqlplus / as sysdba |
5、查询MOS文档,发现ORA-12547相关的案例非常多,得慢慢排查了。
6、此时,负责这套数据库安装部署的同事反馈,前段时间删除、添加过数据库资源。会不会是因为添加资源时,导致了该故障?同时还提示看看MOS文章《Sqlplus Reports ORA-12547 TNSlost contact But SRVCTL Shows Database Running (Doc ID 2975749.1)》
7、检查发现果真是该问题,在向OCR中添加数据库资源时,给ORACLE_HOME多写了个斜杠 /.
解决办法:
修改OCR中的数据库资源信息。
| srvctl modify database -d DB_UNIQUE_NAME-o /u01/app/oracle/product/19.0.0/dbhome_1 srvctl stop database -d DB_UNIQUE_NAME srvctl start database -d DB_UNIQUE_NAME sqlplus / as sysdba |
总结:
可能会导致ORA-12547: TNS:lost contact的原因非常多,我查阅了相关的MOS文章,对该故障的原因作了整理:
| 1. kernel parameters settings 2. Incorrect permissions on the ORACLE executable 3. Check config.o is 0 bytes 4. The stack limit is set too low. 5. The ulimit settings for 'open files' is very low. 6. ORACLE_BASE is not set. 7. ORACLE_HOME and ORACLE_SID is incorrect. 8. extra "/" is added at the end of environment variables. like: "ORACLE_HOME=/oracle/<PATH>/1930/" 9. If there are inconsistencies between id -a and /etc/group. 10. If there are unaccessible files on /tmp/oracle or /tmp/.oracle 11. If /etc/hosts are configured expectedly. 12. Environment variable EXTSHM is set to ON in the environment. 13. The $ORACLE_HOME directory, in the OS /etc/fstab configuration file has specified the nosuid option. 14. Dynatrace agent installed a library in /etc folder called ld.so.preload. 15. Oracle binaries have not been linked correctly. 16. A missing $ORACLE_HOME/dbs directory. 17. A missing libaio package. 18. Incorrect configuration for Oracle home in OCR, Database home added wrongly , Extra / at the end. |
浙公网安备 33010602011771号