运行MongoDB 报错GLIBC_2.14 not found
Linux环境下安装完mongodb,运行./mongod报错如下
# ./mongod
./mongod: /lib64/libc.so.6: version `GLIBC_2.14' not found (required by ./mongod)
使用rpm -qa |grep glibc查看系统当前的glibc版本为2.12
使用如下命令查看系统glibc最高支持的版本为2.12
# strings /lib64/libc.so.6 |grep GLIBC_
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_PRIVATE
可以配置仓库用yum升级glibc rpm包(真的,还是用yum吧,省心,靠谱)。
这里使用源码包安装
(1)这里从http://ftp.acc.umu.se/mirror/gnu.org/gnu/libc/ 下载glibc-2.14.1.tar.gz,解压得到 glibc-2.14.1,然后创建build目录
-
-
# mkdir build
(2)运行configure配置,configure --prefix=<glibc-2.14.1 path>
# pwd
/usr/local/mongodb/glibc-2.14/glibc-2.14.1
# cd build/
# ../configure --prefix=/usr/local/mongodb/glibc-2.14/glibc-2.14.1
# ls -l
total 92
drwxr-xr-x. 2 root root 4096 Apr 3 11:30 bits
-rw-r--r--. 1 root root 7773 Apr 3 11:30 config.h
-rw-r--r--. 1 root root 37585 Apr 3 11:30 config.log
-rw-r--r--. 1 root root 3479 Apr 3 11:30 config.make
-rwxr-xr-x. 1 root root 32737 Apr 3 11:30 config.status
-rw-r--r--. 1 root root 568 Apr 3 11:30 Makefile
#
说明:如果在build/的上级目录执行./configure命令会报错,原因不知。。
configure: error: you must configure in a separate build directory
看到有的帖子在build/上上级目录执行也能成功
(3)运行make && make install
# make -j4
# make install
(4)临时修改环境变量 export LD_LIBRARY_PATH=<glibc-2.14.1 path>/lib:$LD_LIBRARY_PATH
# export LD_LIBRARY_PATH=/usr/local/mongodb/glibc-2.14/glibc-2.14.1/lib:$LD_LIBRARY_PATH
(5)将/lib64/libc.so.6 软链接到 glibc-2.14.1(高能预警!!!不要做这步操作,请跳至步骤7)
# rm -rf /lib64/libc.so.6
# ln -s /usr/local/mongodb/glibc-2.14/glibc-2.14.1/lib/libc-2.14.1.so /lib64/libc.so.6
# ls -l /lib64/libc.so.6
lrwxrwxrwx. 1 root root 61 Apr 3 03:45 /lib64/libc.so.6 -> /usr/local/mongodb/glibc-2.14/glibc-2.14.1/lib/libc-2.14.1.so
再次查看系统glibc最高支持的版本,为2.14
# strings /lib64/libc.so.6 |grep GLIBC_
GLIBC_2.2.5
GLIBC_2.2.6
GLIBC_2.3
GLIBC_2.3.2
GLIBC_2.3.3
GLIBC_2.3.4
GLIBC_2.4
GLIBC_2.5
GLIBC_2.6
GLIBC_2.7
GLIBC_2.8
GLIBC_2.9
GLIBC_2.10
GLIBC_2.11
GLIBC_2.12
GLIBC_2.13
GLIBC_2.14
GLIBC_PRIVATE
但是!但是!但是!
(6)打开新的连接登录这台机器失败,于是想去已有连接改一下密码,发现passwd不能用,报错如下
# passwd
passwd: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
想把libc.so.6链接回原来的文件,结果ln也不能用
# rm -rf /lib64/libc.so.6
# ln -s /lib64/libc-2.12.so /lib64/libc.so.6
ln: error while loading shared libraries: libc.so.6: cannot open shared object file: No such file or directory
很多命令不能用,恢复方法 => 执行
ldconfig -l -v /lib64/libc-2.12.so
(7)再来一遍软链接
cp /usr/local/mongodb/glibc-2.14/glibc-2.14.1/lib/libc-2.14.1.so /lib64/libc-2.14.1.so
rm -rf /lib64/libc.so.6
LD_PRELOAD=/lib64/libc-2.14.1.so ln -s /lib64/libc-2.14.1.so /lib64/libc.so.6
(8)这样做完之后看着没什么问题,但是打开新的连接登录这台机器,会打印
-bash: warning: setlocale: LC_CTYPE: cannot change locale (en_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_COLLATE: cannot change locale (en_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_MESSAGES: cannot change locale (en_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_NUMERIC: cannot change locale (en_US.UTF-8): No such file or directory
-bash: warning: setlocale: LC_TIME: cannot change locale (en_US.UTF-8): No such file or directory
执行locale命令,提示如下异常
# locale
locale: Cannot set LC_CTYPE to default locale: No such file or directory
locale: Cannot set LC_MESSAGES to default locale: No such file or directory
locale: Cannot set LC_ALL to default locale: No such file or directory
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
在/etc/sysconfig/i18n文件中,添加如下行
LC_ALL=C
export LC_ALL
执行 source /etc/sysconfig/i18n
说明:LC_ALL=C 是为了去除所有本地化的设置,让命令能正确执行。
打开新的连接登录这台机器,看着一切正常,暂时未发现其它异常。
————————————————
版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
原文链接:https://blog.csdn.net/wy_hhxx/article/details/105292096