#系統默認的最大打開文件數的限制
vi /etc/security/limits.conf
* - nproc 50240
* - nofile 20480 #65535
* - npro 20480
* - nofile 65535
* - memlock unlimited
vi /etc/sysctl.conf
#儘量不用交換空間
#
#改打開文件數量
vm.max_map_count=655360
#
#網絡優化
net.core.somaxconn = 32768
#設置爲1 而不是0 主要是可能出現內存滿後會亂殺程序
#這個和limit配合,
vm.min_free_kbytes = 65536
fs.nr_open = 20480 #2097152
vm.swappiness = 1
#下面這些,主要是解決http請求高併發的問題,不想改麼用上面的網絡優化
net.core.somaxconn = 4096
net.core.rmem_default = 262144
net.core.wmem_default = 262144
net.core.rmem_max = 16777216
net.core.wmem_max = 16777216
net.core.netdev_max_backlog = 20480
net.ipv4.tcp_max_syn_backlog = 20480
net.ipv4.ip_local_port_range = 1000 65535
net.ipv4.tcp_max_tw_buckets = 400000
net.ipv4.tcp_no_metrics_save = 1
net.ipv4.tcp_syn_retries = 2
net.ipv4.tcp_synack_retries = 2
net.ipv4.tcp_tw_reuse = 1
net.ipv4.tcp_tw_recycle = 1
net.ipv4.tcp_fin_timeout = 15
net.ipv4.tcp_rmem = 4096 65536 16777216
net.ipv4.tcp_wmem = 4096 65536 16777216
net.ipv4.tcp_mem = 786432 2097152 3145728
net.ipv4.tcp_max_orphans = 131072
運行 sysctl -p 命令,使這些系統參數生效。
#關閉swap
swapoff /dev/mapper/vg_"hostname"-lv_swap
#調整每個進程最多可以打開的文件數量和上面的vi /etc/security/limits.conf衝突。。但是都行
vi /etc/profile
ulimit -SH unlimited
ulimit -u unlimited
ulimit -i unlimited
ulimit -l unlimited
ulimit -n 204800
cd/ etc/security/ limits.d
看。。。數字開頭的文件
打開/etc/security/limits.d/90-nproc.conf,
把soft nproc 4024這行的1024改大就行了。
#關閉磁盤文件訪問時間 不知道怎麼弄 可以
#禁止系統對文件的訪問時間更新會有效提高文件讀取的性能
/dev/sdb /data ext4 noatime 0 0
/dev/sdb /data ext4 defaults,noatime,nodiratime 1 2
#防火牆
yum install iptables-services
systemctl mask firewalld.service
systemctl enable iptables.service
systemctl enable ip6tables.service
靜態防火牆規則配置文件是 /etc/sysconfig/iptables 以及 /etc/sysconfig/ip6tables .
注: iptables 與 iptables-services 軟件包不提供與服務配套使用的防火牆規則. 這些服務是用來保障兼容性以及供想使用自己防火牆規則的人使用的. 你可以安裝並使用 system-config-firewall 來創建上述服務需要的規則. 爲了能使用 system-config-firewall, 你必須停止 firewalld.
爲服務創建規則並停用 firewalld 後,就可以啓用 iptables 與 ip6tables 服務了:
systemctl stop firewalld.service
systemctl stop iptables.service
systemctl stop ip6tables.service
#修改默認文件創建權限
echo umask 0022 >> /etc/profile
#調整es 內存使用
vi elasticsearch\bin\service\elasticsearch.conf
#
#兩者最好改成一樣的,否則容易引發長時間GC(stop-the-world)
#HEAP_SIZE設置爲物理內存的60%左右。。
set.default.ES_HEAP_SIZE= 4620
##分配給es的最小內存 讓min == max 建議怎麼做,讓gc跑起來
set.default.ES_MIN_MEM=4620
##分配給es的最大內存
set.default.ES_MAX_MEM=4620
如果你的內存大小超過6G,CMS是不給力的,容易出現stop-the-world
建議使用G1 GC
註釋掉:
JAVA_OPTS=”$JAVA_OPTS -XX:+UseParNewGC”
JAVA_OPTS=”$JAVA_OPTS -XX:+UseConcMarkSweepGC”
JAVA_OPTS=”$JAVA_OPTS -XX:CMSInitiatingOccupancyFraction=75″
JAVA_OPTS=”$JAVA_OPTS -XX:+UseCMSInitiatingOccupancyOnly”
修改爲:
JAVA_OPTS=”$JAVA_OPTS -XX:+UseG1GC”
JAVA_OPTS=”$JAVA_OPTS -XX:MaxGCPauseMillis=200″
G1 GC優點是減少stop-the-world在機率,但是CPU佔有率高。
#注意,如果使用G1垃圾收集器,堆不再使用的內存可能會被歸還給操作系統
#G1垃圾收集器的不足是CPU使用率越高,應用性能越差。因此,如果在內存足夠和CPU能力一般的情況下,CMS可能更勝一籌。
#對於Elasticsearch來說,G1意味着沒有長時間的stop-the-world階段,以及更靈活的內存管理,
#因爲buffer memory和系統I/O緩存能更充分的利用機器內存資源。代價就是小成本的最大化性能,因爲G1利用了更多CPU資源。
#需要更優化的性能,你可以參考
#http://www.oracle.com/webfolder/technetwork/tutorials/obe/java/G1GettingStarted/index.html
#replicas 設置爲0
vi elasticsearch/config/elasticsearch.
index.number_of_replicas:0
#### 等index弄完麼。動態執行下
PUT _all/_settings
{
"index" : {
"number_of_replicas" :1
}
}
###
##配置文件的其他優化
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: ["172.30.1.71","172.30.1.72","172.30.1.52"]
indices.memory.index_buffer_size: 30%
indices.reovery.max_bytes_per_sec: 10gb
index.merge.policy.max_merged_segment: 10gb
index.merge.scheduler.max_thread_count: 3
index.merge.scheduler.max_merge_count: 6
index.refresh_interval: 30s
index.translog.flush_threshold_size: 5gb
index.translog.flush_threshold_ops: 50000
index.cache.field.type: soft
index.cache.field.max_size: 50000
index.cache.field.expire: 10m
index.fielddata.cache: soft
http://stackoverflow.com/questions/28193076/optimize-elasticsearch-jvm
https://discuss.elastic.co/t/miracle-g1-settings-for-30gb-heaps/25271
« 上一篇: centos下Elasticsearch數據遷移與備份
» 下一篇: centos掛存儲