Linux系统上安装mongodb数据库
1、上传mongodb-linux-x86_64-rhel62-3.0.6.gz到/root目录下
2、解压:tar zxvf mongodb-linux-x86_64-rhel62-3.0.6.gz
3、移动解压文件夹到MongoDB安装目录 mv mongodb-linux-x86_64-rhel62-3.0.6 /opt/mongodb
4、创建MongoDB数据库存放路径 mkdir -p /opt/mongodb/data
5、创建MongoDB数据库日志存放路径 mkdir -p /opt/mongodb/logs
6、启动MongoDB
./mongod --replSet dtoa --dbpath=/opt/mongodb/data/ --port 27017 --logpath=/opt/mongodb/logs/mongodb.log --fork --logappend
如果mongoDB启动报错 ERROR: child process failed, exited with error number,请参考如下链接解决
http://yijiebuyi.com/blog/f2e849b336b4d27fbf91bc52735d7841.html
设置随机启动
vi /etc/rc.local加入启动命令即可
出现下面的事由于openssl版本低,用yum install openssl更新就可
/usr/local/mongodb/bin/mongod: /usr/lib64/libssl.so.10: no version information available (required by /usr/local/mongodb/bin/mongod) /usr/local/mongodb/bin/mongod: /usr/lib64/libcrypto.so.10: no version information available (required by /usr/local/mongodb/bin/mongod) /usr/local/mongodb/bin/mongod: /usr/lib64/libcrypto.so.10: no version information available (required by /usr/local/mongodb/bin/mongod) about to fork child process, waiting until server is ready for connections. forked process: 1800 child process started successfully, parent exiting
7、查看MongoDB是否启动 netstat -lanp | grep "27017"
8、进入MongoDB数据库控制台? cd /usr/local/mongodb/bin/ ./mongo
9、查看默认数据库 show dbs 10、切换到admin数据库 use admin
11、关闭MongoDB数据库 db.shutdownServer()
12、退出 exit