linux 下安装mongodb
更新:HHH   时间:2023-1-7



[root@sc-wjg ~]# uname -a
Linux sc-wjg 2.6.32-358.23.2.el6.x86_64 #1 SMP Wed Oct 16 18:37:12 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
[root@sc-wjg ~]# cat /etc/redhat-release
CentOS release 6.4 (Final)

[root@sc-wjg ~]#  groupadd mongo
[root@sc-wjg ~]# useradd -g mongo mongo
[root@sc-wjg ~]#  mkdir -p /database/mongodb/data/
[root@sc-wjg ~]# chown -R mongo:mongo /database/mongodb/data/
[root@sc-wjg ~]# mkdir -p /var/applog/mongo_log/
[root@sc-wjg ~]# chown -R mongo:mongo /var/applog/mongo_log/

[root@sc-wjg ~]#
wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.2.7.tgz
[root@sc-wjg ~]# tar zxf mongodb-linux-x86_64-2.2.7.tgz

[root@sc-wjg ~]# mv mongodb-linux-x86_64-2.2.7 /usr/local/mongodb
[root@sc-wjg ~]# cd /usr/local/mongodb/
[root@sc-wjg mongodb]# ll
total 64
drwxr-xr-x 2 root root  4096 Apr  7 16:00 bin
-rw------- 1  500  500 34520 Jan 11  2013 GNU-AGPL-3.0
-rw------- 1  500  500  1359 Jan 11  2013 README
-rw------- 1  500  500 16787 Jan 11  2013 THIRD-PARTY-NOTICES
[root@sc-wjg mongodb]# mkdir /var/mongodb/data -p
[root@sc-wjg mongodb]# mkdir /var/mongodb/logs -p
[root@sc-wjg mongodb]# /etc/init.d/iptables stop

启动mongodb

[root@sc-wjg mongodb]# /usr/local/mongodb/bin/mongod --dbpath=/var/mongodb/data --logpath /var/mongodb/logs/log.log -fork
forked process: 29117
all output going to: /var/mongodb/logs/log.log
child process started successfully, parent exiting


登入

[root@sc-wjg mongodb]# /usr/local/mongodb/bin/mongo
MongoDB shell version: 2.2.7
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
   http://docs.mongodb.org/
Questions? Try the support group
   http://groups.google.com/group/mongodb-user
> show dbs




返回MongoDB数据库教程...