環境:
OS: Red Hat Linux As 5
DB: 2.2.2
1.下載mongodb
下載地址:http://downloads.mongodb.org/linux/
選擇相應的版本,這裏我選擇的是32 bit的下載.
2.解壓縮tar文件
進入指定安裝mongodb的目錄後,執行如下命令
#tar xvf mongodb-linux-i686-2.2.2.tar
3. 創建數據文件和日誌文件
#mkdir /opt/mongodb-linux-i686-2.2.2/data
#touch /opt/mongodb-linux-i686-2.2.2/logs
4.在安裝mongodb的用戶下添加如下環境變量,以便直接使用mongodb bin目錄下的命令
PATH=$PATH:$HOME/bin:/opt/mongodb-linux-i686-2.2.2/bin
5.啓動mongodb
mongod --dbpath=/opt/mongodb-linux-i686-2.2.2/data --logpath=/opt/mongodb-linux-i686-2.2.2/logs --logappend --port=27017 --fork
6.執行mongo查看安裝是否成功
[root@hxl ~]# mongo
MongoDB shell version: 2.2.2
connecting to: test
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the support group
http://groups.google.com/group/mongodb-user
> use test;
switched to db test
7.設置mongodb自動啓動
將如下命令添加到 /etc/rc.local
mongod --dbpath=/opt/mongodb-linux-i686-2.2.2/data --logpath=/opt/mongodb-linux-i686-2.2.2/logs --logappend --port=27017 --fork
-- The End --