安装mongodb,参考https://blog.csdn.net/m0_62152730/article/details/124729384
在使用安装包安装完mongodb后启动时报错:
mongodb: error while loading shared libraries: libssl.so.1.1: cannot open shared object file: No such file or directory
提示找不到 libssl.so.1.1这个文件,找了半天后发现这个问题是ubuntu22 OpenSSL版本升级3.0造成的,解决办法如下:
第一步: 使用ldd命令查看mongodb缺少哪些依赖:
root@yingyou01:/home/software/mongodb/bin# ldd mongod
linux-vdso.so.1 (0x00007ffcfbfde000)
libcurl.so.4 => /lib/x86_64-linux-gnu/libcurl.so.4 (0x00007f221324b000)
liblzma.so.5 => /lib/x86_64-linux-gnu/liblzma.so.5 (0x00007f2213220000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f221320c000)
libcrypto.so.1.1 => not found
libssl.so.1.1 => not found
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f2213205000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f2213200000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f2213119000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f22130f9000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f22130f4000)
第二步:看到缺少libcrypto.so.1.1和libssl.so.1.1,通过下载openssl来下载对应的文件:
wget https://www.openssl.org/source/openssl-1.1.1o.tar.gz
第三步:编译安装
cd openssl-1.1.1o
./config
make
sudo make install
第四步:将缺少的依赖cp到/lib/x86_64-linux-gnu/目录下
cp ./libssl.so.1.1 /lib/x86_64-linux-gnu
cp ./libcrypto.so.1.1 /lib/x86_64-linux-gnu
再次尝试启动mongodb,启动成功
root@yingyou01:/home/software/mongodb/bin# ./mongod -config /home/software/mongodb/mongodb.conf
about to fork child process, waiting until server is ready for connections.
forked process: 2125940
child process started successfully, parent exiting