jaylong 2020-01-10
MongoDB 是文档类数据库(json),是海量级数据存储的数据库
被称为最像关系型数据库的NoSQL
MongoDB 逻辑结构 MySQL逻辑结构
库database 库
集合 表
文档 数据行
(1) redhat或centos6.2 以上系统
(2) 系统开发包完整
(3) ip地址和hosts文件解析正常
(4) iptables防火墙&SElinux关闭
(5) 关闭大页内存机制
root用户下
在vi /etc/rc.local最后添加如下代码
if test -f /sys/kernel/mm/transparent_hugepage/enabled; then
echo never > /sys/kernel/mm/transparent_hugepage/enabled
fi
if test -f /sys/kernel/mm/transparent_hugepage/defrag; then
echo never > /sys/kernel/mm/transparent_hugepage/defrag
fi
临时关闭大页内存
echo never > /sys/kernel/mm/transparent_hugepage/enabled
echo never > /sys/kernel/mm/transparent_hugepage/defrag
cat /sys/kernel/mm/transparent_hugepage/enabled
cat /sys/kernel/mm/transparent_hugepage/defrag
其他系统关闭参照官方文档:
为什么要关闭?
Transparent Huge Pages (THP) is a Linux memory management system
that reduces the overhead of Translation Lookaside Buffer (TLB)
lookups on machines with large amounts of memory by using larger memory pages.
However, database workloads often perform poorly with THP,
because they tend to have sparse rather than contiguous memory access patterns.
You should disable THP on Linux machines to ensure best performance with MongoDB.
创建所需用户和组 useradd mongod passwd mongod 创建mongodb所需目录结构 mkdir -p /mongodb/conf mkdir -p /mongodb/log mkdir -p /mongodb/data 上传并解压软件到指定位置 [ data]# cd /data [ data]# tar xf mongodb-linux-x86_64-rhel70-3.6.12.tgz [ data]# cp -r /data/mongodb-linux-x86_64-rhel70-3.6.12/bin/ /mongodb 设置目录结构权限 chown -R mongod:mongod /mongodb 设置用户环境变量 su - mongod vi .bash_profile export PATH=/mongodb/bin:$PATH source .bash_profile 启动mongodb mongod --dbpath=/mongodb/data --logpath=/mongodb/log/mongodb.log --port=27017 --logappend --fork 登录mongodb [ ~]$ mongo