CentOS6.5下安装MongoDB v3.05


  • administrators

    Linode的VPS准备在月底就终止续费了,所以尽可能多花时间在上面折腾。准备试着部署一下Nodeclub,看说明写的是

    线上跑的是 Node.js v4.4.0,MongoDB 是 v3.0.5,Redis 是 v3.0.3。

    Node.js系统上已经有了,就先开始安装MongoDB吧。

    [root@li1473-187 ~]# wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel62-3.0.5.tgz
    [root@li1473-187 ~]# tar -zxvf mongodb-linux-x86_64-rhel62-3.0.5.tgz
    [root@li1473-187 ~]# mv mongodb-linux-x86_64-rhel62-3.0.5 mongodb
    [root@li1473-187 ~]# mv mongodb /usr/local/
    [root@li1473-187 ~]# cd /usr/local/mongodb
    [root@li1473-187 mongodb]# ls
    bin  GNU-AGPL-3.0  README  THIRD-PARTY-NOTICES
    [root@li1473-187 mongodb]# mkdir db
    [root@li1473-187 mongodb]# mkdir logs
    [root@li1473-187 mongodb]# cd bin
    [root@li1473-187 bin]# ls
    bsondump  mongod     mongoexport  mongoimport  mongoperf     mongos     mongotop
    mongo     mongodump  mongofiles   mongooplog   mongorestore  mongostat
    [root@li1473-187 bin]# vim mongodb.conf
    dbpath=/usr/local/mongodb/db
    logpath=/usr/local/mongodb/logs/mongodb.log
    port=27017
    fork=true
    nohttpinterface=true
    [root@li1473-187 bin]# /usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf
    about to fork child process, waiting until server is ready for connections.
    forked process: 26170
    child process started successfully, parent exiting
    

    MongoDB已经启动起来了。下面加入开机自动启动mongodb

    [root@li1473-187 bin]# vim /etc/rc.d/rc.local
    /usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf
    [root@li1473-187 bin]# ps -ef|grep mongo
    root     26170     1  0 15:30 ?        00:00:00 /usr/local/mongodb/bin/mongod --config /usr/local/mongodb/bin/mongodb.conf
    root     26794 21916  0 15:31 pts/3    00:00:00 grep mongo
    

    重启系统后进入MongoDB

    [root@li1473-187 ~]# /usr/local/mongodb/bin/mongo
    MongoDB shell version: 3.0.5
    connecting to: test
    Server has startup warnings:
    2017-02-15T15:46:30.303+0800 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
    2017-02-15T15:46:30.303+0800 I CONTROL  [initandlisten]
    > show dbs
    local  0.078GB
    > exit
    bye
    [root@li1473-187 ~]#
    

    测试可用,OVER!


Log in to reply
 

Looks like your connection to MainFrame was lost, please wait while we try to reconnect.