1、报错信息:
-
ERROR:
-
ORA-12547: TNS:lost contact
2、产生该报错的情形
非oracle用户使用sqlplus username/password 后面不使用tnsname.ora 文件中连接字符串的名称时报错:ORA-12547: TNS:lost contact
3、解决方法:
第一步:查看$ORACLE_HOME/bin/oracle的权限:
-
ll $ORACLE_HOME/bin/oracle
-
-rwxr-x--x 1 oracle oinstall 239626731 Apr 6 14:22 /oracle/product/11.2.0/bin/oracle
第二步:修改oracle的权限为6751默认权限:
-
chmod 6751 $ORACLE_HOME/bin/oracle
-
-rwsr-s--x 1 oracle oinstall 239626731 Apr 6 14:22 /oracle/product/11.2.0/bin/oracle
参考网址:
http://www.uncletoo.com/html/oracle/295.html
实验模拟:
1、以mth用户登录系统,使用DB 账号mth以下面的方式连接数据库。
-
[mth@TaylonMeng ~]$ sqlplus mth/mth
-
-
SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 22 22:40:23 2016
-
-
Copyright (c) 1982, 2013, Oracle. All rights reserved.
-
-
ERROR:
-
ORA-12547: TNS:lost contact
-
[mth@TaylonMeng ~]$ sqlplus mth/mth@MTH
-
-
SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 22 22:43:52 2016
-
-
Copyright (c) 1982, 2013, Oracle. All rights reserved.
-
-
-
Connected to:
-
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
-
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-
-
SQL>
可以看到,使用
sqlplus mth/mth@MTH 这种方式就可以连接,但是
sqlplus mth/mth这种会报错。
2、查看$ORACLE_HOME/bin/oracle该执行文件的权限
-
[oracle@TaylonMeng ~]$ ll $ORACLE_HOME/bin/oracle
-
-rwxr-x--x 1 oracle oinstall 239626731 Mar 16 23:16 /oracle/product/11.2.0/bin/oracle
看到该执行文件的权限被修改了,导致非oracle账号在执行该文件时,无法获得oracle账号的权限,因此会报错。
3、修改
$ORACLE_HOME/bin/oracle的权限为默认的6751.
-
[oracle@TaylonMeng ~]$ chmod 6751 /oracle/product/11.2.0/bin/oracle
-
[oracle@TaylonMeng ~]$ ll $ORACLE_HOME/bin/oracle
-
-rwsr-s--x 1 oracle oinstall 239626731 Mar 16 23:16 /oracle/product/11.2.0/bin/oracle
-rwsr-s--x中的“s”,具有如下的限制和功能:
-
SUID 权限仅对二进制程序(binary program)有效;
-
运行者对于该程序需要具有 x 的可运行权限;
-
本权限仅在运行该程序的过程中有效 (run-time);
-
运行者将具有该程序拥有者 (owner) 的权限。
-
[mth@TaylonMeng ~]$ sqlplus mth/mth
-
-
SQL*Plus: Release 11.2.0.4.0 Production on Wed Jun 22 23:07:27 2016
-
-
Copyright (c) 1982, 2013, Oracle. All rights reserved.
-
-
-
Connected to:
-
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
-
With the Partitioning, OLAP, Data Mining and Real Application Testing options
-
-
SQL>
权限修改后,再通过这种方式连接,就不会有报错了。
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/30776559/viewspace-2120766/
,如需转载,请注明出处,否则将追究法律责任。