• mongodb3 设置用户名密码 ,linux


    2015-05-29T09:08:19.328+0800 I CONTROL  [initandlisten] ** WARNING: You are running on a NUMA machine.
    2015-05-29T09:08:19.328+0800 I CONTROL  [initandlisten] **          We suggest launching mongod like this to avoid performance problems:
    2015-05-29T09:08:19.328+0800 I CONTROL  [initandlisten] **              numactl --interleave=all mongod [other options]
    2015-05-29T09:08:19.328+0800 I CONTROL  [initandlisten] 
    2015-05-29T09:08:19.328+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
    2015-05-29T09:08:19.328+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
    2015-05-29T09:08:19.328+0800 I CONTROL  [initandlisten] 
    2015-05-29T09:08:19.328+0800 I CONTROL  [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
    2015-05-29T09:08:19.329+0800 I CONTROL  [initandlisten] **        We suggest setting it to 'never'
    2015-05-29T09:08:19.329+0800 I CONTROL  [initandlisten]

    ===================消除警告====↓========================

    yum install -y numactl
    echo 0 > /proc/sys/vm/zone_reclaim_mode
    # vi /proc/sys/vm/zone_reclaim_mode
    
    echo never > /sys/kernel/mm/transparent_hugepage/enabled
    echo never > /sys/kernel/mm/transparent_hugepage/defrag

    如果是NUMA machine ,启动服务时bin下这样执行
    numactl --interleave=all ./mongod --config /etc/mongodb.conf &
    判读是不是MUMA
    grep -i numa /var/log/dmesg
    NUMA: Allocated memnodemap from 2f000 - 3f840
    NUMA: Using 20 for the hash shift.
    ---------------------------------------------------------

    1./etc/mongodb.conf
    http://docs.mongodb.org/master/reference/configuration-options/
    内容如下:

    systemLog:
       destination: file
       path: "/app/mongodb/mongodb.log"
       logAppend: true
    storage:
       journal:
          enabled: true
       dbPath: "/app/mongodb/data/db"
    net:
       port: 27017
    processManagement:
       fork: true
    security:
       authorization: disabled

    2.请确保配置文件中的path和dbPath存在
    3.
    启动服务命:

    ./mongod --config /etc/mongodb.conf &
    ./mongo
    use admin
    // show users
    // db.system.users.remove({user:"someuser"})
    db.createUser(  
    {  
        user: "admin",  
        pwd: "qwerty",  
        roles:  
        [  
          {  
            role: "userAdminAnyDatabase",  
            db: "admin"  
          } 
        ]  
      }  
    )  
    // db.system.version.find()
    db.system.version.update({ "_id" : "authSchema"},{$set: {"currentVersion" : 3} })
    db.shutdownServer()

    4.修改配置文件中的authorization 为 enabled
    5.启动服务

    ./mongod --config /etc/mongodb.conf &
    ./mongo --port 27017 -u admin -p 'qwerty' --authenticationDatabase admin
    use logtest
    db.createUser(  
        {  
            "user": "user001",  
            "pwd": "asdfgh",  
            "roles":[  
                {  
                    "role": "dbOwner",  
                    "db": "logtest"  
                }  
            ]  
        }  
    )

    备注:没有关闭服务的权限时,重启需要ps&kill

  • 相关阅读:
    VisualStudioCode网页开发常用插件
    java项目报错 :A class file was not written. The project may be inconsistent...
    java抽象类及接口
    博客园首页美化----js添加分割线
    WordPress安全/速度优化(此篇持续更新)
    wordpress宝塔lnmp下安装以及调优(此篇持续更新)
    wordpress之avada安装全过程(此篇持续更新)
    Wordpress之使用阿里云Oss存储
    Linux基础学习(一)虚拟机安装&CentOS8.1安装
    docker安装配置使用
  • 原文地址:https://www.cnblogs.com/zno2/p/4495124.html
Copyright © 2020-2023  润新知