如何在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
或正在运行的客户端
# mongoMongoDB shell version: 2.0.2connecting 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: 2456010:38:43 local mongod[24558]: all output going to: /var/log/mongodb/mongodb.log10: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
这样就可以成功完成初始化,并使守护程序保持运行状态。



