一,下載
官方網(wǎng)站查看下載地址
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
#節(jié)點名稱,必須不一樣
node.name: node-1
#是不是有資格成為主節(jié)點
node.master: true
#是否存儲數(shù)據(jù)
node.data: true
#最大集群節(jié)點數(shù)
node.max_local_storage_nodes: 3
#ip地址.
network.host: 0.0.0.0
#端口
http.port: 19201
#內(nèi)部節(jié)點之間溝通端口
transport.tcp.port: 19700
#es7.x 之后新增的配置,節(jié)點發(fā)現(xiàn)
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"]
#數(shù)據(jù)和存儲路徑
path.data: /mnt/xvdb/datas/elasticsearch/data
path.logs: /mnt/xvdb/datas/elasticsearch/logs
修改jvm相關(guān)配置
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
根據(jù)實際情況配置,這里只做演示
-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
三,修改默認(rèn)jdk
vim /usr/local/services/elasticsearch-7.10.2-node1/bin/elasticsearch-env
#重寫JAVA_HOME JAVA_HOME="$ES_HOME/jdk"
四,修改vm.max_map_count的內(nèi)存大小
vim /etc/sysctl.conf
vm.max_map_count=655360
sysctl -p
五,配置其他節(jié)點
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
#節(jié)點名字
node.name: node-2
#端口http.port: 19202
#節(jié)點名字
node.name: node-3
#端口文章來源:http://www.zghlxwxcb.cn/news/detail-621372.htmlhttp.port: 19203文章來源地址http://www.zghlxwxcb.cn/news/detail-621372.html
六,創(chuàng)建日志和數(shù)據(jù)文件
mkdir -p /mnt/xvdb/datas/elasticsearch/data
mkdir -p /mnt/xvdb/datas/elasticsearch/logs
七,創(chuàng)建用戶
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
到了這里,關(guān)于Elasticsearch 7.10.2 部署集群搭建的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!