elasticsearch 常用命令 一直红色 重启不稳定 不停的宕机
persistent (重启后设置也会存在) or transient (整个集群重启后会消失的设置).
查看集群状态和每个indices状态。搜索到red的,没用就删除
GET /_cluster/health?level=indices
DELETE /.monitoring-kibana-6-2019.07.11/
查看所有未重分配的的分片,分片要平均到各个节点
GET /_cat/shards?h=index,shard,prirep,state,unassigned.reason | grep UNASSIGNED
查看分片分配失败原因:
GET /_cluster/allocation/explain?pretty
设置延迟分片重新分配,减轻重启集群一台是马上reblance带来的压力。所以一般重启时关闭重分配:
PUT _cluster/settings
{
"persistent": {
"cluster.routing.allocation.enable": "primaries",
"cluster.routing.rebalance.enable" : "none"
}
}
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更改集群属性,还是建议你把整个集群关闭,重启整个集群。
重启步骤如下:
1、关闭整个集群
curl -XPOST ‘http://IP:9200/_cluster/nodes/_shutdown’
2、修改你要修改的配置项,或者是升级elasticsearch版本。
3、修改每个节点配置文件:
配置:
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
4、线启动master节点,再依次启动所有的其它节点。
5、查看集群状态,直到所有节点加入集群,变为green状态
curl ‘http://ip:9200/_cluster/health?pretty=true’
这
因为第三步的配置,这个过程会很快,即便数据量大,顶多几分钟的事情。
elasticsearch 常用命令 一直红色 重启不稳定 不停的宕机的更多相关文章
- linux常用命令-关机、重启
常用命令-关机.重启 命令 含义 reboot 重新启动操作系 shutdown –r now 重新启动操作系统,shutdown会给别的用户提示 shutdown -h now 立刻关机,其中now ...
- Linux学习笔记(六)Linux常用命令:关机、重启以及系统运行级别
一.shutdown命令 shutdown [选项] [时间] 常用选项 -c 取消前一个关机命令 -h 关机 -r 重启 shutdown命令关机或重启会保存当前系统正在使用的资源,因此关机或重启最 ...
- Linux学习笔记(9)Linux常用命令之关机重启命令
(1)shutdown shutdown命令用于关机重启,其语法格式为: shutdown [选项] 时间 其中,-c选项表示取消前一个设置的shutdown命令,-h命令表示关机,-r命令表示重启 ...
- Linux常用命令——关机与重启命令
1.shutdown命令 shutdown [选项] 时间 --使用shutdown进行关机或重启会正确保存正在使用的服务,其他命令有一定的危险性,建议最好使用shutdown命令进行关机重启 选项: ...
- linux常用命令6:关机重启命令
关机重启命令 1.shutdown命令 shutdown [选项] 时间 选项: -c 取消前一个关机命令 -h 关机 -r 重启 2.其他关机命令 halt poweroff init 0 3.其 ...
- 管理lnmp常用命令,lnmp重启,start|stop|reload|restart等命令
LNMP状态管理命令: LNMP状态管理: /root/lnmp {start|stop|reload|restart|kill|status}Nginx状态管理:/etc/init.d/nginx ...
- Nginx常用命令(启动/重启/停止/测试配置文件/重新加载配置文件)
Nginx 安装后只有一个程序文件,本身并不提供各种管理程序,它是使用参数和系统信号机制对 Nginx 进程本身进行控制的. Nginx 的参数包括有如下几个: 使用: /usr/local/ngin ...
- 【nginx】常用命令 启动|停止|重启|重新读取配置-centOS7
查看服务的当前状态 (flaskApi) [root@67 goTest]# systemctl status nginx.service ● nginx.service - The nginx H ...
- elasticsearch常用命令
elasticsearch的rest访问格式: curl -X<REST Verb> <Node>:<Port>/<Index>/<Type> ...
随机推荐
- 单片机成长之路(51基础篇) - 023 N76e003 系统时钟切换到外部时钟
N76e003切换到外部时钟的资料很少(因为N76e003的片子是不支持无源晶振的,有源晶振的成本又很高,所以网上很少有对N76e003的介绍).有图有真相: 代码如下: main.c #includ ...
- layui 在页面弹出小窗口,并关闭
function showdialog() { layer.open({ type: 2, title: '发起调度', shadeClose: true, shade: 0.8, area: [ ...
- 华为方舟编译器 下载 和 LiteOS Studio Setup 2019-04-16.exe SDK下载
华为方舟编译器是首个取代Android虚拟机模式的静态编译器,可供开发者在开发环境中一次性将高级语言编译为机器码.此外,方舟编译器未来将支持多语言统一编译,可大幅提高开发效率. 编译器下载 [Ark] ...
- javascript 函数表达和闭包
函数表达式和闭包 针对JS高级程序设计这本书,主要是理解概念,大部分要点源自书内.写这个主要是当个笔记加总结 存在的问题请大家多多指正! 定义函数的两种方法 函数声明: function functi ...
- vue-cli的安装及版本查看更新
vue-cli安装 npm install vue-cli -g vue-cli的版本查看 vue -V vue-cli的3.0+以后使用的不是vue-cli了,如果用以上的安装命令安装的并不是最新版 ...
- mysql 多条数据中,分组获取值最大的数据记录
摘要: 多条纪录中,几个字段相同,但是其中一个或者多个字段不同,则去该字段最大(这里只有一个不同) 源数据: 目的是移除:在同一天中只能存在一天数据,则取审核日期最大,数据库脚本如下: SELECT ...
- ASP.NET Core MVC 502 bad gateway 超时如何处理
在网页程序运行需要较长时间运行的时候,ASP.NET Core MVC会出现502 bad gateway请求超时情况.一般默认的超时时间都比较短,我们需要在 web.config 中配置一下.其中 ...
- spoon数据转换中文乱码(kettle)
(1) 查看mysql数据库是否为utf8(status) (2) 设置spoon (3) 文本打开spoon.bat,找到set OPT=%OPT% %PENTAHO_DI_JAVA_OPTIONS ...
- Mysql数据库之备份还原(mysqldump,LVM快照,select备份,xtrabackup)
备份类型: 热备份:读写不受影响 温备份:仅可执行读备份 冷备份:离线备份,读写均不能执行,关机备份 物理备份和逻辑备份 物理备份:复制数据文件,速度快. 逻辑备份:将数据导出之文本文件中,必要时候, ...
- Alipay支付宝调用错误:Call to undefined function openssl_sign()
打开php.ini,找到这一行 ;extension=php_openssl.dll,将前面的“;”去掉: 重启服务器.