一 通过编辑配置文件启动集群 config/elasticsearch.yml
master配置
# 集群名称
cluster.name: chenkl
# 节点名称
node.name: master
# 存放数据目录,先创建该目录
path.data: /home/elastic/data
# 存放日志目录,先创建该目录
path.logs: /home/elastic/logs
# 节点IP
network.host: 192.168.25.180
# tcp端口
transport.tcp.port: 9300
# http端口
http.port: 9200
# 种子节点列表,主节点的IP地址必须在seed_hosts中
discovery.seed_hosts: ["192.168.25.180","192.168.25.181","192.168.25.182"]
# 主合格节点列表,若有多个主节点,则主节点进行对应的配置
cluster.initial_master_nodes: ["master"]
# 主节点相关配置
node.master: true
node.data: false
node.ingest: false
node.ml: false
cluster.remote.connect: false
# 跨域
http.cors.enabled: true
http.cors.allow-origin: "*"
slave1
cluster.name: chenkl
node.name: slave1
path.data: /home/elastic/data
path.logs: /home/elastic/logs
network.host: 192.168.25.181
transport.tcp.port: 9300
http.port: 9200
discovery.seed_hosts: ["192.168.25.180","192.168.25.181","192.168.25.182"]
cluster.initial_master_nodes: ["master"]
node.master: false
node.data: true
node.ingest: false
node.ml: false
cluster.remote.connect: false
http.cors.enabled: true
http.cors.allow-origin: "*"
slave2
cluster.name: chenkl
node.name: slave2
path.data: /home/elastic/data
path.logs: /home/elastic/logs
network.host: 192.168.25.182
transport.tcp.port: 9300
http.port: 9200
discovery.seed_hosts: ["192.168.25.180","192.168.25.181","192.168.25.182"]
cluster.initial_master_nodes: ["master"]
node.master: false
node.data: true
node.ingest: false
node.ml: false
cluster.remote.connect: false
http.cors.enabled: true
http.cors.allow-origin: "*"
启动所有节点
cd /home/elasticsearch-7.2.0
./bin/elasticsearch
问题 max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
#切换到root用户
vi /etc/sysctl.conf
#在最后追加
vm.max_map_count=262144
#使用 sysctl -p 查看修改结果
sysctl -p
查看集群是否启动成功
查询集群节点
curl -XGET 'http://localhost:9200/_cat/nodes?v'
ip heap.percent ram.percent cpu load_1m load_5m load_15m node.role master name
127.0.0.1 47 96 6 1.26 1.28 0.86 dilm * node-1
127.0.0.1 26 96 6 1.26 1.28 0.86 dilm - node-2
查询单个节点信息
curl -XGET 'http://localhost:9200/'
{
"name" : "node-2",
"cluster_name" : "my-es",
"cluster_uuid" : "LnsMM4p1Royo4Ea19viusw",
"version" : {
"number" : "7.4.2",
"build_flavor" : "default",
"build_type" : "tar",
"build_hash" : "2f90bbf7b93631e52bafb59b3b049cb44ec25e96",
"build_date" : "2019-10-28T20:40:44.881551Z",
"build_snapshot" : false,
"lucene_version" : "8.2.0",
"minimum_wire_compatibility_version" : "6.8.0",
"minimum_index_compatibility_version" : "6.0.0-beta1"
},
"tagline" : "You Know, for Search"
}
二、通过命令行参数启动集群节点
cd /home/elasticsearch-7.2.0
节点1
./bin/elasticsearch -Enode.name=node-1 -Ehttp.port=9200 -Epath.data=/home/elastic/data -Epath.logs=/home/elastic/log
节点2
./bin/elasticsearch -Enode.name=node-2 -Ehttp.port=8200 -Epath.data=/home/elastic/data1 -Epath.logs=/home/elastic/log1