• mongodb4.0 安装


    下载:

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

    解压缩

    tar -zxvf mongodb-linux-x86_64-4.0.9.tgz
    
    mv mongodb-linux-x86_64-4.0.9 ../mongodb
    
    mkdir -p /data/mongodb/{data,logs,etc}

    编辑配置文件

    vi /data/mongodb/etc/mongod.conf 
    
        # where to write logging data.
        systemLog:
          destination: file
          logAppend: true
          path: /data/mongodb/logs/mongod.log
    
        # Where and how to store data.
        storage:
          dbPath: /data/mongodb/data
          journal:
            enabled: true
        #  engine:
        #  mmapv1:
        #  wiredTiger:
    
        # how the process runs
        processManagement:
          fork: true  # fork and run in background
          pidFilePath: /data/mongodb/run/mongod.pid  # location of pidfile
    
        # network interfaces
        net:
          port: 27017
          bindIp: 0.0.0.0  # Listen to local interface only, comment to listen on all interfaces.
    
        #security:

    cat  /lib/systemd/system/mongod.service

        [Unit]
        Description=High-performance, schema-free document-oriented database
        After=network.target
        Documentation=https://docs.mongodb.org/manual
    
        [Service]
        User=root
        Group=root
        Environment="OPTIONS=-f /data/mongodb/etc/mongod.conf"
        ExecStart=/data/mongodb/bin/mongod $OPTIONS
        ExecStartPre=/usr/bin/mkdir -p /data/mongodb/data
        PermissionsStartOnly=true
        PIDFile=/data/mongodb/run/mongod.pid
        Type=forking
        # file size
        LimitFSIZE=infinity
        # cpu time
        LimitCPU=infinity
        # virtual memory size
        LimitAS=infinity
        # open files
        LimitNOFILE=64000
        # processes/threads
        LimitNPROC=64000
        # locked memory
        LimitMEMLOCK=infinity
        # total threads (user+kernel)
        TasksMax=infinity
        TasksAccounting=false
        # Recommended limits for for mongod as specified in
        # http://docs.mongodb.org/manual/reference/ulimit/#recommended-settings
    
        [Install]
        WantedBy=multi-user.target

    授权

    use admin
    db.createUser({ user: "root", pwd: "Abcd,1234", roles: [{ role: "root", db: "admin" }] })
    
    use im_db_v2
    db.createUser({ user: "mongoadmin", pwd: "abc123456789", roles: [ { role: "readWrite", db: "im_db_v2" }]})
    
    db.auth("mongoadmin","abc123456789")
    db.im_db_v2.insert({"name":"baby"})

    配置文件添加

    security:
    authorization: enabled



    重启mongodb

    systemctl  restart  mongod
  • 相关阅读:
    My97 DatePicker 的jQuery插件
    UITableView 的 delegate2个基本方法
    你还在使用myImage = [UIImage imageNamed:@"icon.png"];吗
    自动生成数学题型三 (框架Struts2)题型如 a+b=c(a、b、c都为分数)
    自动生成数学题型二(框架struts2)题型如((a+b)*c=d)
    自动生成数学题型一 (框架Struts2) 题型如(a+b=c)
    创业团队应具备的要素
    在服务器中linux的centos系统如何封ip
    创业成功:必须具备的12个要点
    PHP+mysqli如何连接MySQL数据库,MySQL, Improved
  • 原文地址:https://www.cnblogs.com/fengjian2016/p/10947775.html
Copyright © 2020-2023  润新知