1. 报错信息如下
cmd.PrepareSrc() connect Source database failed ORA-00000: DPI-1047: Cannot locate a 64-bit Oracle Client library: “libnsl.so.1: cannot open shared object file: No such file or directory”. See https://oracle.github.io/odpi/doc/installation.html#linux for help
cmd.PrepareSrc() connect Source database failed ORA-00000: DPI-1047: Cannot locate a 64-bit Oracle Client library: "libnsl.so.1: cannot open shared object file: No such file or directory". See https://oracle.github.io/odpi/doc/installation.html#linux for help
根据错误信息 DPI-1047: Cannot locate a 64-bit Oracle Client library: “libnsl.so.1” ,这是 Linux 环境下 Go 程序连接 Oracle 数据库时的常见依赖问题。
2. 解决方案
2.1. 安装缺失的系统库 libnsl
错误直接表明系统缺少 libnsl.so.1 动态库。执行以下命令安装:
CentOS/RHEL
sudo yum install libnsl
Ubuntu/Debian
sudo apt install libnsl2
验证是否安装成功:
ldconfig -p | grep libnsl.so.1
若输出类似 libnsl.so.1 (libc6,x86-64) 即表示成功 。

2.2. 添加库路径到系统配置
创建配置文件:
说明 /XXXX/instantclient 为 OracleSync2MySQL解压出来的instantclient 路径
若没有该目录,需要自行到下载 Instant Client
从 Oracle官网 下载 64位 Basic 包(如 instantclient-basic-linux.x64-21.x.x.x.zip )。
解压并放置到拥有权限的目录
/XXXX/instantclient 改为解压并放置的目录
sudo sh -c "echo '/XXXX/instantclient' > /etc/ld.so.conf.d/oracle-instantclient.conf"
刷新动态链接库缓存
sudo ldconfig
2.3. 置环境变量
sudo vim /etc/profile
增加
export LD_LIBRARY_PATH=/XXXX/instantclient:$LD_LIBRARY_PATH
刷新环境变量
source /etc/profile
2.4. 验证库依赖完整性
检查 Instant Client 的依赖是否满足:
cd /XXXX/instantclient
查看是否有 “not found” 的依赖项
ldd libclntsh.so
若输出中无缺失项(如 libnsl.so.1 => found),则环境配置正确



4688

被折叠的 条评论
为什么被折叠?



