一,下载
官方网站查看下载地址
Download Elasticsearch | Elastic
#下载
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.10.2-linux-x86_64.tar.gz
#解压
tar -zxvf elasticsearch-7.10.2-linux-x86_64.tar.gz
#重命名
mv elasticsearch-7.10.2 elasticsearch-7.10.2-node1
二,修改集群配置
修改es配置
vim /usr/local/services/elasticsearch-7.10.2-node1/config/elasticsearch.yml
#集群名称,保证唯一
cluster.name: rc-es-cluster
#节点名称,必须不一样
node.name: node-1
#是不是有资格成为主节点
node.master: true
#是否存储数据
node.data: true
#最大集群节点数
node.max_local_storage_nodes: 3
#ip地址.
network.host: 0.0.0.0
#端口
http.port: 19201
#内部节点之间沟通端口
transport.tcp.port: 19700
#es7.x 之后新增的配置,节点发现
discovery.seed_hosts: ["172.22.191.94:19201","172.22.191.94:19202","172.22.191.94:19203"]
#es7.x 之后新增的配置,初始化一个新的集群时需要次配置来选举master
cluster.initial_master_nodes: ["node-1","node-2","node-3"]
#数据和存储路径
path.data: /mnt/xvdb/datas/elasticsearch/data
path.logs: /mnt/xvdb/datas/elasticsearch/logs
修改jvm相关配置
vim /usr/local/services/elasticsearch-7.10.2-node1/config/jvm.options
## JVM configuration
################################################################
## IMPORTANT: JVM heap size
################################################################
##
## You should always set the min and max JVM heap
## size to the same value. For example, to set
## the heap to 4 GB, set:
##
## -Xms4g
## -Xmx4g
##
## See https://www.elastic.co/guide/en/elasticsearch/reference/current/heap-size.html
## for more information
##
################################################################
# Xms represents the initial size of total heap space
# Xmx represents the maximum size of total heap space
根据实际情况配置,这里只做演示
-Xms256m
-Xmx256m
################################################################
## Expert settings
################################################################
##
## All settings below this section are considered
## expert settings. Don't tamper with them unless
## you understand what you are doing
##
################################################################
## GC configuration
8-13:-XX:+UseConcMarkSweepGC
8-13:-XX:CMSInitiatingOccupancyFraction=75
8-13:-XX:+UseCMSInitiatingOccupancyOnly
## G1GC Configuration
# NOTE: G1 GC is only supported on JDK version 10 or later
# to use G1GC, uncomment the next two lines and update the version on the
# following three lines to your version of the JDK
# 10-13:-XX:-UseConcMarkSweepGC
# 10-13:-XX:-UseCMSInitiatingOccupancyOnly
14-:-XX:+UseG1GC
14-:-XX:G1ReservePercent=25
14-:-XX:InitiatingHeapOccupancyPercent=30
## JVM temporary directory
-Djava.io.tmpdir=${ES_TMPDIR}
## heap dumps
# generate a heap dump when an allocation from the Java heap fails
# heap dumps are created in the working directory of the JVM
-XX:+HeapDumpOnOutOfMemoryError
# specify an alternative path for heap dumps; ensure the directory exists and
# has sufficient space
-XX:HeapDumpPath=data
# specify an alternative path for JVM fatal error logs
-XX:ErrorFile=logs/hs_err_pid%p.log
## JDK 8 GC logging
8:-XX:+PrintGCDetails
8:-XX:+PrintGCDateStamps
8:-XX:+PrintTenuringDistribution
8:-XX:+PrintGCApplicationStoppedTime
8:-Xloggc:logs/gc.log
8:-XX:+UseGCLogFileRotation
8:-XX:NumberOfGCLogFiles=32
8:-XX:GCLogFileSize=64m
# JDK 9+ GC logging
9-:-Xlog:gc*,gc+age=trace,safepoint:file=logs/gc.log:utctime,pid,tags:filecount=32,filesize=64m
三,修改默认jdk
vim /usr/local/services/elasticsearch-7.10.2-node1/bin/elasticsearch-env
#重写JAVA_HOME JAVA_HOME="$ES_HOME/jdk"
四,修改vm.max_map_count的内存大小
vim /etc/sysctl.conf
vm.max_map_count=655360
sysctl -p
五,配置其他节点
cd /usr/local/services/
cp -r elasticsearch-7.10.2-node1/ elasticsearch-7.10.2-node2
cp -r elasticsearch-7.10.2-node1/ elasticsearch-7.10.2-node3
修改elasticsearch.yml
#节点名字
node.name: node-2
#端口http.port: 19202
#节点名字
node.name: node-3
#端口文章来源:https://www.toymoban.com/news/detail-621372.htmlhttp.port: 19203文章来源地址https://www.toymoban.com/news/detail-621372.html
六,创建日志和数据文件
mkdir -p /mnt/xvdb/datas/elasticsearch/data
mkdir -p /mnt/xvdb/datas/elasticsearch/logs
七,创建用户
useradd elasticsearch
passwd elasticsearch
cd /usr/local/services/
chown -R elasticsearch:elasticsearch elasticsearch-7.10.2-node1
chown -R elasticsearch:elasticsearch elasticsearch-7.10.2-node2
chown -R elasticsearch:elasticsearch elasticsearch-7.10.2-node
chown -R elasticsearch:elasticsearch /mnt/xvdb/datas/elasticsearch/data
chown -R elasticsearch:elasticsearch /mnt/xvdb/datas/elasticsearch/logs
八,切换用户启动
su elasticsearch
chnod -r -755 /mnt/xvdb/datas/elasticsearch/data
chnod -r -755 /mnt/xvdb/datas/elasticsearch/logs
cd /usr/local/services/
./elasticsearch-7.10.2-node1/bin/elasticsearch -d
./elasticsearch-7.10.2-node2/bin/elasticsearch -d
./elasticsearch-7.10.2-node3/bin/elasticsearch -d
到了这里,关于Elasticsearch 7.10.2 部署集群搭建的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!