zoukankan      html  css  js  c++  java
  • 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
    
    
  • 相关阅读:
    寻找完全数(C++)
    莱布尼兹三角形(C++)
    简单的素数问题(C++)
    ubuntu17.04下安装LNMP
    ubuntu下连接mysql出现Access denied for user 'rose'@'localhost' (using password: NO)的解决方法
    快速理解面向对象的PHP编程--基础篇
    百度电面总结
    操作系统基础知识
    快速理解C语言指针
    新手学习MongoDB的基本命令
  • 原文地址:https://www.cnblogs.com/liujitao79/p/6876913.html
Copyright © 2011-2022 走看看