elasticsearch8怎么配集群
本文时间用的elasticsearch8的最新版本是elasticsearch-8.3.2,8版本比7版多了验证,配置上有几点较疑惑的地方。
第一步
配第一个节点,还算正常。先解压。
1.执行bin/elasticsearch.bat,启动。启动后会出现以下画面,粘出来到记事本。
------------------------------------------------------------------------------------------------------------------------ -> Elasticsearch security features have been automatically configured! -> Authentication is enabled and cluster connections are encrypted. -> Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`): o_gzcANYbJpKYCm0ypCK -> HTTP CA certificate SHA-256 fingerprint: ab9e1e9809b37676d91128add385fb14ad25ba603236cd0302927cac020cb220 -> Configure Kibana to use this cluster: * Run Kibana and click the configuration link in the terminal when Kibana starts. * Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes): eyJ2ZXIiOiI4LjMuMiIsImFkciI6WyIxOTIuMTY4LjMwLjEyMDo5MjAwIl0sImZnciI6ImFiOWUxZTk4MDliMzc2NzZkOTExMjhhZGQzODVmYjE0YWQyNWJhNjAzMjM2Y2QwMzAyOTI3Y2FjMDIwY2IyMjAiLCJrZXkiOiJoQ19WSklJQmhBS1ZMWHhJMWxWcTpPMU5QWHpNMlJrYUMzUlFGSS1WbDFRIn0= -> Configure other nodes to join this cluster: * On this node: - Create an enrollment token with `bin/elasticsearch-create-enrollment-token -s node`. - Uncomment the transport.host setting at the end of config/elasticsearch.yml. - Restart Elasticsearch. * On other nodes: - Start Elasticsearch with `bin/elasticsearch --enrollment-token <token>`, using the enrollment token that you generated. ------------------------------------------------------------------------------------------------------------------------
2.修改配置config/elasticsearch.yml
先注释掉原来的discovery.seed_hosts,再添加以下配置(192.168.30.120为本机ip)
cluster.name: mac-es bootstrap.memory_lock: false network.host: 192.168.30.120 discovery.seed_hosts: ["192.168.30.147:9300", "192.168.30.120:9300"] cluster.initial_master_nodes: ["node-0", "node-1"] http.port: 9200 transport.port: 9300 node.name: node-1
3.再次用bin/elasticsearch.bat启动。
4.执行以下命令生成token,供后面添加节点使用
bin/elasticsearch-create-enrollment-token -s node
关于kibana
其实第1步后就可以在本机启kibana.bat了,这时再启也行,需要用上第一步生成的key.
第二步
配置第二个节点
1.解压,不要改配置 执行
./elasticsearch --enrollment-token 主节点第4步生成的node值2.会报错,说不能加入集群,因为集群名字不对。不用管,停掉进程
3.修改../config/elasticsearch.yml ,
先注释掉原来的discovery.seed_hosts,再添加以下配置(192.168.30.147为本机ip)
node.name: node-0 network.host: 192.168.30.147 discovery.seed_hosts: ["192.168.30.147:9300", "192.168.30.120:9300"] cluster.initial_master_nodes: ["node-0", "node-1"] cluster.name: mac-es4.再次启动,正常启动
./elasticsearch
最后,验证结果
在第一个节点上启动的kibana里(Dev Tools)执行
GET /_cat/nodes是不是有两个节点了,证明集群搭好了,进行增删改查的验证吧。
相关阅读
评论:
↓ 广告开始-头部带绿为生活 ↓
↑ 广告结束-尾部支持多点击 ↑