Elasticsearch 8.6 cluster install

# master node 1
cd /opt
wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.6.0-x86_64.rpm -P /opt/
yum localinstall -y /opt/elasticsearch-8.6.0-x86_64.rpm /opt/elasticsearch-8.6.0-x86_64.rpm
sudo mv /etc/elasticsearch/elasticsearch.yml /etc/elasticsearch/elasticsearch.yml.default
vim /etc/elasticsearch/elasticsearch.yml
cluster.name: sbtest_es_cluster
node.name:    node-1
node.master:  true
node.roles: [master,data]
#node.data  :  ture
#node.ingest:  false
#node.attr.rack_id: rack_dpzr-es20
#cluster.routing.allocation.awareness.attributes: rack_id
#cluster.routing.allocation.same_shard.host: true
path.data: /data/es/data
path.logs: /data/es/logs
#bootstrap.memory_lock: true
#indices.memory.index_buffer_size: 20%
#indices.recovery.max_bytes_per_sec: 1g
network.host: 10.10.10.11
#network.publish_host: 10.111.101.333
http.port: 9200
http.cors.enabled: true
http.cors.allow-origin: "*"
action.destructive_requires_name: false
ingest.geoip.downloader.enabled: false
#transport.tcp.port: 9300
discovery.seed_hosts: ["10.111.101.18:9300","10.111.101.19:9300","10.111.101.20:9300"]
#cluster.initial_master_nodes: ["10.111.101.18","10.111.101.19","10.111.101.20"]
#cluster.fault_detection.leader_check.interval: 20s
#discovery.cluster_formation_warning_timeout: 30s
#cluster.join.timeout: 120s
#cluster.publish.timeout: 90s
#client.transport.ping_timeout: 60s
#action.destructive_requires_name: true
#xpack.ml.enabled: false
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:enabled:false #默认是ture 访问的时候需要带证书才行,这里改成false之后,就不需要制定证书访问了,跟es7的访问方式一样

xpack.security.transport.ssl:
 enabled: true
 verification_mode: certificate
 keystore.path: certs/transport.p12
 truststore.path: certs/transport.p12
 cluster.initial_master_nodes: ["dba-test-es01"] # 第一个节点 一定要配置初始化节点为自己,否则启动会报错
 http.host: 0.0.0.0
 transport.host: 0.0.0.0                        
#xpack.security.transport.ssl.keystore.type: PKCS12
#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
#xpack.security.transport.ssl.truststore.type: PKCS12
#xpack.security.audit.enabled: true
#thread_pool:
    #write:
        #size: 7
#indices.fielddata.cache.size: 20%
#indices.breaker.fielddata.limit: 30%
sudo mv /etc/elasticsearch/jvm.options /etc/elasticsearch/jvm.options.default
vim /etc/elasticsearch/jvm.options # 模版在下面
-Xms32g
-Xmx32g
-XX:+UseG1GC
#8-13:-XX:+UseConcMarkSweepGC
#8-13:-XX:CMSInitiatingOccupancyFraction=75
#8-13:-XX:+UseCMSInitiatingOccupancyOnly
#14-:-XX:+UseG1GC
-Djava.io.tmpdir=${ES_TMPDIR}
-XX:+HeapDumpOnOutOfMemoryError
-XX:+ExitOnOutOfMemoryError
-XX:HeapDumpPath=/var/lib/elasticsearch
-XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log
#8:-XX:+PrintGCDetails
#8:-XX:+PrintGCDateStamps
#8:-XX:+PrintTenuringDistribution
#8:-XX:+PrintGCApplicationStoppedTime
#8:-Xloggc:/var/log/elasticsearch/gc.log
#8:-XX:+UseGCLogFileRotation
#8:-XX:NumberOfGCLogFiles=32
#8:-XX:GCLogFileSize=64m
-Xlog:gc*,gc+age=trace,safepoint:file=/var/log/elasticsearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m
#EOF
chown elasticsearch. -R /data/es/
chown elasticsearch. -R /etc/elasticsearch/
 sudo systemctl daemon-reload
 sudo systemctl enable elasticsearch.service
 sudo systemctl start elasticsearch.service;  sudo systemctl status elasticsearch.service;

#注意看输出消息,包含密码 如何做新节点 ,记下密码和信息
#在主节点生成一个token 其他节点接入集群时候需要用到
生成token
/usr/share/elasticsearch/bin/elasticsearch-create-enrollment-token -s node
 # 保存token 30 分钟内有效,失效后重新执行即可
ejkjsdflj sldfjsljdflsjfd lssdfj lsf lsjfdljs lkfjsldj fl
2: 给集群添加新节点
安装 elasticsearch 但不启动
 新节点执行
 wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-8.6.0-x86_64.rpm -P /opt/
yum localinstall -y /opt/elasticsearch-8.6.0-x86_64.rpm

#先不要启动 不要启动

#使用token加入到已有的集群
使用刚刚保存的token,该命令会将上一个机器的证书拷贝过来

新节点执行
/usr/share/elasticsearch/bin/elasticsearch-reconfigure-node --enrollment-token <token-here.
#配置修改
新节点执行
mkdir /data/es/{data,logs} -p

sudo egrep -v '^#|^$' /etc/elasticsearch/elasticsearch.yml >/etc/elasticsearch/elasticsearch.yml.default

sudo cp /etc/elasticsearch/elasticsearch.yml.default /etc/elasticsearch/elasticsearch.yml

sudo vim /etc/elasticsearch/elasticsearch.yml
新节点elasticsearch.yml
cluster.name: sbtest_es_cluster
node.name : node-2
node.roles: [master,data]
path.data: /data/es/data
path.logs: /data/es/logs
network.host: 10.10.10.12
http.port: 9200
http.cors.enabled: true
http.cors.allow-orign: "*"
action.destructive_requires_name: false
ingest.geoip.downloader.enabled: false
discovery.seed_hosts: ["10.10.10.11:9300","10.10.10.12:9300","10.10.10.13:9300"] # 集群成员

xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
  enabled:false
xpack.security.transport.ssl:
  enabled:true
verification_mode: certificate
keystore.path: certs/transport.p12
truststore.path: certs/transport.p12
http.host:0.0.0.0
transport.host: 0.0.0.0
sudo mv /etc/elasticsearch/jvm.options /etc/elasticsearch/jvm.options.default
vim /etc/elasticsearch/jvm.options

-Xms32g
-Xmx32g
-XX:+UseG1GC
#8-13:-XX:+UseConcMarkSweepGC
#8-13:-XX:CMSInitiatingOccupancyFraction=75
#8-13:-XX:+UseCMSInitiatingOccupancyOnly
#14-:-XX:+UseG1GC
-Djava.io.tmpdir=${ES_TMPDIR}
-XX:+HeapDumpOnOutOfMemoryError
-XX:+ExitOnOutOfMemoryError
-XX:HeapDumpPath=/var/lib/elasticsearch
-XX:ErrorFile=/var/log/elasticsearch/hs_err_pid%p.log
#8:-XX:+PrintGCDetails
#8:-XX:+PrintGCDateStamps
#8:-XX:+PrintTenuringDistribution
#8:-XX:+PrintGCApplicationStoppedTime
#8:-Xloggc:/var/log/elasticsearch/gc.log
#8:-XX:+UseGCLogFileRotation
#8:-XX:NumberOfGCLogFiles=32
#8:-XX:GCLogFileSize=64m
-Xlog:gc*,gc+age=trace,safepoint:file=/var/log/elasticsearch/gc.log:utctime,pid,tags:filecount=32,filesize=64m
#EOF
chown elasticsearch. -R /data/es/
chown elasticsearch. -R /etc/elasticsearch/

sudo systemctl daemon-reload
sudo systemctl enable elasticsearch.service
sudo systemctl start elasticsearch.service; systemctl status elasticsearch.service;

检查节点是否正常
curl -u elastic http://localhost:9200/_cat/nodes

#安装kibana
yum localinstall /opt/kibana-8.6.0-x86_64.rpm -y

  • 3
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值