zoukankan      html  css  js  c++  java
  • 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
  • 相关阅读:
    log4j 日志分级处理
    http接口调用,传递json格式带双引号问题
    测试输出方法执行时间
    关于 propertychange 兼容性问题
    表结构的修改
    固定table表头
    tomcat 的log4j配置问题
    ie 导出不行,不兼容问题,或只出现后缀文件无法识别
    Spring3.x错误----java.lang.ClassNotFoundException:org.aspectj.weaver.reflect.ReflectionWorld$ReflectionWorldException
    Spring3.x错误----java.lang.ClassNotFoundException:org.aopalliance.inter.MethodInterceptor
  • 原文地址:https://www.cnblogs.com/fengjian2016/p/10947775.html
Copyright © 2011-2022 走看看