MongoDBインストール

MongoDBをインストールしてみた。

ユーザ作成

groupadd -g 2003 mongodb
useradd -u 2003 -g mongodb -d /home/mongodb -m -s /bin/bash mongodb

ソースダウンロード

cd /usr/local/src
wget -c http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.0.2.tgz

インストール

tar zxvf mongodb-linux-x86_64-2.0.2.tgz
mv -i mongodb-linux-x86_64-2.0.2 /usr/local/.
ln -s /usr/local/mongodb-linux-x86_64-2.0.2 /usr/local/mongodb

ディレクトリ作成

mkdir -p /usr/local/mongodb/{conf,logs,data}
chown -R mongodb. /usr/local/mongodb-linux-x86_64-2.0.2

MongoDB起動

/usr/local/mongodb/bin/mongod --port 27017 --logappend --logpath /usr/local/mongodb/logs/mongod.log --pidfilepath=/usr/local/mongodb/logs/mongod.pid --dbpath=/usr/local/mongodb/data --fork
Option Value Summary
--port ポート番号 mongodのListen port
--logappend なし logを追記する
--logpath /path/to/log logfileのpath
--pidfilepath /path/to/pid pidfileのpath
--dbpath /path/to/data database格納path
--fork なし backgroundで実行

MongoDB停止

kill -2 `cat /usr/local/mongodb/logs/mongod.pid`

MongoDB設定ファイル

中身はapt-getで入れた時に入るものとほぼ同じ。

vi /usr/local/mongodb/conf/mongod.conf
# mongodb.conf

# Where to store the data.

# Note: if you run mongodb as a non-root user (recommended) you may
# need to create and set permissions for this directory manually,
# e.g., if the parent directory isn't mutable by the mongodb user.
dbpath=/usr/local/mongodb/data

#where to log
logappend=true
logpath=/usr/local/mongodb/logs/mongod.log

pidfilepath=/usr/local/mongodb/logs/mongod.pid

bind_ip = 127.0.0.1                                                             
port = 27017

# Enables periodic logging of CPU utilization and I/O wait
#cpu = true

# Turn on/off security.  Off is currently the default
#noauth = true
#auth = true

# Verbose logging output.
#verbose = true

# Inspect all client data for validity on receipt (useful for
# developing drivers)
#objcheck = true

# Enable db quota management
#quota = true

# Set oplogging level where n is
#   0=off (default)
#   1=W
#   2=R
#   3=both
#   7=W+some reads
#oplog = 0

# Diagnostic/debugging option
#nocursors = true

# Ignore query hints
#nohints = true

# Disable the HTTP interface (Defaults to localhost:27018).
#nohttpinterface = true

# Turns off server-side scripting.  This will result in greatly limited
# functionality
#noscripting = true

# Turns off table scans.  Any query that would do a table scan fails.
#notablescan = true

# Disable data file preallocation.
#noprealloc = true

# Specify .ns file size for new databases.
# nssize = <size>

# Accout token for Mongo monitoring server.
#mms-token = <token>