MongoDB 3.2 在CentOS 上的安裝和配置

jopen 8年前發布 | 55K 次閱讀 MongoDB NoSQL數據庫

一、安裝

編輯/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



來自: http://my.oschina.net/newlooper/blog/598268

 本文由用戶 jopen 自行上傳分享,僅供網友學習交流。所有權歸原作者,若您的權利被侵害,請聯系管理員。
 轉載本站原創文章,請注明出處,并保留原始鏈接、圖片水印。
 本站是一個以用戶分享為主的開源技術平臺,歡迎各類分享!