mongodb 3.4 学习 (一) 安装
2024-09-04 11:40:01
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
最新文章
- 【UWP】FlipView绑定ItemsSource,Selectedindex的问题
- 关于多线程情况下Net-SNMP v3 版本导致进程假死情况的跟踪与分析
- C#类的继承相关总结
- 20145236 冯佳 《Java程序设计》第3周学习总结
- Unity3D之移植学习笔记:移植到Android平台
- Git branch (分支学习)
- V9 二次开发技术篇之 模型数据库
- 关于IoAttachDeviceToDeviceStack
- 云计算:创业的好时机——上海够快网络科技有限公司总经理蒋烁淼专访(评价阿里云的OSS的4个优点)(够快科技正式宣布已成功挂牌新三板)
- drupal7 开发自定义上传、下载模块的上传功能
- flex-骰子布局
- ffmpeg转码器移植VC的project:ffmpeg for MFC
- Delphi 集合和字符串互转
- spring mvc项目中导出excel表格简单实现
- Mask R-CNN详解和安装
- strip() 只去头尾的,不能去中间
- 写在OI退役后和高中毕业前的一些话
- c++动态规划dp算法题
- 开启Visual Studio 2013时,出现Microsoft.VisualStudio.Web.PasteJson.JsonPackage无法载入的可能解決方案
- centos 源码安装php5.5
热门文章
- XSS攻击的防御
- 【原创】SpringMVC同一RequestMapping返回不同的类型
- AtCoder Beginner Contest 113 A
- UVA - 10543 LIS
- [转] NOI, NOIP, IOI, ACM
- [转] Spring Boot 揭秘与实战(二) 数据存储篇 - ElasticSearch
- vue 浏览器顶部有载入(进度)动画插件vue-progressbar
- CAD 卸载工具,完美彻底清除干净cad各种残留注册表和文件
- HDFS基本工具类的实现
- innosetup卸载软件后,删除定时任务schedule task