错误描述
今天在虚拟机上用docker启动elasticsearch7.6.2,启动成功后,通过浏览器访问虚拟机es,可以成功访问,但是用es-head连接es时却报错:
{"error":{"root_cause":[{"type":"cluster_block_exception","reason":"blocked by: [SERVICE_UNAVAILABLE/1/state not recovered / initialized];"}],"type":"cluster_block_exception","reason":"blocked by: [SERVICE_UNAVAILABLE/1/state not recovered / initialized];"},"status":503}
解决方案
修改es的config目录下的配置文件elasticsearch.yml。
原来的配置文件如下:
cluster.name: "docker-cluster"
network.host: 0.0.0.0
bootstrap.system_call_filter: false
cluster.initial_master_nodes: ["node-1"]
http.cors.enabled: true
http.cors.allow-origin: "*"
修改cluster.name后配置文件如下:
node.name: "node-1"
network.host: 0.0.0.0
bootstrap.system_call_filter: false
cluster.initial_master_nodes: ["node-1"]
http.cors.enabled: true
http.cors.allow-origin: "*"
然后重启docker(docker restart es),其中es是自己的容器名称。再次连接就可以连接上了。