MongoDB 3.2 在CentOS 上的安装和配置
jopen
9年前
一、安装
编辑/etc/yum.repos.d/mongodb-org-3.2.repo
[mongodb-org-3.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.2/x86_64/ gpgcheck=0 enabled=1
yum install -y mongodb-org
二、配置
编辑/etc/mongod.conf
# mongod.conf # for documentation of all options, see: # http://docs.mongodb.org/manual/reference/configuration-options/ # where to write logging data. systemLog: destination: file logAppend: true path: /var/log/mongodb/mongod.log # Where and how to store data. storage: dbPath: /data/mongo journal: enabled: true # engine: # mmapv1: # wiredTiger: # how the process runs processManagement: fork: true # fork and run in background pidFilePath: /var/run/mongodb/mongod.pid # location of pidfile # network interfaces net: port: 27017 bindIp: 127.0.0.1,<内网IP> # Listen to local interface only, comment to listen on all interfaces.注意不要逗号前后不要有空格 #security: #operationProfiling: #replication: #sharding: ## Enterprise-Only Options #auditLog:
执行
echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled echo never > /sys/kernel/mm/transparent_hugepage/defrag
编辑/etc/rc.local,添加
echo never > /sys/kernel/mm/redhat_transparent_hugepage/enabled echo never > /sys/kernel/mm/transparent_hugepage/defrag
编辑vi /etc/security/limits.d/99-mongodb-nproc.conf
# Default limit for number of user's processes to prevent # accidental fork bombs. # See rhbz #432903 for reasoning. * soft nproc 35000 root soft nproc unlimited
三、防火墙
iptables -I INPUT 10 -s <允许ip> -p tcp --destination-port 27017 -m state --state NEW,ESTABLISHED -j ACCEPT iptables -A OUTPUT -d <允许ip> -p tcp --source-port 27017 -m state --state ESTABLISHED -j ACCEPT