社区微信群开通啦,扫一扫抢先加入社区官方微信群
社区微信群
从官网下载instantclient-basic和instantclient-sdk压缩包,并解压到/usr/lib/目录
unzip instantclient-basic-linux.x64-12.2.0.1.0.zip
unzip instantclient-sdk-linux.x64-12.2.0.1.0.zip
cd instantclient_12_2/
mv instantclient_12_2/ /usr/lib
创建软链接
ln -s /usr/lib/instantclient_12_2/libclntsh.so.12.1 /usr/lib/libclntsh.so
ln -s /usr/lib/instantclient_12_2/libocci.so.12.1 /usr/lib/libocci.so
ln -s /usr/lib/instantclient_12_2/libociei.so /usr/lib/libociei.so
ln -s /usr/lib/instantclient_12_2/libnnz12.so /usr/lib/libnnz12.so
安装相关依赖
yum -y install pkgconfig libaio
配置oci8动态链接库路径
ldconfig命令的用途主要是在默认搜寻目录/lib和/usr/lib以及动态库配置文件/etc/ld.so.conf内所列的目录下,搜索出可共享的动态链接库(格式如lib*.so*),进而创建出动态装入程序(ld.so)所需的连接和缓存文件。缓存文件默认为/etc/ld.so.cache,此文件保存已排好序的动态链接库名字列表,为了让动态链接库为系统所共享,需运行动态链接库的管理命令ldconfig,此执行程序存放在/sbin目录下。
echo ‘/usr/lib/instantclient_12_2’ >> /etc/ld.so.conf
配置oci8.pc配置文件
vim /usr/lib64/pkgconfig/oci8.pc
prefix=/usr/lib/instantclient_12_2
libdir=${prefix}
includedir=${prefix}/sdk/include/
Name: OCI
Description: Oracle database engine
Version: 12.2
Libs: -L${libdir} -lclntsh
Libs.private:
Cflags: -I${includedir}
添加环境变量
export PKG_CONFIG_PATH=/usr/lib64/pkgconfig
export ORACLE_HOME=/usr/lib/instantclient_12_2
export LD_LIBRARY_PATH=$ORACLE_HOME
pkg-config这一工具是用来检索系统中安装库文件的信息。其主要功能如下:
检查库的版本号。如果所需要的库的版本不满足要求,它会打印出错误信息,避免链接错误版本的库文件。
–exists,可以用来测试模块的可用性。
$ pkg-config --exists oci8||echo no
显示 no 说明pkg-config 没有找到相应的 oci8.pc
报错1:
/usr/bin/ld: warning: libaio.so.1, needed by /usr/lib/gcc/x86_64-redhat-linux/4.8.5/…/…/…/libclntsh.so, not found (try using -rpath or -rpath-link)
解决方法:
yum -y install libaio
报错2:
/usr/bin/ld: warning: libmql1.so, needed by /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../libclntsh.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libipc1.so, needed by /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../libclntsh.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libons.so, needed by /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../libclntsh.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libaio.so.1, needed by /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../libclntsh.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: warning: libclntshcore.so.12.1, needed by /usr/lib/gcc/x86_64-redhat-linux/4.8.5/../../../libclntsh.so, not found (try using -rpath or -rpath-link)
。。。等等一大堆报错信息
解决方法:
echo ‘/usr/lib/instantclient_12_2’ >> /etc/ld.so.conf
如果觉得我的文章对您有用,请随意打赏。你的支持将鼓励我继续创作!