CentOS 6.5針對MongoDB叢集應該調整和優化哪些核心引數?

chenfeng發表於2016-07-18
1.修改 Max processes 或者 files (Max processes,Max open files )
(1)方法一:修改配置檔案 /etc/security/limits.d/90-nproc.conf 
   使用vi /etc/security/limits.d/90-nproc.conf  命令
*          soft    nproc     1024
改為:
*          soft    nproc     65536
然後重啟MongoDB的相關服務即可
(2)方法二:修改配置檔案 /etc/security/limits.conf
 使用vi /etc/security/limits.conf 命令
*  soft   nofile 65536
*  hard   nofile 65536
*  soft   nproc 65536
*  hard  nproc 65536


重啟 mongod 服務


檢視系統限制:ulimit -a
MongoDB推薦配置:
ulimit -f unlimited
ulimit -t unlimited
ulimit -v unlimited
ulimit -n 64000
ulimit -m unlimited
ulimit -u 64000


2.關閉透明大頁功能
禁用透明大頁的方法:
(1).修改檔案/etc/grub.conf,新增一行:transparent_hugepage=never
(2)修改檔案/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


3.修改磁碟排程演算法:
echo deadline > /sys/block/sda/queue/scheduler


4.設定Linux核心引數:
vi /etc/sysctl.conf
net.ipv4.ip_forward = 1
net.ipv4.tcp_syncookies = 1
kernel.msgmnb = 65536
kernel.msgmax = 65536
kernel.shmmax = 483183820800
kernel.shmall = 117964800
net.ipv4.tcp_max_tw_buckets = 180000
net.ipv4.tcp_rmem = 4096 87380 4194304
net.ipv4.tcp_wmem = 4096 16384 4194304
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 262144
net.core.somaxconn = 262144
net.ipv4.tcp_syn_retries = 3
net.ipv4.tcp_retries2 = 5
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_mem = 94500000 915000000 927000000
net.ipv4.tcp_fin_timeout = 30
net.ipv4.tcp_keepalive_time = 300
net.ipv4.tcp_keepalive_probes = 3
net.ipv4.tcp_keepalive_intvl = 30
net.ipv4.ip_local_port_range = 1024 65535
vm.zone_reclaim_mode = 0
vm.dirty_writeback_centisecs = 400
vm.dirty_expire_centisecs = 2400
vm.dirty_background_ratio = 5
vm.dirty_ratio = 20
vm.drop_caches = 1
vm.min_free_kbytes = 52428800
vm.vfs_cache_pressure = 200
fs.file-max = 98000
kernel.pid_max = 64000
kernel.threads-max = 64000




來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2122155/,如需轉載,請註明出處,否則將追究法律責任。

相關文章