zoukankan      html  css  js  c++  java
  • centos下安装mongodb

    1.进入linux 服务器

    2.进入/usr/local/下创建mongodb 文件

    3.centos7下载mongodb文件

     wget  https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.0.9.tgz

    4.解压文件

      tar -zxvf mongodb-linux-x86_64-rhel70-4.0.9.tgz

    5.将文件拷贝到指定目录

     mv mongodb-linux-x86_64-rhel70-4.0.9/*  /usr/local/mongodb

    6.在mongodb 下创建logs,data,conf 文件夹

    7.在logs下创建mongodb.log

    touch mongodb.conf

    8.在conf下创建mongodb.conf,配置文档目录

    9.添加环境变量

    进入bin/etc/中 添加环境变量(如果编辑profile是吧,可以打开 ls -a 查看隐藏文件,删除.profile.swp这样的文件)

    10.需要设置生效

    11.启动mongodb服务

    12.链接mongodb数据库

    13.关闭 db.shutdownServer(),或者killall mongod

    14.mongodb 

    cd  /etc/init.d

    MongoDB设置为系统服务并且设置开机启动

    #!/bin/sh
    #
    #chkconfig: 2345 80 90
    #description: mongodb

    if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
    echo never > /sys/kernel/mm/transparent_hugepage/enabled
    fi
    if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
    echo never > /sys/kernel/mm/transparent_hugepage/defrag
    fi

    start() {
    /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/bin/mongodb.conf
    }

    stop() {
    /usr/local/mongodb/bin/mongod -f /usr/local/mongodb/bin/mongodb.conf --shutdown
    }

    case "$1" in
    start)
    start
    ;;
    stop)
    stop
    ;;
    restart)
    stop
    start
    ;;
    *)
    echo $"Usage: $0 {start|stop|restart}"
    exit 1
    esac

    将代码放入mongod中

    chmod –R a+x mongod 设置执行权限

    chkconfig --add mongod #加入系统服务

    chkconfig mongodb on #开机启动

    shutdown -r重启服务器

    启动mongodb service mongod start

    service mongod stop 关闭

    验证是否启动 lsof -i :28001

    报错:

        停止mongodb 运行重新运行

         systemctl daemon-reload

  • 相关阅读:
    php与nginx配置,不能运行php程序
    奇葩php之数组
    奇葩之mysql
    for语法研究
    php short tag不显示排查
    奇葩之mysql【三】我只想获得一个自增Id,我容易吗我
    男女不同
    Restart explorer
    iOS面试贴士
    phpmyadmin万能登陆密码
  • 原文地址:https://www.cnblogs.com/elsons/p/10731291.html
Copyright © 2011-2022 走看看