persistent (重启后设置也会存在) or transient (整个集群重启后会消失的设置).html
查看集群状态和每一个indices状态。搜索到red的,没用就删除node
GET /_cluster/health?level=indicesspring
DELETE /.monitoring-kibana-6-2019.07.11/bootstrap
查看全部未重分配的的分片,分片要平均到各个节点api
GET /_cat/shards?h=index,shard,prirep,state,unassigned.reason | grep UNASSIGNED 安全
查看分片分配失败缘由:服务器
GET /_cluster/allocation/explain?pretty并发
设置延迟分片从新分配,减轻重启集群一台是立刻reblance带来的压力。因此通常重启时关闭重分配:less
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "primaries",
"cluster.routing.rebalance.enable" : "none"
}
}curl
PUT /_all/_settings
{
"settings": {
"index.unassigned.node_left.delayed_timeout": "15m"
}
}
#动态设置es索引副本数量
curl -XPUT 'http://168.7.1.67:9200/log4j-emobilelog/_settings' -d '{
"number_of_replicas" : 2
}'
#设置es不自动分配分片
curl -XPUT 'http://168.7.1.67:9200/log4j-emobilelog/_settings' -d '{
"cluster.routing.allocation.disable_allocation" : true
}'
#手动移动分片
curl -XPOST "http://168.7.1.67:9200/_cluster/reroute' -d '{
"commands" : [{
"move" : {
"index" : "log4j-emobilelog",
"shard" : 0,
"from_node" : "es-0",
"to_node" : "es-3"
}
}]
}'
#手动分配分片
curl -XPOST "http://168.7.1.67:9200/_cluster/reroute' -d '{
"commands" : [{
"allocate" : {
"index" : ".kibana",
"shard" : 0,
"node" : "es-2",
}
}]
}'
设置恢复并发和每秒的大小:
"cluster.routing.allocation.node_concurrent_recoveries": 100, "indices.recovery.max_bytes_per_sec": "40mb"
开启疯狂写入模式能够先禁用refresh
curl -XPUT localhost:9200/my_index/_settings -d '{"index":{"refresh_interval":-1}}'
暂时关闭副本:
curl -XPUT 'localhost:9200/my_index/_settings' -d '
{
"index" : {
"number_of_replicas" : 1
}
}'
查看当前线程池、查看当前节点信息
curl -XGET 'http://localhost:9200/_nodes/stats?pretty'
curl -XGET 'localhost:9200/_cat/nodes?h=name,ram.current,ram.percent,ram.max,fielddata.memory_size,query_cache.memory_size,request_cache.memory_size,percolate.memory_size,segments.memory,segments.index_writer_memory,segments.index_writer_max_memory,segments.version_map_memory,segments.fixed_bitset_memory,heap.current,heap.percent,heap.max,\&v'
curl -XPOST "localhost:9200/_cache/clear"
es节点重启注意点:
##第一步:先暂停集群的shard自动均衡。##
curl -XPUT http://192.168.1.2:9200/_cluster/settings -d’
{
“transient” : {
“cluster.routing.allocation.enable” : “none”
}
}’
##第二步:shutdown你要升级的节点##
curl -XPOST http://192.168.1.8:9200/_cluster/nodes/_local/_shutdown
##第三步:升级重启该节点,并确认该节点从新加入到了集群中##
##第四步:重复2-3步,升级重启其它要升级的节点。##
##第五步:重启启动集群的shard均衡##
curl -XPUT http://192.168.1.2/_cluster/settings -d’
{
“transient” : {
“cluster.routing.allocation.enable” : “all”
}
}’
————————————————
版权声明:本文为CSDN博主「马立弘」的原创文章,遵循CC 4.0 by-sa版权协议,转载请附上原文出处连接及本声明。
原文连接:https://blog.csdn.net/manimanihome/article/details/93883301
!!!没有template的数据字段类型又多变 极可能拖累es
https://www.elastic.co/guide/en/elasticsearch/guide/current/indexing-performance.html#_using_and_sizing_bulk_requests
Segment merging 拖慢写数据时会有日志
now throttling indexing
默认是20MB 若是ssd建议100-200
PUT /_cluster/settings
{
"persistent" : {
"indices.store.throttle.max_bytes_per_sec" : "100mb"
}
}
若是只录入数据,不作索引查询,甚至能够关掉这个(从新打开将其设置为merge)
PUT /_cluster/settings
{
"transient" : {
"indices.store.throttle.type" : "none"
}
}
机械硬盘减小磁盘io压力方法
(This setting will allow max_thread_count + 2 threads to operate on the disk at one time, so a setting of 1 will allow three threads.)
For SSDs, you can ignore this setting. The default is Math.min(3, Runtime.getRuntime().availableProcessors() / 2), which works well for SSD.
这个是写在配置文件elasticsearch.yml配置文件的
index.merge.scheduler.max_thread_count: 1
Finally, you can increase index.translog.flush_threshold_size from the default 512 MB to something larger, such as 1 GB.
!!!这样能减轻磁盘压力,但会加剧内存压力
This allows larger segments to accumulate in the translog before a flush occurs.
By letting larger segments build, you flush less often, and the larger segments merge less often.
All of this adds up to less disk I/O overhead and better indexing rates
知道哪一个索引的哪一个分片就开始手动修复,经过reroute的allocate分配
curl -XPOST '{ESIP}:9200/_cluster/reroute' -d '{
"commands" : [ {
"allocate" : {
"index" : "eslog1",
"shard" : 4,
"node" : "es1",
"allow_primary" : true
}
}
]
}'
https://www.cnblogs.com/seaspring/p/9322582.html
ELK的内外网配置:
network.bind_host: 多个地址,能够是内网,外网同时能够访问
network.publish_host: es集群间交互通讯地址。若是同时有内网,外网,咱们将他设定为这台服务器的内网地址。分片复制会更快。
network.host: 0.0.0.0 指绑到全部的网卡IP上,若是一台服务器有多个地址,外网,内网 (若是没有设置上面两个选项,上面两个选项的默认值就是它。)
个数为(master候选节点个数/2)+1. 这里有几个例子:
*若是你有10个节点(能保存数据,同时能成为master) 法定数就是6
*若是你有3个候选master,和100个数据节点,法定数就是2,你只要数数那些能够作master的节点数就能够了。
PUT /_cluster/settings
{
“persistent” : {
“discovery.zen.minimum_master_nodes” : 2
}
}
-
集群恢复config/elasticsearch.yml:
在发现8个节点(数据节点或者master节点)才启动平衡恢复:
gateway.recover_after_nodes: 8
应该有多少个节点,而且咱们但愿集群须要多久等待全部节点:
gateway.expected_nodes: 10
gateway.recover_after_time: 5m
综合上面三个条件,这意味着Elasticsearch会采起以下操做:
*至少等待8个节点上线
*等待5分钟,或者10个节点上线后,才进行数据恢复,这取决于哪一个条件先达到。
不须要包含你的集群中的全部节点,它只须要包含足够一个新节点联系上其中一个而且说上话就ok了。若是你使用master候选节点做为单播列表,你只要列出三个就能够了。这个配置在elasticsearch.yml文件中:
discovery.zen.ping.multicast.enabled: false
discovery.zen.ping.unicast.hosts: [“host1”, “host2:port”]
备注:请确认你已经关闭了组播(discovery.zen.ping.multicast.enabled: false),不然它会和单播同时存在。
监控节点(index)
GET _nodes/stats
elasticsearch如何安全重启节点(续)
以前分享的一篇文章介绍了如何滚动rolling重启elasticsearch集群。可是当数据量很大的时候,可能那种方式并不适合修改整个集群的配置。
若是你没法经过api更改集群属性,仍是建议你把整个集群关闭,重启整个集群。
重启步骤以下:
一、关闭整个集群
curl -XPOST ‘http://IP:9200/_cluster/nodes/_shutdown’
二、修改你要修改的配置项,或者是升级elasticsearch版本。
三、修改每一个节点配置文件:
配置:
gateway.expected_nodes: 10
gateway.recover_after_time: 5m
gateway.recover_after_nodes: 8
minimum_master_nodes: 2
以上参考:http://zhaoyanblog.com/archives/745.html
配置:bootstrap.mlockall: true
以上参考:http://zhaoyanblog.com/archives/826.html
四、线启动master节点,再依次启动全部的其它节点。
五、查看集群状态,直到全部节点加入集群,变为green状态curl ‘http://ip:9200/_cluster/health?pretty=true’这由于第三步的配置,这个过程会很快,即使数据量大,顶多几分钟的事情。