一.下载安装包
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.12.0-linux-x86_64.tar.gz
二.配置节点(三个节点)
节点1:x.x.x.61
节点2:x.x.x.62
节点3:x.x.x.73
三.配置节点参数
节点1配置:直接linux命令行直接复制粘贴
cat >> elasticsearch.yml <<EOF
#====================================61==================================
# ======================== Elasticsearch Configuration =========================
cluster.name: cluster-Es
node.name: es3
network.host: 0.0.0.0
node.master: true
node.data: true
path.data: /data/es/data
path.logs: /data/es/log
# head 插件需要这打开这两个配置
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
# 可以选举的主节点
cluster.initial_master_nodes: ["x.x.x.61:9300","x.x.x.62:9300","x.x.x.x:9300"]
discovery.seed_hosts: ["x.x.x.61:9300","x.x.x.x:9300","x.x.x.73:9300"]
gateway.recover_after_nodes: 2
network.tcp.keep_alive: true
network.tcp.no_delay: true
transport.tcp.compress: true
#集群内同时启动的数据任务个数,默认是2个
cluster.routing.allocation.cluster_concurrent_rebalance: 16
#添加或删除节点及负载均衡时并发恢复的线程个数,默认4个
cluster.routing.allocation.node_concurrent_recoveries: 16
#初始化数据恢复时,并发恢复线程的个数,默认4个
cluster.routing.allocation.node_initial_primaries_recoveries: 16
#开启 xpack 功能,如果要禁止使用密码,请将以下内容注释,直接启动不需要设置密码
#xpack.security.enabled: true
#xpack.security.transport.ssl.enabled: true
#xpack.security.transport.ssl.verification_mode: certificate
#xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
#xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
EOF
节点2配置:直接linux命令行直接复制粘贴
cat >> elasticsearch.yml <<EOF
#====================================62==================================
# ======================== Elasticsearch Configuration =========================
cluster.name: cluster-Es
node.name: es2
network.host: 0.0.0.0
node.master: true
node.data: true
path.data: /data/es/data
path.logs: /data/es/log
# head 插件需要这打开这两个配置
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
# 可以选举的主节点
cluster.initial_master_nodes: ["x.x.x.61:9300","x.x.x.62:9300","x.x.x.73:9300"]
discovery.seed_hosts: ["x.x.x.61:9300","x.x.x.62:9300","x.x.x.73:9300"]
gateway.recover_after_nodes: 2
network.tcp.keep_alive: true
network.tcp.no_delay: true
transport.tcp.compress: true
#集群内同时启动的数据任务个数,默认是2个
cluster.routing.allocation.cluster_concurrent_rebalance: 16
#添加或删除节点及负载均衡时并发恢复的线程个数,默认4个
cluster.routing.allocation.node_concurrent_recoveries: 16
#初始化数据恢复时,并发恢复线程的个数,默认4个
cluster.routing.allocation.node_initial_primaries_recoveries: 16
#开启 xpack 功能,如果要禁止使用密码,请将以下内容注释,直接启动不需要设置密码
#xpack.security.enabled: true
#xpack.security.transport.ssl.enabled: true
#xpack.security.transport.ssl.verification_mode: certificate
#xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
#xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
EOF
节点3配置:直接linux命令行直接复制粘贴
cat >> elasticsearch.yml <<EOF
# ====================================73==================================
# ======================== Elasticsearch Configuration =========================
cluster.name: cluster-Es
node.name: es1
network.host: 0.0.0.0
node.master: true
node.data: true
path.data: /data/es/data
path.logs: /data/es/log
# head 插件需要这打开这两个配置
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
# 可以选举的主节点
cluster.initial_master_nodes: ["x.x.x.61:9300","x.x.x.62:9300","x.x.x.73:9300"]
discovery.seed_hosts: ["x.x.x.61:9300","x.x.x.62:9300","x.x.x.73:9300"]
gateway.recover_after_nodes: 2
network.tcp.keep_alive: true
network.tcp.no_delay: true
transport.tcp.compress: true
#集群内同时启动的数据任务个数,默认是2个
cluster.routing.allocation.cluster_concurrent_rebalance: 16
#添加或删除节点及负载均衡时并发恢复的线程个数,默认4个
cluster.routing.allocation.node_concurrent_recoveries: 16
#初始化数据恢复时,并发恢复线程的个数,默认4个
cluster.routing.allocation.node_initial_primaries_recoveries: 16
#开启 xpack 功能,如果要禁止使用密码,请将以下内容注释,直接启动不需要设置密码
#xpack.security.enabled: true
#xpack.security.transport.ssl.enabled: true
#xpack.security.transport.ssl.verification_mode: certificate
#xpack.security.transport.ssl.keystore.path: elastic-certificates.p12
#xpack.security.transport.ssl.truststore.path: elastic-certificates.p12
EOF
四.启动集群
./elasticsearch -d -p pid
启动报错
修改配置
vim /etc/sysctl.conf
vm.max_map_count = 562144
五.验证服务可用性
curl -l http://x.x.x.x:9200