centos7 安装mongo ./mongod: error while loading shared libraries: libnetsnmpmibs.so.31:

入坑两次:第二次几近崩溃,容我吐槽一下,以表明治。。

问题是这:

NETWORK  [thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
./mongod: error while loading shared libraries: libnetsnmpmibs.so.31: cannot open shared object file: No such file or directory


第一次是2018年2月3号;今天是2018年4月24,时隔近3个月,由于ECS到期要迭代原因,所有东西重装,两次都是tar.gz安装mongo, data目录db与logs/mongodb.log已创建好,mongo.conf如下

# 设置数据文件的存放目录
dbpath = /alex/data/mongo/mongo3.2.15/data/db
# 设置日志文件的存放目录及其日志文件名
logpath = /alex/data/mongo/mongo3.2.15/data/logs/mongodb.log
# 设置端口号(默认的端口号是 27017)
port = 27017 
# 设置为以守护进程的方式运行,即在后台运行
fork = true
# nohttpinterface = true
nohttpinterface = true
#登录验证
#noauth=false


问题开始出现~2:

操作步骤:1

[root@alex /alex/data/mongo/mongo3.2.15/bin]$ ./mongo
MongoDB shell version: 3.2.15
connecting to: test
2018-04-24T21:53:16.940+0800 W NETWORK[thread1] Failed to connect to 127.0.0.1:27017, in(checking socket for error after poll), reason: errno:111 Connection refused
2018-04-24T21:53:16.940+0800 E QUERY    [thread1] Error: couldn't connect to server 127.0.0.1:27017, connection attempt failed :
connect@src/mongo/shell/mongo.js:229:14
@(connect):1:6

exception: connect failed

不服:进行操作步骤2

[root@alex /alex/data/mongo/mongo3.2.15]$ ./bin/mongod --dbpath=/alex/data/mongo/mongo3.2.15/data/db/
./bin/mongod: error while loading shared libraries: libnetsnmpmibs.so.31: cannot open shared object file: No such file or directory
[root@alex /alex/data/mongo/mongo3.2.15]$ cd bin/
[root@alex /alex/data/mongo/mongo3.2.15/bin]$ ./mongod --dbpath=/alex/data/mongo/mongo3.2.15/data/db/
./mongod: error while loading shared libraries: libnetsnmpmibs.so.31: cannot open shared object file: No such file or directory
[root@alex /alex/data/mongo/mongo3.2.15/bin]$ vim mongo.conf 
[root@alex /alex/data/mongo/mongo3.2.15/bin]$ ./mongod --dbpath=/alex/data/mongo/mongo3.2.15/data/db/^C
[root@alex /alex/data/mongo/mongo3.2.15/bin]$ ./mongod --config mongo.conf
./mongod: error while loading shared libraries: libnetsnmpmibs.so.31: cannot open shared object file: No such file or directory
[root@alex /alex/data/mongo/mongo3.2.15/bin]$ ./mongod --config mongo.conf  
./mongod: error while loading shared libraries: libnetsnmpmibs.so.31: cannot open shared object file: No such file or directory
[root@alex /alex/data/mongo/mongo3.2.15/bin]$ ls
bsondump  mongo  mongo.conf  mongod  mongodecrypt  mongodump  mongoexport  mongofiles  mongoimport  mongooplog  mongoperf  mongorestore  mongos  mongosniff  mongostat  mongotop
[root@alex /alex/data/mongo/mongo3.2.15/bin]$ chmod 777 mongod
[root@alex /alex/data/mongo/mongo3.2.15/bin]$ ./mongod --config mongo.conf  
./mongod: error while loading shared libraries: libnetsnmpmibs.so.31: cannot open shared object file: No such file or directory
然后各种百度,但是内心最深处就是感觉哪个地方没弄好,开始百度“centos7 安装mongo入门,看官方文档”,都没提起

“libnetsnmpmibs.so.31”不小心翻到2月3号给人家留言的博客,定位到这个时间点,本想查看自己的csdn,发现并没做记录无奈之下去旧的ecs上蹭人品,用history看一下操作记录指令,惊奇的发现前1000行竟然是从mongo开始的。感谢上帝的怜悯

37  cd /space/data/mongo3.2.15/bin/
   38  ls
   39  ./mongod --config mongo.conf 
   40  sudo service mongod start
   41  cd ../
   42  ls
   43  cd ../
   44  ls
   45  cd mongo3.2.15/
   46  ls
   47  cd bin/
   48  ls
   49  ./mongod
   50  ls
   51  ./mongo
   52  ./mongod
   53  yum whatprovides libstdc++.so.6
   54  yum whatprovides libstdc++.so.31
   55  yum whatprovides  libnetsnmpmibs.so.31
   56  yum -y install net-snmp-agent-libs-5.7.2-28.el7_4.1.i686
   57  ./mongod --config mongo.conf 
   58  ./mongod --dbpath=/space/data/mongo3.2.15/data/db --logpath=/space/data/mongo3.2.15/data/logs/mongodb.log --logappend --fork
   59  yum whatprovides  libnetsnmpmibs.so.31
   60  mongod --dbpath=/space/data/mongo3.2.15/data/db --logpath=/space/data/mongo3.2.15/data/logs/mongodb.log --logappend --fork
   61  sudo ln -s /lib/libcrypto.so.0.9.8 /lib/libnetsnmpmibs.so.31
   62  sudo ln -s /lib/libcrypto.so.0.9.8 /lib/libnetsnmpmibs.so.31 -y
   63  ln --help
   64  ls
   65  ./mongod
   66  cat mongod
   67  ./mongod
   68  ls
   69  sudo -i
   70  cd /space/data/mongo3.2.15/bin/
   71  ls
   72  ./mongod
   73  sudo ln -s ~/Downloads/mongodb-correct-version/bin/mongod /usr/local/sbin/bin/mongod
   74  sudo ln -s ~/Downloads/mongodb-correct-version/bin/mongod /space/data/mongo3.2.15/bin/mongod
   75  sudo ln -s ~/Downloads/mongodb-correct-version/bin/mongod /space/data/mongo3.2.15/bin/mongod  --version
   76  ./mongod --dbpath=/space/data/mongo3.2.15/data/db --logpath=/space/data/mongo3.2.15/data/logs/mongodb.log --logappend --fork
   77  cd /etc/
   78  ls
   79  cd init.d/
   80  ls
   81  mongod --dbpath ~/data/db/
   82  cd /space/data/mongo3.2.15/bin/
   83  mongod --dbpath ~/data/db/
   84   sudo cp /lib/x86_64-linux-gnu/libssl.so.1.0.0 /usr/lib/libssl.so.31
   85  sudo apt-get update
   86   sudo apt-get install snmp
   87  yum install -y snmp
   88  yum -y install snmp
   89  cd /space/data/mongo3.2.15/bin/
   90  ls
   91  ll -lhtr /usr/lib64/libnetsnmp.so.31 
   92  mv /usr/lib64//usr/lib64/libnetsnmp.so.31  /tmp/
   93  mv /usr/lib64/libnetsnmp.so.31  /tmp/
   94  ps -ef | grep mongo
   95  kill 32317
   96  ./mongod --dbpath=/space/data/mongo3.2.15/data/db --logpath=/space/data/mongo3.2.15/data/logs/mongodb.log --logappend --fork –smallfiles –nojournal
   97  mv /tmp/libnetsnmp.so.31  /usr/lib64/
   98  ./mongod --dbpath=/space/data/mongo3.2.15/data/db --logpath=/space/data/mongo3.2.15/data/logs/mongodb.log --logappend --fork –smallfiles –nojournal
   99  ./mongod --dbpath=/space/data/mongo3.2.15/data/db --logpath=/space/data/mongo3.2.15/data/logs/mongodb.log  –smallfiles –nojournal &
  100  ./mongod -dbpath /space/data/mongo3.2.15/data/db -logpath /space/data/mongo3.2.15/data/logs/mongodb.log  –smallfiles –nojournal &
  101  ./mongod -dbpath /space/data/mongo3.2.15/data/db -logpath /space/data/mongo3.2.15/data/logs/mongodb.log  –smallfiles –nojournal
  102  ./mongod -dbpath /space/data/mongo3.2.15/data/db -logpath /space/data/mongo3.2.15/data/logs/mongodb.log
  103  ./mongo
  104  ./mongo --port 40000
  105  service mongod start
  106  sudo -i
  107  sudo -i
  108  cd /tmp/
  109  ls
立刻警醒到:这台借别人新买ECS的“ net-snmp”没装:

此处参考博客:https://blog.csdn.net/qq_17202587/article/details/78538065

在启动 mongod的时候遇到error while loading shared libraries: libnetsnmpagent.so.20: cannot open shared object file: No such file or directory

该error 是因为未装net-snmp

直接连接外网的Linux服务器可直接使用:yum install net-snmp


[root@alex /alex/data/mongo/mongo3.2.15/bin]$ yum install net-snmp 
base                                                                                                                                                                                                                                                   | 3.6 kB  00:00:00     
epel                                                                                                                                                                                                                                                   | 4.7 kB  00:00:00     
extras                                                                                                                                                                                                                                                 | 3.4 kB  00:00:00     
updates                                                                                                                                                                                                                                                | 3.4 kB  00:00:00     
Loading mirror speeds from cached hostfile
Resolving Dependencies
  Installing : 1:net-snmp-libs-5.7.2-28.el7_4.1.x86_64                                                                                                                                                                                                                    1/4 
  Installing : 1:net-snmp-agent-libs-5.7.2-28.el7_4.1.x86_64                                                                                                                                                                                                              2/4 
  Installing : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                                                                                                                                                        3/4 
  Installing : 1:net-snmp-5.7.2-28.el7_4.1.x86_64                                                                                                                                                                                                                         4/4 
  Verifying  : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                                                                                                                                                        1/4 
  Verifying  : 1:net-snmp-5.7.2-28.el7_4.1.x86_64                                                                                                                                                                                                                         2/4 
  Verifying  : 1:net-snmp-agent-libs-5.7.2-28.el7_4.1.x86_64                                                                                                                                                                                                              3/4 
  Verifying  : 1:net-snmp-libs-5.7.2-28.el7_4.1.x86_64                                                                                                                                                                                                                    4/4 


Installed:
  net-snmp.x86_64 1:5.7.2-28.el7_4.1                                                                                                                                                                                                                                          


Dependency Installed:
  net-snmp-agent-libs.x86_64 1:5.7.2-28.el7_4.1                                                 net-snmp-libs.x86_64 1:5.7.2-28.el7_4.1                                                 perl-Data-Dumper.x86_64 0:2.145-3.el7                                                
Complete!
[root@alex /alex/data/mongo/mongo3.2.15/bin]$ ./mongo
MongoDB shell version: 3.2.15
connecting to: test
Server has startup warnings:
2018-04-24T23:36:09.715+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-04-24T23:36:09.715+0800 I CONTROL  [initandlisten] 
2018-04-24T23:36:09.715+0800 I CONTROL  [initandlisten] 
2018-04-24T23:36:09.715+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
2018-04-24T23:36:09.715+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2018-04-24T23:36:09.715+0800 I CONTROL  [initandlisten] 
2018-04-24T23:36:09.715+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
2018-04-24T23:36:09.715+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
2018-04-24T23:36:09.715+0800 I CONTROL  [initandlisten] 
2018-04-24T23:36:09.715+0800 I CONTROL  [initandlisten] ** WARNING: soft rlimits too low. rlimits set to 7283 processes, 65535 files. Number of processes should be at least 32767.5 : 0.5 times number of files.
2018-04-24T23:36:09.715+0800 I CONTROL  [initandlisten] 
MongoDB Enterprise > show dbs
local  0.000GB
MongoDB Enterprise > use hellotables
switched to db hellotables
MongoDB Enterprise > db.hellotales.insert({"name":"菜鸟教程"})
WriteResult({ "nInserted" : 1 })
MongoDB Enterprise > show tables

完成,,这次再晚也要记录,可以洗漱睡觉去了~

你可能感兴趣的:(docker服务构建)