如何在 fedora linux 上安装 mongodb 和 mongodb-server(在 f16 和 f17 上验证)。所有命令都旨在在 su 会话中运行。
1)确保你没有安装mongodb
# yum erase mongodb
# yum erase mongo-10gen (if it is installed)
2) 从 fedora yum 存储库安装
# yum --disablerepo=* --enablerepo=fedora,updates install mongodb mongodb-server
3)启动mongod(mongodb守护进程)
# systemctl start mongod.service
4) 验证 mongod 是否正在运行
# systemctl status mongod.service
# tail /var/log/mongodb/mongodb.log
# nmap -p27017 localhost
或运行客户端
# mongo
MongoDB shell version: 2.0.2
connecting to: test
> db.test.save( { a: 1 } )
> db.test.find()
{ "_id" : ObjectId("4fdf28f09d16204d66082fa3"), "a" : 1 }
5) 自定义配置
# vim /etc/mongodb.conf
# systemctl restart mongod.service
6)让mongodb服务开机自动启动
# systemctl enable mongod.service
Fedora 18 更新
当 systemd 第一次在慢速或负载机器上启动时,mongod 服务可能在完成初始化之前超时,systemd 将服务标记为失败。
症状:
# journalctl -xn
-- Unit mongod.service has begun starting up.
10:38:43 local mongod[24558]: forked process: 24560
10:38:43 local mongod[24558]: all output going to: /var/log/mongodb/mongodb.log
10:40:13 local systemd[1]: mongod.service operation timed out. Terminating.
10:40:13 local systemd[1]: Failed to start High-performance, schema-free document-oriented database.
-- Subject: Unit mongod.service has failed
很容易治愈,重启服务:
# systemctl restart mongod.service
这应该成功完成初始化并使守护程序处于运行状态。