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
    
    
  • 相关阅读:
    二级缓存
    java面试题
    BRD,MRD,PRD文档
    程序做处理时,try..catch和if..else的区别
    关于java中字符串截取
    导出oracle数据库表(备份表)操作命令
    WSDL文件生成java类
    Linux下redis安装(单机版)
    Springboot2.0访问Redis集群
    Spring Cloud Sleuth通过Kafka将链路追踪日志输出到ELK
  • 原文地址:https://www.cnblogs.com/liujitao79/p/6876913.html
Copyright © 2011-2022 走看看