Fork me on GitHub

Liunx下安装MongoDB

#建立DB与日志目录
#cd /opt
# mkdir -p mongodb/data 
# touch mongodb/logs
#下载解压
#yum wegt
#cd /opt/mangodb
#wegt
http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-2.4.2.tgz
#tar zxvf mongodb-linux-x86_64-2.4.2.tgz
#启动MongoDB服务
#cd mongodb-linux-x86_64-2.4.2
#./bin/mongod --dbpath=/opt/mongodb/data --logpath=/opt/mongodb/logs

#查看日志
[root@localhost mongodb]# cat logs
Sun Apr 21 14:39:52.707 [initandlisten] MongoDB starting : pid=10522 port=27017 dbpath=/opt/mongodb/data 64-bit host=localhost.localdomain
Sun Apr 21 14:39:52.709 [initandlisten]
Sun Apr 21 14:39:52.709 [initandlisten] ** WARNING: You are running on a NUMA machine.
Sun Apr 21 14:39:52.709 [initandlisten] **          We suggest launching mongod like this to avoid performance problems:
Sun Apr 21 14:39:52.709 [initandlisten] **              numactl --interleave=all mongod [other options]
Sun Apr 21 14:39:52.709 [initandlisten]
Sun Apr 21 14:39:52.709 [initandlisten] db version v2.4.2
Sun Apr 21 14:39:52.709 [initandlisten] git version: 3e52c1a73c08eba7abdcb2c93e08205111976f07
Sun Apr 21 14:39:52.709 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Sun Apr 21 14:39:52.709 [initandlisten] allocator: tcmalloc
Sun Apr 21 14:39:52.709 [initandlisten] options: { dbpath: "/opt/mongodb/data", logpath: "/opt/mongodb/logs" }
Sun Apr 21 14:39:52.753 [initandlisten] journal dir=/opt/mongodb/data/journal
Sun Apr 21 14:39:52.754 [initandlisten] recover : no journal files present, no recovery needed
Sun Apr 21 14:39:54.394 [initandlisten] preallocateIsFaster=true 19.86
Sun Apr 21 14:39:56.025 [initandlisten] preallocateIsFaster=true 19.82
Sun Apr 21 14:39:58.636 [initandlisten] preallocateIsFaster=true 19.34
Sun Apr 21 14:39:58.636 [initandlisten] preallocateIsFaster check took 5.882 secs
Sun Apr 21 14:39:58.636 [initandlisten] preallocating a journal file /opt/mongodb/data/journal/prealloc.0
Sun Apr 21 14:40:09.895 [initandlisten] preallocating a journal file /opt/mongodb/data/journal/prealloc.1
Sun Apr 21 14:40:20.836 [initandlisten] preallocating a journal file /opt/mongodb/data/journal/prealloc.2
Sun Apr 21 14:40:23.029 [initandlisten]                 File Preallocator Progress: 660602880/1073741824        61%
Sun Apr 21 14:40:33.515 [FileAllocator] allocating new datafile /opt/mongodb/data/local.ns, filling with zeroes...
Sun Apr 21 14:40:33.515 [FileAllocator] creating directory /opt/mongodb/data/_tmp
Sun Apr 21 14:40:33.832 [FileAllocator] done allocating datafile /opt/mongodb/data/local.ns, size: 16MB,  took 0.275 secs
Sun Apr 21 14:40:33.832 [FileAllocator] allocating new datafile /opt/mongodb/data/local.0, filling with zeroes...
Sun Apr 21 14:40:34.665 [FileAllocator] done allocating datafile /opt/mongodb/data/local.0, size: 64MB,  took 0.832 secs
Sun Apr 21 14:40:34.667 [initandlisten] command local.$cmd command: { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0  reslen:37 1152ms
Sun Apr 21 14:40:34.668 [initandlisten] waiting for connections on port 27017
Sun Apr 21 14:40:34.668 [websvr] admin web console waiting for connections on port 28017

#将mongoDB服务加入随机启动
#vi /etc/rc.local
#加入一行(为测试,yum源安装)
/opt/mongodb/mongodb-linux-x86_64-2.4.2/bin/mongod --dbpath=/opt/mongodb/data --logpath=/opt/mongodb/logs  --logappend
#配置文件
#vm /etc/mongod.conf
#连接mongoDB
#cd /opt/mongodb/mongodb-linux-x86_64-2.4.2
#./bin/mongo
MongoDB shell version: 2.4.2
connecting to: test
#防火墙(服务端的默认连接端口:27017 WEB:28017)
# iptables -I INPUT -p tcp --dport 27017 -j ACCEPT
# iptables -I INPUT -p tcp --dport 28017 -j ACCEPT
# service iptables save
# service iptables restart

Refer:
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-red-hat-centos-or-fedora-linux/
http://www.yyuc.net/linux/setup/mongodb.html
yum:http://zuoqiang.iteye.com/blog/1155069
dbpath:http://www.cnblogs.com/mobydick/archive/2012/11/05/2755509.html

posted @ 2013-04-21 14:57  花儿笑弯了腰  阅读(584)  评论(0编辑  收藏  举报