zoukankan      html  css  js  c++  java
  • MongoDB 安装 ( centos6.5系统)

    mongodb的安装非常简单,主要是配置文件和添加系统服务,设置开机启动。

    1. 下载安装文件,解压    tar -zxvf  mongodb-linux-x86_64-rhel62-3.2.22.tgz  -C /opt/module    

    2.  重命名目录 mv mongodb-linux-x86_64-rhel62-3.2.22  mongodb

        bin目录说明:

    mongo 客户端程序,连接MongoDB

    mongod 服务端程序,启动MongoDB

    mongodump 备份程序

    mongoexport 数据导出程序

    mongofiles GridFS工具,内建的分布式文件系统

    mongoimport 数据导入程序

    mongorestore 数据恢复程序

    mongos 数据分片程序,支持数据的横向扩展

    mongostat 监视程序

    3. 创建data、log目录

            cd /opt/module/mongodb

            mkdir data log

            touch log/mongodb.log //建立日志文件

    4. 创建配置文件

        cd  /opt/module/mongodb

        touch  mongodb.conf

        编辑 mongodb.conf 文件

    #mongodb.conf
    dbpath=/opt/module/mongodb/data
    logpath=/opt/module/mongodb/log/mongodb.log
    
    logappend=true
    #服务端程序子进程运行 fork = true port = 27017
    #不需要验证登录系统 noauth
    = true #auth = true #journal=true nojournal=true
    #容许外机访问
    #bind_ip_all=true

    5. 创建系统服务脚本 vim /etc/init.d/mongodb

    #!/bin/bash
    #
    #chkconfig: 2345 80 90
    #description: mongodb
    
    start() {
     rm -f /opt/module/mongodb/data/mongod.lock
     /opt/module/mongodb/bin/mongod --config /opt/module/mongodb/mongodb.conf >> /opt/module/mongodb/log/db.log 2>&1 &
    }
    
    stop() {
     /opt/module/mongodb/bin/mongod --config /opt/module/mongodb/mongodb.conf --shutdown
    }
    
    case "$1" in
      start)
        start
         ;;
    
      stop)
        stop
         ;;
    
      restart)
        stop
        start
        ;;
    
      *)
        echo $"Usage: $0 {start|stop|restart}"
        exit 1
      ;;
    esac
    
    exit 0

    6. 添加到系统服务,并设置开机启动

    chmod +x /etc/init.d/mongodb

    chkconfig --add mongodb

    chkconfig --level 35 mongodb on

    7. 启动mongodb

    service mongodb start

    8. 关闭mongodb

    service mongodb stop

    9. 将/opt/mongodb/bin目录添加到环境变量PATH中

        vim /etc/profile

        export PATH=$PATH:/opt/module/mongodb/bin

        保存退出,

        source /etc/profile

     

     

  • 相关阅读:
    nginx配置文件详解
    centos 小知识
    nginx 常见问题
    centos7.5 安装nginx
    tomact 配置远程登录
    Centos7 离线安装 mariaDB
    Crontab详细用法-定时任务详解
    新项目push/pull到github
    GIT的基本操作
    hive的安装
  • 原文地址:https://www.cnblogs.com/kpwong/p/14251622.html
Copyright © 2011-2022 走看看