CentOS 6.5でmongodb2.6をインストールする

ダウンロード:
http://www.mongodb.org/downloads

解凍:
tar zxf mongodb-linux-i686-2.6.0.tgz

保存ディレクトリ
/usr/local/mongodb

データディレクトリ
/mongodb/data/

ログファイル
/mongodb/dblogs

操作コマンド:
login as: root
root@10.187.50.3’s password:
[root@localhost ~]# cd /home/startnews24/Desktop
[root@localhost Desktop]# ls
mongodb-linux-i686-2.6.0 mongodb-linux-i686-2.6.0.tgz vsftpd.rpm
[root@localhost Desktop]# cd mongodb-linux-i686-2.6.0
[root@localhost mongodb-linux-i686-2.6.0]# ls
bin GNU-AGPL-3.0 README THIRD-PARTY-NOTICES
[root@localhost mongodb-linux-i686-2.6.0]# rsync -a bin /usr/local/mongodb
[root@localhost mongodb-linux-i686-2.6.0]# cd /usr/local/
[root@localhost local]# ls
bin etc games include lib libexec mongodb sbin share src
[root@localhost local]# cd mongodb
[root@localhost mongodb]# ls
bin
[root@localhost mongodb]# cd bin
[root@localhost bin]# ls
bsondump mongodump mongoimport mongorestore mongotop
mongo mongoexport mongooplog mongos
mongod mongofiles mongoperf mongostat
[root@localhost bin]# cd ../
[root@localhost mongodb]# ls
bin
[root@localhost mongodb]# mkdir data
[root@localhost mongodb]# touch dblogs
[root@localhost mongodb]# ls
bin data dblogs
[root@localhost mongodb]# cd bin/
[root@localhost bin]# ls
bsondump mongodump mongoimport mongorestore mongotop
mongo mongoexport mongooplog mongos
mongod mongofiles mongoperf mongostat
[root@localhost bin]# ./mongod –dbpath=/usr/local/mongodb/data/ –logpath=/usr/local/mongodb/dblogs –fork
2014-09-24T08:06:43.480+0800
2014-09-24T08:06:43.480+0800 warning: 32-bit servers don’t have journaling enabled by default. Please use –journal if you want durability.
2014-09-24T08:06:43.480+0800
about to fork child process, waiting until server is ready for connections.
forked process: 4489
child process started successfully, parent exiting
[root@localhost bin]# pstree -p | grep mongod
|-mongod(4489)-+-{mongod}(4490)
| |-{mongod}(4491)
| |-{mongod}(4492)
| |-{mongod}(4493)
| |-{mongod}(4494)
| |-{mongod}(4495)
| |-{mongod}(4496)
| |-{mongod}(4497)
| `-{mongod}(4498)
[root@localhost bin]# vi /etc/rc.local
[root@localhost bin]# cat /etc/rc.local
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don’t
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/usr/local/mongodb/bin/mongod –dbpath=/usr/local/mongodb/data/ –logpath=/usr/local/mongodb/dblogs –fork
[root@localhost bin]# ps -ef | grep mongod
root 4489 1 0 08:06 ? 00:00:03 ./mongod –dbpath=/usr/local/mongodb/data/ –logpath=/usr/local/mongodb/dblogs –fork
root 18469 4413 0 08:15 pts/1 00:00:00 grep mongod
[root@localhost bin]# kill -9 4489
[root@localhost bin]# ps -ef | grep mongod
root 18474 4413 0 08:16 pts/1 00:00:00 grep mongod
[root@localhost bin]# ./mongod –dbpath=/usr/local/mongodb/data/ –logpath=/usr/local/mongodb/dblogs –fork
2014-09-24T08:16:24.524+0800
2014-09-24T08:16:24.524+0800 warning: 32-bit servers don’t have journaling enabled by default. Please use –journal if you want durability.
2014-09-24T08:16:24.524+0800
about to fork child process, waiting until server is ready for connections.
forked process: 18478
ERROR: child process failed, exited with error number 100
[root@localhost bin]# ps -ef | grep mongod root 18483 4413 0 08:16 pts/1 00:00:00 grep mongod
[root@localhost bin]# cd ../
[root@localhost mongodb]# cd data/
[root@localhost data]# ls
local.0 local.ns mongod.lock _tmp
[root@localhost data]# rm -rf mongod.lock
[root@localhost data]# cd ../
[root@localhost mongodb]# cd bin
[root@localhost bin]# ./mongod –dbpath=/usr/local/mongodb/data/ –logpath=/usr/local/mongodb/dblogs –fork
2014-09-24T08:18:31.190+0800
2014-09-24T08:18:31.190+0800 warning: 32-bit servers don’t have journaling enabled by default. Please use –journal if you want durability.
2014-09-24T08:18:31.190+0800
about to fork child process, waiting until server is ready for connections.
forked process: 18493
child process started successfully, parent exiting
[root@localhost bin]# ps -ef | grep mongod root 18493 1 0 08:18 ? 00:00:00 ./mongod –dbpath=/usr/local/mongodb/data/ –logpath=/usr/local/mongodb/dblogs –fork
root 18505 4413 0 08:18 pts/1 00:00:00 grep mongod
[root@localhost bin]#

Linux

Posted by arkgame