mongodb 3.4 学习 (一) 安装

it2022-05-05  174

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 "\nsecurity:\n 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 posted on 2017-05-19 10:05 北京涛子 阅读( ...) 评论( ...) 编辑 收藏

转载于:https://www.cnblogs.com/liujitao79/p/6876913.html

相关资源:CentOS7.2 安装 MongoDB 3.4的教程

最新回复(0)