你好,游客 登录 注册 搜索
背景:
阅读新闻

CentOS编译安装MongoDB

[日期:2012-02-10] 来源:Linux社区  作者:Linux [字体: ]
启动服务
ln -s /usr/local/mongodb/bin/mongod /usr/bin/mongod
/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/etc/mongodb.conf

系统服务
mkdir -p /usr/local/mongodb/service

vi /usr/local/mongodb/service/mongodb-start
#!/bin/sh
/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/etc/mongodb.conf

vi /usr/local/mongodb/service/mongodb-stop
#!/bin/bash
pid=`ps -o pid,command ax | grep mongod | awk '!/awk/ && !/grep/ {print $1}'`;
if [ "${pid}" != "" ]; then
    kill -2 ${pid};
fi

chmod a+x /usr/local/mongodb/service/mongodb-start
chmod a+x /usr/local/mongodb/service/mongodb-stop

vi /etc/rc.d/init.d/mongodb
#! /bin/sh
#
# mongodb - this script starts and stops the mongodb daemon
#
# chkconfig: - 85 15
# description: MongoDB is a non-relational database storage system.
# processname: mongodb
# config: /usr/local/mongodb/etc/mongodb.conf
# pidfile: /usr/local/mongodb/mongodb.pid
PATH=/usr/local/mongodb/bin:/sbin:/bin:/usr/sbin:/usr/bin
NAME=mongodb
test -x $DAEMON || exit 0
set -e
case "$1" in
  start)
        echo -n "Starting MongoDB... "
        /usr/local/mongodb/service/mongodb-start
        ;;
  stop)
        echo -n "Stopping MongoDB... "
        /usr/local/mongodb/service/mongodb-stop
        ;;
      *)
            N=/etc/init.d/$NAME
            echo "Usage: $N {start|stop}" >&2
            exit 1
            ;;
    esac
    exit 0

chmod a+x /etc/rc.d/init.d/mongodb
chkconfig --add mongodb
chkconfig --level 345 mongodb on
/etc/rc.d/init.d/mongodb start

命令行测试
/usr/local/mongodb/bin/mongo --help
/usr/local/mongodb/bin/mongo  192.168.1.36:27017
show dbs
use blog
db
show collections
db.blog.save({"id":1, "name":"hello world"})
db.blog.find()

管理工具(类似phpmyadmin)
http://code.google.com/p/rock-php/wiki/rock_mongo_zh
下载解压修改config.php为对应的地址及端口,使用admin:admin访问即可。linux
相关资讯       MongoDB  CentOS安装教程 
本文评论   查看全部评论 (0)
表情: 表情 姓名: 字数

       

评论声明
  • 尊重网上道德,遵守中华人民共和国的各项有关法律法规
  • 承担一切因您的行为而直接或间接导致的民事或刑事法律责任
  • 本站管理人员有权保留或删除其管辖留言中的任意内容
  • 本站有权在网站内转载或引用您的评论
  • 参与本评论即表明您已经阅读并接受上述条款