wsl2搭建ElasticSearch集群
最近杂事多, 要升级生产ElasticSearch集群的版本。本地先做实验,搭建es集群。
wsl2新建3个es路径,代表3个节点。
/data/elasticsearch-7.10.0_0
,/data/elasticsearch-7.10.0_1
,/data/elasticsearch-7.10.0_2
分别改elasticsearch.yml配置
cluster.name: my-application
node.name: node-0
http.port: 9200
transport.tcp.port: 9300
discovery.zen.ping.unicast.hosts: ["localhost:9300","localhost:9301","localhost:9302"]
cluster.initial_master_nodes: ["node-0", "node-1", "node-2"]
剩下2个类似。
启动成功。
http://localhost:9200/_cat/nodes?pretty
127.0.0.1 36 97 2 0.04 0.25 0.35 cdhilmrstw - node-2
127.0.0.1 19 97 3 0.04 0.25 0.35 cdhilmrstw - node-0
127.0.0.1 13 97 2 0.04 0.25 0.35 cdhilmrstw * node-1
升级
stop 所有es服务,
解压es7.15版本,将旧版本的config,data路径软连接到新版本的路径下。 启动所有es节点。
运行成功。但kibana前台管理index显示错误“Error loading indices Cannot read property 'aliases' of undefined”。
同步升级kibana,软连接旧kibana的config和data到新路径。启动,index显示正常。
GET _cluster/health
{
"cluster_name" : "my-application",
"status" : "green",
"timed_out" : false,
"number_of_nodes" : 3,
"number_of_data_nodes" : 3,
"active_primary_shards" : 17,
"active_shards" : 34,
"relocating_shards" : 0,
"initializing_shards" : 0,
"unassigned_shards" : 0,
"delayed_unassigned_shards" : 0,
"number_of_pending_tasks" : 0,
"number_of_in_flight_fetch" : 0,
"task_max_waiting_in_queue_millis" : 0,
"active_shards_percent_as_number" : 100.0
}
禁止自动创建索引
PUT _cluster/settings
{
"persistent": {
"action.auto_create_index": "false"
}
}
{
"acknowledged" : true,
"persistent" : {
"action" : {
"auto_create_index" : "false"
}
},
"transient" : { }
}
# 创建索引
PUT teacher/teacher1/1
{
"name":"t1"
}
# 失败
{
"error" : {
"root_cause" : [
{
"type" : "index_not_found_exception",
"reason" : "no such index [teacher] and [action.auto_create_index] is [false]",
"index_uuid" : "_na_",
"index" : "teacher"
}
],
"type" : "index_not_found_exception",
"reason" : "no such index [teacher] and [action.auto_create_index] is [false]",
"index_uuid" : "_na_",
"index" : "teacher"
},
"status" : 404
}
禁止索引动态增加字段
PUT teacher/_mapping
{
"dynamic": "strict"
}