最近在布置一个应用程序连接oracle后台数据库,数据库为oracle11g(11.2.0.2)。应用程序属于root用户,所以需要以root用户通过系统认证的方式连接数据库。设置了root用户的环境变量并将root用户加入了dba组中。但是在root用户中启动sqlplus连接数据库一直报

ERROR:
----------------
ORA-12547: TNS:lost contact
       起初以为是oracle_home目录的权限不够,给了最大的权限仍然报同样的错误。在root用户下通过网络服务名可以连接成功就是通过系统认证一直不成功,说明我的环境变量没有问题。通过一位朋友的帮助,查了oracle的maintant link。获取如下信息:

Symptoms

- Not able to make a local connection.
- Getting the following error when trying to connect to scott/tiger

ERROR:
----------------
ORA-12547: TNS:lost contact
 

Cause

1. This could be due to kernel parameters settings
2. Incorrect permissions on the ORACLE executable
 

Solution

To implement the solution, please execute the following steps:

1.
This could be due to kernel parameters settings
Please check the notes below that provide the required settings for kernel parameters
Note 169706.1 Oracle Database on AIX,HP-UX,Linux,MacOSX,Solaris,Tru64
Note 201021.1 SOLARIS: Quick Start Guide - 9.2.0 RDBMS Installation

2.
This could be due to Incorrect permissions on the ORACLE.exe
The 'ls' command should show permissions 6751 (as follows)

Please check the following:

$ cd $ORACLE_HOME/bin
$ ls -l oracle

The output should be
-rwsr-s--x 1 oracle dba

If not then please execute the following
$ chmod 6751 oracle

Please also verify if the following are correct

echo $ORACLE_HOME
echo $ORACLE_SID
echo $LD_LIBRARY_PATH
echo $PATH

3.
If the above does not resolve I suggest that you shutdown the database and listener and then
"relink all"
Note 131321.1 How to Relink Oracle Database Software on UNIX
 

根据提示查看系统的配置,内核参数是按照官方的说明进行配置应该没有问题可以排除。到第二个的时候发现$ORACLE_HOME/bin目录下的oracle程序权限有问题,修改为文档提示的权限后测试连接成功。原来是该脚本的权限不够导致该错误报错。