欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  IT编程

oracle库文件解决办法badELFinterpreter:Nosuchfileordirectory

程序员文章站 2022-08-08 10:56:31
今天是2014-05-27,今天遇到一个lib问题,再次记录一下。这是一个案例,更是一种解决该问题的方法过程。 当我们在使用sqlplus 登陆unix的时候,有可能出现类&...

今天是2014-05-27,今天遇到一个lib问题,再次记录一下。这是一个案例,更是一种解决该问题的方法过程。

当我们在使用sqlplus 登陆unix的时候,有可能出现类似:xxxxxx bad elf interpreter: no such file or directory的问题。该问题的原因也是lib的问题。正常情况如下:

[root@dg1 ~]# su - oracle
[oracle@dg1 ~]$ ldd `which sqlplus`
        linux-vdso.so.1 =>  (0x00007fff2e5ff000)
        libsqlplus.so => /u01/app/oracle/product/11.2.0/dbhome_1/lib/libsqlplus.so (0x00007fba1fef6000)
        libclntsh.so.11.1 => /u01/app/oracle/product/11.2.0/dbhome_1/lib/libclntsh.so.11.1 (0x00007fba1d48b000)
        libnnz11.so => /u01/app/oracle/product/11.2.0/dbhome_1/lib/libnnz11.so (0x00007fba1d0be000)
        libdl.so.2 => /lib64/libdl.so.2 (0x0000003c93800000)
        libm.so.6 => /lib64/libm.so.6 (0x0000003c94400000)
        libpthread.so.0 => /lib64/libpthread.so.0 (0x0000003c94000000)
        libnsl.so.1 => /lib64/libnsl.so.1 (0x0000003ca3000000)
        libc.so.6 => /lib64/libc.so.6 (0x0000003c93c00000)
        libaio.so.1 => /lib64/libaio.so.1 (0x00007fba1cea4000)
        /lib64/ld-linux-x86-64.so.2 (0x0000003c93400000)
[oracle@dg1 ~]$ 

但有时候可能会缺失相应的lib文件。

那么对于该问题的解决思路是:

1、查看程序缺少的lib文件是那些

2、判断对应的lib文件时缺少还是环境变量问题。

3、如果是lib文件缺少那么需要安装对应的软件包或是复制对应的lib文件。如果是环境变量问题,那就需要更具不同设置不同的环境变量了。

另外对于oracle我们安装的32位的是lib32,是64位的那么是lib目录。

如下是我今天遇到的一个启动realsync的例子,其他程序类似:

启动realsync提示如下错误:

dsg@dg2 scripts]$ ./start
./start: /dsg/bin/archivelog: /lib/ld-linux.so.2: bad elf interpreter: no such file or directory
./start: /dsg/bin/archivelog: /lib/ld-linux.so.2: bad elf interpreter: no such file or directory
[dsg@dg2 scripts]$ ./stop
info: stop realsync normally...
info: stopping vagentd ...
info: stopping loader -s for fullsync loader ...
info: stopping loader -r for realsync loader ...
[dsg@dg2 scripts]$ 
[dsg@dg2 scripts]$ exit

那么对于ld-linux.so.2是对应的glibc.i686这个包。因此进行安装:如下:

[root@dg2 ~]# cd /media/ol6.4\ x86_64\ disc\ 1\ 20130225/packages/
[root@dg2 packages]# yum install glibc.i686
loaded plugins: refresh-packagekit, security
oel6                                                                                            | 3.7 kb     00:00 ... 
setting up install process
resolving dependencies
--> running transaction check
---> package glibc.i686 0:2.12-1.107.el6 will be installed
--> processing dependency: libfreebl3.so(nssrawhash_3.12.3) for package: glibc-2.12-1.107.el6.i686
--> processing dependency: libfreebl3.so for package: glibc-2.12-1.107.el6.i686
--> running transaction check
---> package nss-softokn-freebl.i686 0:3.12.9-11.el6 will be installed
--> finished dependency resolution

dependencies resolved

=======================================================================================================================
 package                             arch                  version                         repository             size
=======================================================================================================================
installing:
 glibc                               i686                  2.12-1.107.el6                  oel6                  4.3 m
installing for dependencies:
 nss-softokn-freebl                  i686                  3.12.9-11.el6                   oel6                  116 k

transaction summary
=======================================================================================================================
install       2 package(s)

total download size: 4.4 m
installed size: 13 m
is this ok [y/n]: y
downloading packages:
-----------------------------------------------------------------------------------------------------------------------
total                                                                                   60 mb/s | 4.4 mb     00:00     
running rpm_check_debug
running transaction test
transaction test succeeded
running transaction
warning: rpmdb altered outside of yum.
  installing : nss-softokn-freebl-3.12.9-11.el6.i686                                                               1/2 
  installing : glibc-2.12-1.107.el6.i686                                                                                                              2/2 
  verifying  : glibc-2.12-1.107.el6.i686                                                                                                              1/2 
  verifying  : nss-softokn-freebl-3.12.9-11.el6.i686                                                                                                  2/2 

installed:
  glibc.i686 0:2.12-1.107.el6                                                                                                                             

dependency installed:
  nss-softokn-freebl.i686 0:3.12.9-11.el6                                                                                                                 

complete!
[root@dg2 packages]# su - dsg
[dsg@dg2 bin]$ cd ../ ;cd scripts/;./start
dsg       4416  4391  0 11:48 pts/0    00:00:00 /dsg/bin/archivelog /dsg/log/log.vagentd /dsg/log/archivelog/log.vagentd_archlog 43200 5g
dsg       4426  4391  0 11:48 pts/0    00:00:00 /dsg/bin/archivelog /dsg/log/log.r0 /dsg/log/archivelog/log.r0_archlog 43200 5g
[dsg@dg2 scripts]$ 

这是没有错误提示,查看日志如下:

[dsg@dg2 log]$ tail -f log.vagentd 
/dsg/bin/vagentd: error while loading shared libraries: libclntsh.so.11.1: wrong elf class: elfclass64
tail: log.vagentd: file truncated

查看该程序的使用lib信息:

[dsg@dg2 scripts]$ cd ../bin
[dsg@dg2 bin]$ ldd vagentd
        linux-gate.so.1 =>  (0xf77a6000)
        libclntsh.so.11.1 => not found
        libnnz.so => not found
        libpthread.so.0 => /lib/libpthread.so.0 (0xf7773000)
        libcrypt.so.1 => /lib/libcrypt.so.1 (0xf7743000)
        libdl.so.2 => /lib/libdl.so.2 (0xf773d000)
        libm.so.6 => /lib/libm.so.6 (0xf7713000)
        librt.so.1 => /lib/librt.so.1 (0xf770a000)
        libc.so.6 => /lib/libc.so.6 (0x48cb8000)
        /lib/ld-linux.so.2 (0x48c96000)
        libfreebl3.so => /lib/libfreebl3.so (0xf76bb000)
[dsg@dg2 bin]$ 

可以知道目前有两个问题,一个是libnnz.so没有,另一个是libclntsh.so.11.1没有。需要做的是安装相应的软件包或是直接复制相应的lib文件到相应目录。
现在需要做的事是修改环境变量

[dsg@dg2 ~]$ more .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#######3333
export tmp=/tmp
export tmpdir=/tmp
export oracle_base=/u01/app/oracle
export oracle_sid=dg2
export oracle_home=/u01/app/oracle/product/11.2.0/dbhome_1
stty erase ^h
[dsg@dg2 ~]$ vi .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#######3333
export tmp=/tmp
export tmpdir=/tmp
export oracle_base=/u01/app/oracle
export oracle_sid=dg2
export oracle_home=/u01/app/oracle/product/11.2.0/dbhome_1
stty erase ^h
export ld_library_path=$oracle_home/lib32:/u01/app/oracle/product/11.2.0/dbhome_1/lib32

再次查看该所需程序lib文件信息:

[dsg@dg2 bin]$ ldd vagentd
        linux-gate.so.1 =>  (0xf77ef000)
        libclntsh.so.11.1 => /u01/app/oracle/product/11.2.0/dbhome_1/lib32/libclntsh.so.11.1 (0xf5af0000)
        libnnz.so => /u01/app/oracle/product/11.2.0/dbhome_1/lib32/libnnz.so (0xf58a3000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xf5871000)
        libcrypt.so.1 => /lib/libcrypt.so.1 (0xf5840000)
        libdl.so.2 => /lib/libdl.so.2 (0xf583b000)
        libm.so.6 => /lib/libm.so.6 (0xf5811000)
        librt.so.1 => /lib/librt.so.1 (0xf5808000)
        libc.so.6 => /lib/libc.so.6 (0x48cb8000)
        libnnz11.so => /u01/app/oracle/product/11.2.0/dbhome_1/lib32/libnnz11.so (0xf55ba000)
        libnsl.so.1 => /lib/libnsl.so.1 (0xf559f000)
        /lib/ld-linux.so.2 (0x48c96000)
        libaio.so.1 => not found
        libfreebl3.so => /lib/libfreebl3.so (0xf5550000)
[dsg@dg2 bin]$
那么需要安装libaio.so.1对应的软件包:
[root@dg2 packages]# yum install libaio-
libaio-0.3.107-10.el6.i686.rpm          libaio-0.3.107-10.el6.x86_64.rpm        libaio-devel-0.3.107-10.el6.i686.rpm    libaio-devel-0.3.107-10.el6.x86_64.rpm
[root@dg2 packages]# yum install libaio-0.3.107-10.el6.i686.rpm 
loaded plugins: refresh-packagekit, security
setting up install process
examining libaio-0.3.107-10.el6.i686.rpm: libaio-0.3.107-10.el6.i686
marking libaio-0.3.107-10.el6.i686.rpm to be installed
resolving dependencies
--> running transaction check
---> package libaio.i686 0:0.3.107-10.el6 will be installed
--> finished dependency resolution

dependencies resolved

=======================================================================================================================================================================
 package                          arch                           version                                   repository                                             size
=======================================================================================================================================================================
installing:
 libaio                           i686                           0.3.107-10.el6                            /libaio-0.3.107-10.el6.i686                            31 k

transaction summary
=======================================================================================================================================================================
install       1 package(s)

total size: 31 k
installed size: 31 k
is this ok [y/n]: y
downloading packages:
running rpm_check_debug
running transaction test
transaction test succeeded
running transaction
  installing : libaio-0.3.107-10.el6.i686                                                                                                                          1/1 
  verifying  : libaio-0.3.107-10.el6.i686                                                                                                                          1/1 

installed:
  libaio.i686 0:0.3.107-10.el6                                                                                                                                         

complete!
[root@dg2 packages]# 

再次查看:

[dsg@dg2 bin]$ ldd vagentd
        linux-gate.so.1 =>  (0xf772c000)
        libclntsh.so.11.1 => /u01/app/oracle/product/11.2.0/dbhome_1/lib32/libclntsh.so.11.1 (0xf5a2d000)
        libnnz.so => /u01/app/oracle/product/11.2.0/dbhome_1/lib32/libnnz.so (0xf57e0000)
        libpthread.so.0 => /lib/libpthread.so.0 (0xf57ae000)
        libcrypt.so.1 => /lib/libcrypt.so.1 (0xf577d000)
        libdl.so.2 => /lib/libdl.so.2 (0xf5778000)
        libm.so.6 => /lib/libm.so.6 (0xf574e000)
        librt.so.1 => /lib/librt.so.1 (0xf5745000)
        libc.so.6 => /lib/libc.so.6 (0x48cb8000)
        libnnz11.so => /u01/app/oracle/product/11.2.0/dbhome_1/lib32/libnnz11.so (0xf54f7000)
        libnsl.so.1 => /lib/libnsl.so.1 (0xf54dc000)
        libaio.so.1 => /lib/libaio.so.1 (0xf54da000)
        /lib/ld-linux.so.2 (0x48c96000)
        libfreebl3.so => /lib/libfreebl3.so (0xf548b000)
[dsg@dg2 bin]$ 

启动realsync:

[dsg@dg2 scripts]$ ./start
dsg       5203     1  0 12:04 pts/1    00:00:00 /dsg/bin/vagentd 50001
dsg       5204  5203  0 12:04 pts/1    00:00:00 /dsg/bin/vagentd 50001
dsg       5214     1  0 12:04 pts/1    00:00:00 /dsg/bin/loader -r -qno 0 1
dsg       5216  5214  0 12:04 pts/1    00:00:00 /dsg/bin/loader -r -qno 0 1
dsg       5213     1  0 12:04 pts/1    00:00:00 /dsg/bin/loader -s -qno 0 1
dsg       5215  5213  0 12:04 pts/1    00:00:00 /dsg/bin/loader -s -qno 0 1
dsg       5199  5174  0 12:04 pts/1    00:00:00 /dsg/bin/archivelog /dsg/log/log.vagentd /dsg/log/archivelog/log.vagentd_archlog 43200 5g
dsg       5208  5174  0 12:04 pts/1    00:00:00 /dsg/bin/archivelog /dsg/log/log.r0 /dsg/log/archivelog/log.r0_archlog 43200 5g
[dsg@dg2 scripts]$ 

至此问题得到解决: