MongoDB在openssl@1.1上无法正常工作
背景 – 背景情景
在将openssl升级到1.1版本后,MongoDB停止运行。↓出现了以下错误。
$ mongod --version
dyld: Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /usr/local/opt/mongodb@3.2/bin/mongod
Reason: image not found
为了确认,检查当前已安装的openssl。
$ brew list openssl
...
...
...
/usr/local/Cellar/openssl@1.1/1.1.1d/lib/libssl.1.1.dylib
...
...
...
解决方案 ‘àn)
這個問題有兩個解決方法。
第一個是降低 OpenSSL 的版本。
第二個是升級 MongoDB 的版本。
降级OpenSSL版本
brew update && brew upgrade
brew uninstall --ignore-dependencies openssl;brew uninstall --ignore-dependencies openssl;brew install https://github.com/tebelorg/Tump/releases/download/v1.0.0/openssl.rb
确认版本已降级
$ brew list openssl
...
...
...
/usr/local/Cellar/openssl/1.0.2t/lib/libcrypto.1.0.0.dylib
...
...
...
确认MongoDB的版本
$ mongod --version
db version v3.2.21
git version: 1ab1010737145ba3761318508ff65ba74dfe8155
OpenSSL version: OpenSSL 1.0.2t 10 Sep 2019
allocator: system
modules: none
build environment:
distarch: x86_64
target_arch: x86_64
升级MongoDB版本的方法2
确认版本为OpenSSL 1.1
$ brew list openssl
...
...
...
/usr/local/Cellar/openssl@1.1/1.1.1d/lib/libcrypto.1.1.dylib
...
...
...
如果不是的话,请执行brew install openssl@1.1。
$ brew upgrade mongodb
Error: No available formula with the name "mongodb"
哎呀,听说从Homebrew Core中移除了MongoDB,所以无法升级MongoDB的版本了呢。。。
不过,这样问题就解决了!太棒了!!
$ brew tap mongodb/brew
$ brew install mongodb-community@4.2
请注意:如果不更改现有的MongoDB路径,它无法正常运行!!所以,请在~/.zshrc文件中(我的情况下),将export PATH=”/usr/local/opt/mongodb-community@4.2/bin:$PATH” 进行修改。
确认MongoDB的版本
$ mongod --version
db version v4.2.2
git version: a0bbbff6ada159e19298d37946ac8dc4b497eadf
allocator: system
modules: none
build environment:
distarch: x86_64
target_arch: x86_64
我能确认版本已经成功升级了!
印象
降低openssl版本后,仍可以使用MongoDB,但与openssl相关的库会出现相同的dyld: Library not loaded错误。
所以,我认为方法2的处理是合理的。