mongodb 运行错误总结
1、查看服务起来(端口号)
netstat -ntlp |grep 27017
2、启动mongodb
./mongod
遇到错误:
2018-06-26T09:32:52.289+0800 I CONTROL [initandlisten] MongoDB starting : pid=11475 port=27017 dbpath=/data/db 64-bit host=localhost.localdomain 2018-06-26T09:32:52.393+0800 I CONTROL [initandlisten] db version v3.2.9 2018-06-26T09:32:52.393+0800 I CONTROL [initandlisten] git version: 22ec9e93b40c85fc7cae7d56e7d6a02fd811088c 2018-06-26T09:32:52.393+0800 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.0.1e-fips 11 Feb 2013 2018-06-26T09:32:52.393+0800 I CONTROL [initandlisten] allocator: tcmalloc 2018-06-26T09:32:52.393+0800 I CONTROL [initandlisten] modules: none 2018-06-26T09:32:52.393+0800 I CONTROL [initandlisten] build environment: 2018-06-26T09:32:52.393+0800 I CONTROL [initandlisten] distmod: rhel62 2018-06-26T09:32:52.393+0800 I CONTROL [initandlisten] distarch: x86_64 2018-06-26T09:32:52.393+0800 I CONTROL [initandlisten] target_arch: x86_64 2018-06-26T09:32:52.393+0800 I CONTROL [initandlisten] options: {} 2018-06-26T09:32:52.455+0800 I STORAGE [initandlisten] exception in initAndListen: 29 Data directory /data/db not found., terminating 2018-06-26T09:32:52.456+0800 I CONTROL [initandlisten] dbexit: rc: 100
原因:mongodb启动如果不指定路径,默认加载/data/db
解决方法:启动加上dbpath
后台运行:
./mongod --dbpath=/home/mongo/mongodb/data/db --fork --logpath=/home/mongo/mongodb/logs/mongod.log
3、启动mongod,进入管理员界面
./mongod --dbpath=/home/mongo/mongodb/data/db
./mongo
注意:保持原界面不变,打开新界面输入管理台