当前位置:Gxlcms > 数据库问题 > 在CentOS 7上安装MongoDB

在CentOS 7上安装MongoDB

时间:2021-07-01 10:21:17 帮助过:9人阅读

参考博文:https://www.jianshu.com/p/ccdd3e884b86

一、安装准备
1、修改系统配置
#关闭selinux、firewall
#修改/etc/security/limits.conf添加以下内容:

  • soft nofile 65536
  • hard nofile 65536
  • soft nproc 65536
  • hard nproc 65536
    #修改/etc/security/limits.d/20-nproc.conf
  • soft nproc 65536
    3、创建账户、目录
    groupadd -g 600 mongo
    useradd -u 600 -g mongo mongo

二、安装步骤
1、解压文件
tar xvf mongodb-linux-x86_64-enterprise-rhel70-3.6.2.tgz -C /usr/local/
cd /usr/local
mv mongodb-linux-x86_64-enterprise-rhel70-3.6.2/ mongodb
cd mongodb
mkdir -p data/db
mkdir log
touch log/mongod.log
mkdir etc
touch etc/mongod.conf
chown -R mongo.mongo /usr/local/mongodb
2、创建配置文件/usr/local/mongodb/data/mongodb/config/mongod.conf
systemLog:
destination: file
path: /usr/local/mongodb/data/mongodb/log/mongod.log
logAppend: true
storage:
journal:
enabled: true
dbPath: /usr/local/mongodb/data/db/
directoryPerDB: true
engine: wiredTiger
wiredTiger:
engineConfig:
cacheSizeGB: 4
directoryForIndexes: true
collectionConfig:
blockCompressor: none
indexConfig:
prefixCompression: true
processManagement:
fork: true
pidFilePath: /usr/local/mongodb/data/mongodb/mongod.pid
net:
port: 27017
bindIp: 192.168.1.213
3、取消透明大页在/etc/rc.d/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
chmod +x /etc/rc.d/rc.local
4、修改环境变量.bash_profile
JAVA_HOME=/usr/local/jdk
CLASSPATH=$JAVA_HOME/lib
PATH=$JAVA_HOME/bin:$PATH:$HOME/bin:/usr/local/mongodb/bin
export PATH JAVA_HOME CLASSPATH
#重新加载.bash_profile
. .bash_profile
5、启动MongoDB
yum install -y net-snmp* gcc-c++
nohup mongod -f /usr/local/mongodb/data/mongodb/config/mongod.conf >/dev/null 2>&1 &
6、登录测试
mongo 192.168.1.213:27017
7、Mongodb C drive安装
tar xvf mongo-c-driver-1.6.1.tar.gz
cd mongo-c-driver-1.6.1/
./configure -disable-automatic-init-and-cleanup
make
make install

在CentOS 7上安装MongoDB

标签:enabled   ever   cache   1.2   dip   加载   href   java   make   

人气教程排行