• mongodb 3.4 学习 (一) 安装


    https://www.mongodb.com/blog/post/capacity-planning-and-hardware-provisioning-mongodb-ten-minutes

    安装

    yum -y install mongodb-org*
    systemctl enable mongod && systemctl restart mongod
    

    mongo命令行客户端登录有警告,用以下方法消除

    #1. 数据目录需要用xfs
     ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
     **          See http://dochub.mongodb.org/core/prodnotes-filesystem
    
    opt分区格式化为xfs,将数据目录/var/lib/mongo迁移到/opt,并建立软链接
    cd /var/lib && mv mongo /opt && ln -s /opt/mongo mongo
    
    #2. mongodb默认是无密码登录,有风险 
     ** WARNING: Access control is not enabled for the database.
     **          Read and write access to data and configuration is unrestricted.
     
    建立管理员admin,对所有数据库有userAdmin权限
    db.createUser({user: 'admin', pwd: '@admin', roles: [{role: 'userAdminAnyDatabase', db: 'admin'}]})
    
    建立用户test,仅对test数据库有读写权限
    use test
    db.createUser({user: 'test', pwd: '@test', roles: [{role: 'readWrite', db: 'test'}]})
    
    重新启动mongo服务,启动权限认证功能
    echo -e "
    security:
      authorization: enabled" >> /etc/mongod.conf
    systemctl restart mongod
    
    用户认证
    db.auth('admin', '@admin')
    
    #3. linux的cpu各核内存共享的机制,在bios或者内核禁用
     ** WARNING: You are running on a NUMA machine.
     **          We suggest launching mongod like this to avoid performance problems:
     **              numactl --interleave=all mongod [other options]
    
    vim /etc/default/grub
    GRUB_CMDLINE_LINUX="crashkernel=auto rhgb quiet numa=off"
    
    grub2-mkconfig -o /boot/grub2/grub.cfg
    
    #4. transparent_hugepage机制,在内核中禁用
     ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is 'always'.
     **        We suggest setting it to 'never'
     
     ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is 'always'.
     **        We suggest setting it to 'never'
    
    cat > /lib/systemd/system/disable_transparent_hugepage.service << EOF
    [Unit]
    Description="Disable Transparent Hugepage before MongoDB boots"
    Before=mongodb.service 
    
    [Service]
    Type=oneshot
    ExecStart=/bin/bash -c 'echo never > /sys/kernel/mm/transparent_hugepage/enabled'
    ExecStart=/bin/bash -c 'echo never > /sys/kernel/mm/transparent_hugepage/defrag'
    
    [Install]
    RequiredBy=mongod.service
    EOF
    
    systemctl enable disable_transparent_hugepage && systemctl start disable_transparent_hugepage
    systemctl restart mongod
    
    
  • 相关阅读:
    集合已修改 ;可能无法执行枚举操作 Dictionary
    net 操作XML小结
    SQL SERVER 2000写存储过程出现列名无效的解决方法
    .net如何获得前一页面的地址
    SQL字符串叠加问题
    c# 保留2位小数
    如何取字符字段的第几个字符,如取name的左边从2位起的2个字符?
    SQL语句复制表的方法
    给页面加上Loading效果最简单实用的办法
    为XMl文档添加子节点,依据淘宝
  • 原文地址:https://www.cnblogs.com/liujitao79/p/6876913.html
Copyright © 2020-2023  润新知