UP | HOME

elk add node solved unassigned shards

Table of Contents

问题

因为之前搭建ELK是单机单节点,运行了一段时间了,今天上服务器查看了下状态,命令如下

$ curl -XGET "http://localhost:9200/_cat/health?v"

突然发现status: yellow,奇怪的是出现了大量unassigned shards。 已经搜索了一下相关资料,都建议新增节点试试,可以解决这个问题;经过尝试,果然解决了这个问题,顺便把搭建过程重新整理一遍( [查看之前整理的](http://www.zshuiquan.com/archives/20161213-elk-notes.html) )

下载

elasticsearch-5.2.2
logstash-5.2.2
kibana-5.2.2-linux-x86_64

logstash udp server

input {
   udp {
	port => 65551
	type => weblog
	codec => json
   }
   udp {
	port => 65552
	type => serverlog
	codec => json
   }
   udp {
	port => 65553
	type => applog
	codec => json
   }
   udp {
	port => 65554
	type => crontablog
	codec => json
   }
}
output {
   elasticsearch {
   hosts => ["localhost:9200", "localhost:9201"]
   }
}

kibana配置

server.port: 8080
server.host: "0.0.0.0"
elasticsearch.url: "http://localhost:9200"
elasticsearch.requestTimeout: 60000

Elasticsearch节点1

cluster.name: logcenter
node.name: node1
node.data: true
node.master: true
discovery.zen.ping.unicast.hosts: ["0.0.0.0:9300", "0.0.0.0:9301"]
discovery.zen.minimum_master_nodes: 1

Elasticsearch节点2

cluster.name: logcenter
node.name: node2
node.data: true
node.master: false
transport.tcp.port: 9301
http.port: 9201
discovery.zen.ping.unicast.hosts: ["0.0.0.0:9300", "0.0.0.0:9301"]
discovery.zen.minimum_master_nodes: 1

其他

### 可以修改 elasticsearch-5.2.2/config/jvm.options 
-Xms3g
-Xmx3g
-XX:+UseConcMarkSweepGC
-XX:CMSInitiatingOccupancyFraction=75
-XX:+UseCMSInitiatingOccupancyOnly
-XX:+DisableExplicitGC
-XX:+AlwaysPreTouch
-server
-Xss1m
-Djava.awt.headless=true
-Dfile.encoding=UTF-8
-Djna.nosys=true
-Djdk.io.permissionsUseCanonicalPath=true
-Dio.netty.noUnsafe=true
-Dio.netty.noKeySetOptimization=true
-Dio.netty.recycler.maxCapacityPerThread=0
-Dlog4j.shutdownHookEnabled=false
-Dlog4j2.disable.jmx=true
-Dlog4j.skipJansi=true
-XX:+HeapDumpOnOutOfMemoryError

启动

#!/bin/bash
nohup /disk1/elk/kibana-5.2.2-linux-x86_64/bin/kibana > /disk1/elk/kibana.log 2>&1 &
nohup /disk1/elk/elasticsearch-5.2.2/bin/elasticsearch -p /tmp/espid/node1.pid > /disk1/elk/esnode1.log 2>&1 &
nohup /disk1/elk/elasticsearch-5.2.2-node2/bin/elasticsearch -p /tmp/espid/node2.pid > /disk1/elk/esnode2.log 2>&1 &
nohup /disk1/elk/logstash-5.2.2/bin/logstash -f /disk1/elk/logstash-5.2.2/config/logstash-udp.conf > /disk1/elk/ls.log 2>&1 &

#保存为start.sh
$ ./start.sh

验收

$ curl -XGET "http://localhost:9200/_cat/health?v"
epoch      timestamp cluster   status node.total node.data shards pri relo init unassign pending_tasks max_task_wait_time active_shards_percent
1489128117 14:41:57  logcenter green           2         2     12   6    0    0        0             0                  -                100.0%
/static/img/20170310145235.png

First created: 2017-03-11 19:15:02
Last updated: 2021-11-25 Thu 23:23
Power by Emacs 27.1 (Org mode 9.4)
© 2017 – 2021 by josephzeng