ElasticSearch相关面试题
此题是xx位面试题
(1)有两个机房,每个机房两台服务器,总共有4台服务器搭建的ES集群,怎么控制所有副本在一个机房或者某些节点里面。
可以通过打标签的形式,指定哪些索引的主分片在哪个节点上。
首先指定节点的类型:
## 指定节点类型 方式
node.attr.box_type: "type" # type为该node类型 自定义
### 参考文章
https://blog.csdn.net/knight_zhou/article/details/131468721
通过Kibana 配置index属性:
a. 设置已有的index 到指定node上:
PUT /test-index/_settings
{
"settings": {
"index.routing.allocation.require.box_type": "hot",
"index.number_of_replicas": "0"
}
}
b. 在模板中指定类型
PUT _template/active-logs
{
"template": "active-logs-*",
"settings": {
"number_of_shards": 5,
"number_of_replicas": 1,
"routing.allocation.include.box_type": "h