elasticsearch 性能优化

 

 #系统默认的最大打开文件数的限制

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挂存储

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值