• mongodb 安装部署说明


    mongodb.conf 配置文件

    # Where the databases will be stored
    dbpath=/usr/local/mongodb/mongodb-3.4.6/data/db
    
    # The port number the mongod server will listen on
    # port=27017
    
    # Listen on a specific ip address
    # Comment out the line below if you need to access mongod remotely.
    # USE WITH CAUTION -- THIS WILL ACCEPT ANY AND ALL CONNECTIONS WHEN USED WITH
    # THE noauth OPTION!!!
    # bind_ip=127.0.0.1
    
    # Log location -- otherwise stdout
    logpath=/usr/local/mongodb/mongodb-3.4.6/logs/log
    
    # appnd to logpath instead of over-writing
    # logappend=true
    
    # Use authentication
    # auth=true
    
    # Don't use authentication
    noauth=true
    
    # Disable the http interface
    nohttpinterface=true
    
    # fork and run in background
    fork=true

    mongod.centos 服务注册文件

    #!/bin/bash 
    # init script for mongodb 
    # chkconfig: 2345 70 11 
    # description: mongod 
    # processname: mongod 
    # pidfile: /var/run/mongodb.pid
    
    # Source function library. 
    . /etc/rc.d/init.d/functions
    
    RETVAL=0 
    pidfile=/var/run/mongodb.pid 
    exec="/usr/local/mongodb/mongodb-3.4.6/bin/mongod" 
    prog="mongod" 
    config="/etc/mongodb.conf" 
    lockfile="/var/lock/mongod"
    
    [ -e $config ] && . $config
    
    start() { 
      if [ ! -x $exec ] 
      then 
        echo $exec not found 
        exit 5 
      fi
    
      echo -n $"Starting $prog: "
    
      daemon $exec --fork --logpath=/usr/local/mongodb/mongodb-3.4.6/logs/mongod.log --logappend -f $config
      RETVAL=$? 
      echo 
      [ $RETVAL = 0 ] && touch ${lockfile} 
      return $RETVAL
    
    }
    
    stop() {
      echo -n $"Stopping $prog: " 
      killproc $prog 
      RETVAL=$? 
      echo 
      [ $RETVAL = 0 ] && rm -f $lockfile $pidfile
    }
    
    restart() { 
      stop 
      start 
    }
    
    # See how we were called. 
    case "$1" in 
      start) 
        start 
      ;; 
      stop) 
        stop 
      ;; 
      restart) 
        stop 
        sleep 1 
        start 
      ;; 
    *) 
    
    echo $"Usage: `basename $0` {start|stop|restart|status}" 
    exit 2 
    esac
    
    exit $RETVAL

    # 安装目录
    /usr/local/mongodb/mongodb-3.4.6

    # 建立存储数据及日志的目录:
    cd /usr/local/mongodb/mongodb-3.4.6
    mkdir -p /data/db/
    mkdir -p /data/logs/
    touch /data/logs/mongodb.log

    # 加入系统环境变量
    export PATH=/usr/local/mongodb/mongodb-3.4.6/bin:$PATH

    # 配置文件方式启动
    mongod -f /etc/mongodb.conf

    # 命令行方式启动 无身份验证
    mongod -dbpath=/usr/local/mongodb/mongodb-3.4.6/data/db -logpath=/usr/local/mongodb/mongodb-3.4.6/logs/log --fork --rest

    # 命令行方式启动 加身份验证
    mongod -dbpath=/usr/local/mongodb/mongodb-3.4.6/data/db -logpath=/usr/local/mongodb/mongodb-3.4.6/logs/log --fork --rest --auth

    # 注册服务

    # Copy the init script and config file

    cp mongod.centos /etc/init.d/mongod
    cp mongodb.conf /etc/mongodb.conf

    # Install mongod as a service
    /sbin/chkconfig mongod on

    # 用chmod +x /etc/init.d/mongod 命令允许该脚本可被执行
    chmod +x /etc/init.d/mongod

    # 删除服务
    chkconfig --del mongod

    # 启动或停止服务
    sudo service mongod stop
    sudo service mongod start

    # 注册开机脚本
    chkconfig --add mongod
    chmod +x mongod
    chkconfig mongod on

    # 如果是ubuntu 添加服务,开机启动
    update-rc.d mongod defaults
    # 删除服务
    update-rc.d -f mongod remove

    # 检查并结束进程
    ps -aux|grep mongodb
    kill -s 9 "pid"

  • 相关阅读:
    uniapp 环境变量
    vue 生命周期
    浏览器的工作原理
    monent
    维基百科
    vue 生命周期(二) uniapp
    二进制安装K8S kubctl get node 返回No resources found
    k8s master节点高可用 nginx+keepalived配置文件
    elesticsearch启动
    qt多线程内存崩溃
  • 原文地址:https://www.cnblogs.com/rinack/p/7232725.html
Copyright © 2020-2023  润新知