ElasticSearch一台机器搭建多节点集群

必须有JDK环境

官网下载ES,本文是7.16.2 官网下载

上传至服务器后,解压

tar -xvf elasticsearch-7.16.2-linux-x86_64.tar.gz

修改配置  

elasticsearch.yml  ES配置项

cluster.name: hanweihuES
node.name: node-1
path.data: /opt/software/elasticsearch-7.16.2/data
path.logs: /opt/software/elasticsearch-7.16.2/logs

network.host: 0.0.0.0
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"

discovery.seed_hosts: ["127.0.0.1", "[::1]"]
discovery.zen.minimum_master_nodes: 2

cluster.initial_master_nodes: ["node-1", "node-2", "node-3"]

jvm.options:JVM参数设置,只修改两个参数,XmsXmx值一致即可

-Xms256m
-Xmx256m

修改Linux系统设置

vi /etc/security/limits.conf   在文末添加以下两行
es hard nofile 65537
es soft nofile 65535

vi /etc/sysctl.conf    在文末添加以下一行
vm.max_map_count=655360

放行主节点port
iptables -A INPUT -p tcp --dport 9201 -j ACCEPT
iptables -A OUTPUT -p tcp --sport 9201 -j ACCEPT

 创建ES用户

groupadd es       # 创建用户组
useradd es -g es  # 创建用户并添加至用户组
passwd es         # 更改用户密码(输入 123123)

修改ES目录权限

chown -R es:es /opt/software/elasticsearch-7.16.2/

es用户启动ES三个节点

su es
cd /opt/software/elasticsearch-7.16.2
./bin/elasticsearch -Ehttp.port=9201 -Epath.data=/opt/software/elasticsearch-7.16.2/data/node1_data -Epath.logs=/opt/software/elasticsearch-7.16.2/logs/node1_logs -Enode.name=node-1 -d
./bin/elasticsearch -Ehttp.port=9202 -Epath.data=/opt/software/elasticsearch-7.16.2/data/node2_data -Epath.logs=/opt/software/elasticsearch-7.16.2/logs/node2_logs -Enode.name=node-2 -d
./bin/elasticsearch -Ehttp.port=9203 -Epath.data=/opt/software/elasticsearch-7.16.2/data/node3_data -Epath.logs=/opt/software/elasticsearch-7.16.2/logs/node3_logs -Enode.name=node-3 -d

 会输出两个警告,意思是建议JDK11且环境变量名叫ES_JAVA_HOME,不必理会,只要没输出ERROR就说明启动成功。

启动后查看es节点

curl -X GET http://localhost:9201/_cat/nodes?v

你可能感兴趣的:(ElasticSearch,elasticsearch)