#系統默認的最大打開文件數的限制html
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