ES添加新的节点

#es添加新的节点
curl -XGET http://172.21.210.55:9200/_cluster/health?pretty -u elastic:GQgwmKAH5CNlIup53LuZ
curl -XGET http://172.21.210.55:9200/_cat/nodes -u elastic:GQgwmKAH5CNlIup53LuZ
curl -XGET 'http://172.21.210.55:9200/_cat/indices/?v' -u elastic:GQgwmKAH5CNlIup53LuZ
#查看节点缓存
curl 'http://172.21.210.55:9200/_stats/query_cache?pretty&human' -u elastic:GQgwmKAH5CNlIup53LuZ
#通过GET _nodes/node-1/stats/indices查看确认节点分片数为空后停止该节点的elastic服务
curl 'http://172.21.210.40:9200/_nodes/es-2/stats/indices' -u elastic:GQgwmKAH5CNlIup53LuZ |jq

1、初始化新节点的配置

# vi /etc/security/limits.conf
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096

# vim /etc/sysctl.conf
vm.max_map_count=655360

# sysctl -p
2、从现有节点拷贝文件到新节点
 scp -r elasticsearch-8.6.1/ root@172.21.210.36:/usr/local/
 
3、创建用户
groupadd elasticsearch
useradd elasticsearch -g elasticsearch

4、创建目录

mkdir /data1/es/{logs,data} -p
chown -R elasticsearch:elasticsearch /data1/es/
chown -R elasticsearch:elasticsearch /usr/local/elasticsearch-8.6.1

5、修改配置,只用修改节点的名称即可
cluster.name: es-test
node.name: es-4   #修改这个配置,其他配置不变
node.roles: [master,data]

6、启动
#su - elasticsearch
#cd /usr/local/elasticsearch-8.6.1/bin
#./elasticsearch -d

7、验证
[root@host-172-21-210-36 config]# curl -XGET http://172.21.210.36:9200/ -u elastic:GQgwmKAH5CNlIup53LuZ
{
  "name" : "es-4",
  "cluster_name" : "es-test",
  "cluster_uuid" : "7GZrqS-iQW-iFgz0DeUB7g",
  "version" : {
    "number" : "8.6.1",
    "build_flavor" : "default",
    "build_type" : "tar",
    "build_hash" : "180c9830da956993e59e2cd70eb32b5e383ea42c",
    "build_date" : "2023-01-24T21:35:11.506992272Z",
    "build_snapshot" : false,
    "lucene_version" : "9.4.2",
    "minimum_wire_compatibility_version" : "7.17.0",
    "minimum_index_compatibility_version" : "7.0.0"
  },
  "tagline" : "You Know, for Search"
}
[root@host-172-21-210-36 config]# curl -XGET http://172.21.210.55:9200/_cat/nodes -u elastic:GQgwmKAH5CNlIup53LuZ
172.21.210.36 15 45  2  0.67  0.67  0.32 dm - es-4
172.21.210.55 58 99 94 21.45 21.69 21.40 dm - es-3
172.21.210.38 46 98 98 23.18 24.54 23.89 dm - es-1
172.21.210.40 48 99 99 29.05 30.22 29.96 dm * es-2

添加监控

[root@host-172-21-210-55 elasticsearch_exporter]# vi /etc/systemd/system/elasticsearch_exporter.service
[Unit]
Description=elasticsearch_exporter
After=syslog.target network.target
[Service]
Type=simple
RemainAfterExit=no
WorkingDirectory=/usr/local/elasticsearch_exporter/
User=root
Group=root
ExecStart=/usr/local/elasticsearch_exporter/elasticsearch_exporter --es.all --es.indices --es.indices_settings --es.timeout=5s --web.listen-address ":9555" --es.uri http://elastic:GQgwmKAH5CNlIup53LuZ@172.21.210.55:9200
Restart=always
RestartSec=5
[Install]
WantedBy=multi-user.target
posted @ 2023-11-08 14:15  村尚chun叔  阅读(128)  评论(0编辑  收藏  举报