Linux and Oracle:用户环境变量设置不正确导致的“error while loading shared libraries: librt.so.1: cannot open shared object file”

By | 2014年9月3日

今天,在部署linux的时候遇到了如题所示的问题。
它发生的场景是:
操作系统:Red Hat Enterprise Linux 6.5 64bit

Error:
[root@zyposdb home]# su – oracle
[oracle@zyposdb ~]$ ls
ls: error while loading shared libraries: librt.so.1: cannot open shared object file: No such file or directory
[oracle@zyposdb ~]$

初看的时候会认为是缺少软件包,或者特定的软件包的安装不正确。
但事实上,这个问题的导致是:环境变量设置的不正确。

下面,完整的看看报错的发生起因以及解决方法:
错误:
[root@zyposdb home]# cat /home/oracle/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

# Oracle
export TMP=/tmp
export TMPDIR=$TMP
export ORACLE_BASE=/u01/app
export ORACLE_HOME=$ORACLE_BASE/product/10g/db_1
export ORACLE_SID=elis10
export ORACLE_TERM=xterm
export PATH=/usr/sbin:$PATH
export PATH=$ORACLE_HOME/bin:$PATH
export LD_LIBRARY_PATH=$ORACLE_HOME/lib:/lib64:/usr/lib64:/usr/local/lib64:/usr/X11R6/lib64/
export CLASSPATH=$ORACLE_HOME/JRE:$ORACLE_HOME/jlib:$ORACLE_HOME/rdbms/jlib
export LD_ASSUME_KERNEL=2.6.9
umask 022
[root@zyposdb home]#
[root@zyposdb home]# su – oracle
[oracle@zyposdb ~]$ ls
ls: error while loading shared libraries: librt.so.1: cannot open shared object file: No such file or directory
[oracle@zyposdb ~]$ env
env: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
[oracle@zyposdb ~]$ exit
logout
[root@zyposdb home]#
[root@zyposdb home]#

解法:
[root@zyposdb home]# cat /home/oracle/.bash_profile
# .bash_profile

# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi

# User specific environment and startup programs

PATH=$PATH:$HOME/bin

export PATH

# Oracle
ORACLE_SID=edendb1; export ORACLE_SID
ORACLE_UNQNAME=edendb; export ORACLE_UNQNAME
JAVA_HOME=/usr/local/java; export JAVA_HOME
ORACLE_BASE=/u01/app/oracle; export ORACLE_BASE
ORACLE_HOME=$ORACLE_BASE/product/10g/dbhome_1; export ORACLE_HOME
ORACLE_PATH=/u01/app/common/oracle/sql; export ORACLE_PATH
ORACLE_TERM=xterm; export ORACLE_TERM
NLS_DATE_FORMAT=”DD-MON-YYYY HH24:MI:SS”; export NLS_DATE_FORMAT
TNS_ADMIN=$ORACLE_HOME/network/admin; export TNS_ADMIN
ORA_NLS11=$ORACLE_HOME/nls/data; export ORA_NLS11

PATH=.:${JAVA_HOME}/bin:${PATH}:$HOME/bin:$ORACLE_HOME/bin
PATH=${PATH}:/usr/bin:/bin:/usr/bin/X11:/usr/local/bin
PATH=${PATH}:/u01/app/common/oracle/bin
export PATH

LD_LIBRARY_PATH=$ORACLE_HOME/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:$ORACLE_HOME/oracm/lib
LD_LIBRARY_PATH=${LD_LIBRARY_PATH}:/lib:/usr/lib:/usr/local/lib
export LD_LIBRARY_PATH

CLASSPATH=$ORACLE_HOME/JRE
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/rdbms/jlib
CLASSPATH=${CLASSPATH}:$ORACLE_HOME/network/jlib
export CLASSPATH

THREADS_FLAG=native; export THREADS_FLAG

export TEMP=/tmp
export TMPDIR=/tmp
[root@zyposdb home]# su – oracle
[oracle@zyposdb ~]$ ls
[oracle@zyposdb ~]$ pwd
/home/oracle
[oracle@zyposdb ~]$ env | grep BASE
ORACLE_BASE=/u01/app/oracle
[oracle@zyposdb ~]$

如上所示,问题被解决了。
在本例中出错的环境变量设定,在RHEL5的环境中是被测试过正确可用的,为何会在RHEL6中出现异常,需要更多的思考。
————————————————————————
Ending。

打赏

说点什么

avatar
  Subscribe  
提醒