当把 elasticsearch 版本从 2.0.0 升级到 2.1.1 的时候,客户端彻底不可用,接口变化了,所以在升级的时候,须要客户端也升级html
重启整个 elasticsearch 集群以前,须要把副本关闭掉,而后在集群其中成功以后,再开启副本功能node
重启单个 data 节点须要作如下操做,可是这个只针对冷索引git
暂停数据写入程序github
关闭集群shard allocation算法
手动执行POST /_flush/syncedbootstrap
重启节点api
从新开启集群shard allocation服务器
等待recovery完成,集群health status变成greenapp
从新开启数据写入程序curl
删除磁盘上的数据的话,会引发 shard 数据变成默认值,由于只有在初始化的时候才会设置,因此删除后,手工进行初始化便可
中止全部的 ES 节点
中止客户端的数据写入
启动全部的 ES 节点
初始化 shard 数
启动客户端的数据写入
// 手动初始化 template http://ip/_plugin/kopf/#!/indexTemplates "template": "trace*", "settings": { "index": { "number_of_shards": "3", "number_of_replicas": "1" } }, "mappings": { "test": { "_source": { "includes": [ "traceId" ] }, "properties": { "traceId": { "type": "string" }, "binaryAnnotations": { "search_analyzer": "linieAnalzyer", "analyzer": "linieAnalzyer", "index": "analyzed", "type": "string" }, "app": { "index": "not_analyzed", "type": "string" }, "duration": { "type": "long" }, "suc": { "type": "string" }, "bizAnnotations": { "index": "not_analyzed", "type": "string" }, "host": { "index": "not_analyzed", "type": "string" }, "id": { "type": "string" }, "serviceId": { "index": "not_analyzed", "type": "string" }, "spanName": { "type": "string" }, "timestamp": { "type": "long" } } } }, "aliases": { }
中止 data 节点,shard 分配时间恢复,集群数据量大概是 1.26TB
中止1个节点,恢复时间大概是20分钟
中止2个节点,恢复时间大概是55分钟
中止3个节点,恢复时间大概是100分钟
中止5个节点,恢复时间大概是120分钟
ES_HEAP_SIZE 使用不要超过物理内存的一半,最好不要超过 30.5 G
设置 vm.swappiness = 1
在 elasticsearch.yml 中设置 bootstrap.mlockall: true
官方推荐垃圾回收算法针对 ES 应该设置 CMS
search 的 theadpool 推荐设置为 cores * 3,其余线程池推荐和 cores 数量相等
disk I/O 的线程是有 Lucene 处理的,而不是 ES
设置 vm.max_map_count=262144 用于 mmapped files 的虚拟内存
修改配置请使用 API,API,API,而不是修改配置,修改 API 有两种方式,一种临时的,一种持久的,临时的修改当节点下次重启的时候会失效,永久的当下次重启的时候会覆盖静态配置
curl -XPUT ip:9200/_cluster/settings -d '{ "transient": { "logger.discover": "DEBUG" } "persistent": { "discovery.zen.minimum_master_nodes": 2 } }'
设置 slowlog 的阀值有利于定位问题,能够设置 queries, fetches, indexing 的 slowlog
若是你的集群是偏重于 indexing,而对 search 的性能要求不是毫秒级别的返回,能够作些设置作平衡。
Bulk size 比 documents 数量重要,好比 5-15 MB 每一个 bulk
磁盘,首选 SSD,没有 SSD 的话,可使用RAID0
path.data 配置多个路径
避免 segment merging ,当发生的时候, ES 会自动 throttle index 请求到单个线程,当你使用 SSD 的时候,默认的限制 20MB/s 过小了,能够设置成 100-200MB/s
若是在作一个大的 bulk import,能够设置 index.number_of_replicas:0,等到插入完成的时候,再进行 replicas
在升级或者作其余维护须要重启服务器的时候,请保持 ES master 节点是可用的,而后一台台重启 data 节点,最好是能够经过 api 先禁止 shard 分配,若是能够中止 indexing 新数据最好(可是这是不可能的)
执行命令禁止 allocation
PUT /_cluster/settings { "transient": { "cluster.routing.allocation.enable": "none" } }
使用 shutdown api 中止一个节点
POST /_cluster/nodes/_local/_shutdown
执行升级或者维护
重启节点,确认加入了集群
启动 shard allocation
PUT /_cluster/settings { "transient": { "cluster.routing.allocation.enable": "all" } }
其余节点重复1到5步骤
使用 snapshot API 备份,建议备份到 HDFS 中,而后使用 _restore API 来恢复备份。
经过设置 action.disable_delete_all_indices: true. 来禁止经过 API 删除全部索引
indices.fielddata.cache.size: 25%
,在 datanode 设置 indices.cluster.send_refresh_mapping: false
cluster.routing.allocation.cluster_concurrent_rebalance:2
最好设置低一些,这样不会影响索引
cluster.routing.allocation.disk.threshold_enabled:true cluster.routing.allocation.disk.watermark.low:.97 cluster.routing.allocation.disk.watermark.high:.99
恢复:
cluster.routing.allocation.node_concurrent_recoveries:4 cluster.routing.allocation.node_initial_primaries_recoveries:18 indices.recovery.concurrent_streams: 4 indices.recovery.max_bytes_per_sec: 40mb
避免数据丢失和 _bulk 的重试 threadpool.bulk.queue_size: 3000
zabbix 监控 - https://github.com/ejimz/Elasticsearch-zabbix
须要监控的 10 个数据 - http://radar.oreilly.com/2015/04/10-elasticsearch-metrics-to-watch.html
目前使用的是插件监控方式,主要是如下三个插件
bigdesk
kopf
head
这些里面 kopf 目前最好用,bigdesk 从 es 1.x 版本后就不更新了,因此目前 2.x 版本的部分图表没法出来