下载mongodb-linux-x86_64-2.6.4.tgz

# tar zxvf mongodb-linux-x86_64-2.6.4.tgz
# mv mongodb-linux-x86_64-2.6.4 /mongodb

chown -R root.root /mongodb

mkdir -p /mdb /mdb/log

ln -s /mongodb/bin/* /usr/bin/

vi /mongodb/mongod.conf

点击(此处)折叠或打开

  1. dbpath = /mdb
  2. logpath = /mdb/log/mongod.log

vi /etc/init.d/mongodb

点击(此处)折叠或打开

  1. #!/bin/bash
  2. #
  3. #chkconfig: 2345 80 90
  4. #description
  5. start(){
  6. /mongodb/bin/mongod --config /mongodb/mongod.conf &
  7. }


  8. stop(){
  9. /mongodb/bin/mongod --config /mongodb/mongod.conf --shutdown;rm -rf /mdb/mongod.lock
  10. }


  11. case "$1" in
  12. start)
  13. start
  14. ;;


  15. stop)
  16. stop
  17. ;;


  18. restart)
  19. stop
  20. start
  21. ;;
  22. *)
  23. echo
  24. $"Usage: $0 {start|stop|restart}"
  25. exit 1
  26. esac



chmod +x /etc/init.d/mongodb

chkconfig --add mongodb
chkconfig mongodb on

#service mongodb start


09-07 14:08