GLIBC_PRIVATE not defined in file libc.so.6 with link time reference

自己在centos上想升级glib,下载源码make install之后,不能用,又yum install gettext,之后系统大部分命令都不能执行了,全部报这个错误:

lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference

比如grep:
grep: relocation error: /lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
mkdir: relocation error: /lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
/usr/bin/python3: relocation error: /lib64/libpthread.so.0: symbol __libc_dl_error_tsd, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference

ls,ps,grep这些基本命令都不能用了

貌似只有内核自带的命令能用,看起来是系统坏了

此时千万不要断开ssh连接(断开就连不上了,需要接触到服务器,才能进行后续补救的措施)
更不要重启,重启就开不开机了

先用head查看lib64里面现有版本有哪些:

head /usr/lib64/ld*.so
head /usr/lib64/libc-*

返回

==> /usr/lib64/ld-2.17.so <==
ELF>@
==> /usr/lib64/ld-2.25.so <==
ELF>�@�1
==> /usr/lib64/libc-2.17.so <==
ELF>`&@p� @8
==> /usr/lib64/libc-2.25.so <==
ELF> @ Û@8

说明存在2.25和2.17两个版本,由于我是相当于升级了ld版本,所以原来的是2.17

重新链接回到2.17版本,并测试ps能不能用:

sln /usr/lib64/ld-2.17.so /usr/lib64/ld-linux-x86-64.so.2
sln /usr/lib64/libc-2.17.so /usr/lib64/libc.so.6
ps
# 返回:
  PID TTY         TIME CMD
1 ? 14:01:50 systemd
2 ? 00:05:22 kthreadd
4 ? 00:00:00 kworker/0:0H
6 ? 01:53:51 ksoftirqd/0
7 ? 00:02:25 migration/0
8 ? 00:00:00 rcu_bh

到这里说明解决方案得到了验证,后续的测试发现python,sshd,supervisor还不能用,有报错:

/usr/bin/python3: relocation error: /lib64/libdl.so.2: symbol _dl_catch_error, version GLIBC_PRIVATE not defined in file libc.so.6 with link time reference
virtualenvwrapper.sh: There was a problem running the initialization hooks.

检查目录,看下在新增/usr/lib64/ld-2.25.so那个时间点,哪些文件链接被改变了,就改回去

$ ls -lh /lib64/| grep '14 10:58'
drwxr-xr-x. 2 root root 4.0K Aug 14 10:58 gettext
lrwxrwxrwx. 1 root root 20 Aug 14 10:58 libasprintf.so.0 -> libasprintf.so.0.0.0
lrwxrwxrwx. 1 root root 21 Aug 14 10:58 libcroco-0.6.so.3 -> libcroco-0.6.so.3.0.1
lrwxrwxrwx. 1 root root 21 Aug 14 10:58 libgettextpo.so.0 -> libgettextpo.so.0.5.4
lrwxrwxrwx. 1 root root 12 Aug 14 10:58 libm.so.6 -> libm-2.25.so

经过比对
后来又改回了这三个链接到2.17

sln /lib64/libdl-2.17.so /lib64/libdl.so.2
sln /lib64/libBrokenLocale-2.17.so /lib64/libBrokenLocale.so.1
sln /lib64/libm-2.17.so /lib64/libm.so.6

总结一共改回了这些,具体要根据自己的情况改

sln /usr/lib64/ld-2.17.so /usr/lib64/ld-linux-x86-64.so.2
sln /usr/lib64/libc-2.17.so /usr/lib64/libc.so.6
sln /lib64/libdl-2.17.so /lib64/libdl.so.2
sln /lib64/libBrokenLocale-2.17.so /lib64/libBrokenLocale.so.1
sln /lib64/libm-2.17.so /lib64/libm.so.6