logstash导入五十多万条的ngnix日志非常慢!!!
Logstash • laoyang360 回复了问题 • 3 人关注 • 2 个回复 • 1896 次浏览 • 2018-07-16 23:47
ES的集群平衡算法是怎么算的啊?请教
Elasticsearch • yayg2008 回复了问题 • 4 人关注 • 2 个回复 • 5184 次浏览 • 2018-07-18 09:33
time picker未正常显示
Kibana • rockybean 回复了问题 • 2 人关注 • 1 个回复 • 1787 次浏览 • 2018-07-13 15:47
es5 想删除一项settings配置 怎么删
Elasticsearch • rockybean 回复了问题 • 4 人关注 • 2 个回复 • 4899 次浏览 • 2018-07-13 15:31
集群环境下java单例查询多了就异常
Elasticsearch • JackGe 回复了问题 • 2 人关注 • 1 个回复 • 2624 次浏览 • 2018-07-14 22:11
kibana 找不到Elasticsearch 节点
Elasticsearch • yu754369677 回复了问题 • 3 人关注 • 4 个回复 • 7141 次浏览 • 2018-07-13 14:33
Rollup 功能对超时数据的处理是否支持
Elasticsearch • fanmo3yuan 回复了问题 • 5 人关注 • 4 个回复 • 4103 次浏览 • 2018-11-05 15:56
elasticsearch Scroll size问题
Elasticsearch • God_lockin 回复了问题 • 2 人关注 • 1 个回复 • 5493 次浏览 • 2018-07-15 21:58
logstash6.3.0 通过配置文件启动报错
Logstash • zqc0512 回复了问题 • 2 人关注 • 2 个回复 • 3738 次浏览 • 2018-07-16 09:50
es的group by在多shard下是不精确的?
Elasticsearch • zhangg7723 回复了问题 • 5 人关注 • 3 个回复 • 2917 次浏览 • 2018-08-03 20:24
如何一次过得出某个特定条件的某字段在所有数据里面的排名
回复Elasticsearch • Lanfice 发起了问题 • 1 人关注 • 0 个回复 • 1189 次浏览 • 2018-07-13 11:02
如何对聚合得到的结果再次统计
Elasticsearch • ziyou 回复了问题 • 4 人关注 • 2 个回复 • 5130 次浏览 • 2019-08-13 14:58
社区日报 第331期 (2018-07-13)
社区日报 • laoyang360 发表了文章 • 0 个评论 • 1250 次浏览 • 2018-07-13 06:25
http://t.cn/RdDZL7C
2、Elasticsearch must_not为什么相对较慢?
http://t.cn/RdDZtfq
3、Function Score Query优化Elasticsearch搜索结果
http://t.cn/RdDZJRP
活动预告
1. 7月21日上海meetup倒计时(更大场地,等您来!)
https://elasticsearch.cn/m/article/655
2. Elastic 中国开发者大会 2018 ,开始接受演讲申请和赞助合作
https://conf.elasticsearch.cn/2018/shenzhen.html
编辑:铭毅天下
归档:https://elasticsearch.cn/article/712
订阅:https://tinyletter.com/elastic-daily
Es能否实现sql全数据的group by
Elasticsearch • dx420811682 回复了问题 • 3 人关注 • 2 个回复 • 9405 次浏览 • 2018-07-13 10:54
聊聊ELASTICSEARCH的集群状态的管理和维护
Elasticsearch • vearne 发表了文章 • 2 个评论 • 5977 次浏览 • 2018-07-12 22:49
注意 本文参考的ES 5.0.1的源码
1. 查看集群状态
可以通过API查看集群状态
<br /> GET /_cluster/state<br />
大致可以得到如下内容
![cluster_state](https://ut-bucket01.sh1a.qings ... 7.jpeg)
version
集群状态数字版本号
每次更新version + 1
集群重启version不会置0(只会单调增)
state_uuid
是集群状态字符串版本号(UUID)
master_node
master节点
nodes
该版本中的所有节点信息
routing_table
和 routing_nodes
都是描述不同index上的shard在node上的分布关系
2. 集群状态的维护
可以阅读
.//core/src/main/java/org/elasticsearch/cluster/ClusterState.java
- 2.1 ClusterState是不可变对象,每次状态变更都会产生新的ClusterState,它们拥有不同的版本号
- 2.2 在ES中, 集群状态由Master维护,并且只能由master节点更新集群状态
- 2.3 更新完成后,Master会把新版本的集群状态推送给集群的其它所有节点
对于publish,Master节点会根据它已知其它节点所拥有的集群状态版本,决定是执行
sendFullClusterState()
还是sendClusterStateDiff()
, 前者是全量推送,后者增量推送。
- 2.4 对于使用Zen Discovery的情况,只要有minimumMasterNodes响应了Master节点的
publish
消息, 那么这次的commit
就算成功
The cluster state can be updated only on the master node. All updates are performed by on a single thread and controlled by the {@link ClusterService}. After every update the
{@link Discovery#publish} method publishes new version of the cluster state to all other nodes in the cluster.
In the Zen Discovery it is handled in the {@link PublishClusterStateAction#publish} method
- 2.5 另外需要补充的是Elasticsearch使用Gossip + Bully算法进行选主。Bully算法在具体实现中,不是简单选取节点ID小的节点, 首先要先比较ClusterState的版本。版本高的优先当选。(各个版本实现有不同,但都需要考虑候选节点的集群状态版本)
<br /> /**<br /> * Elects a new master out of the possible nodes, returning it. Returns <tt>null</tt><br /> * if no master has been elected.<br /> */<br /> public MasterCandidate electMaster(Collection<MasterCandidate> candidates) {<br /> assert hasEnoughCandidates(candidates);<br /> List<MasterCandidate> sortedCandidates = new ArrayList<>(candidates);<br /> sortedCandidates.sort(MasterCandidate::compare);<br /> return sortedCandidates.get(0);<br /> }<br />
<br /> /**<br /> * compares two candidates to indicate which the a better master.<br /> * A higher cluster state version is better<br /> *<br /> * @return -1 if c1 is a batter candidate, 1 if c2.<br /> */<br /> public static int compare(MasterCandidate c1, MasterCandidate c2) {<br /> // we explicitly swap c1 and c2 here. the code expects "better" is lower in a sorted<br /> // list, so if c2 has a higher cluster state version, it needs to come first.<br /> int ret = Long.compare(c2.clusterStateVersion, c1.clusterStateVersion);<br /> if (ret == 0) {<br /> ret = compareNodes(c1.getNode(), c2.getNode());<br /> }<br /> return ret;<br /> }<br /> }<br />
参考资料
- [cluster-state](https://www.elastic.co/guide/e ... e.html)
欢迎光临我的个人博客 萌叔 | http://vearne.cc
- [cluster-state](https://www.elastic.co/guide/e ... e.html)