網(wǎng)站開發(fā)設(shè)計(jì)總結(jié)seo在線外鏈
轉(zhuǎn)載說明:如果您喜歡這篇文章并打算轉(zhuǎn)載它,請私信作者取得授權(quán)。感謝您喜愛本文,請文明轉(zhuǎn)載,謝謝。
本文記錄在3臺服務(wù)器上離線搭建es8.7.1版本集群。
1. 修改系統(tǒng)配置
1.1 hosts配置
在三臺es節(jié)點(diǎn)服務(wù)器加入hostname解析:
10.0.0.101 es01
10.0.0.102 es02
10.0.0.103 es03
1.2 三臺節(jié)點(diǎn)創(chuàng)建啟動es的普通用戶sre
# useradd sre
1.3 三臺節(jié)點(diǎn)修改內(nèi)存參數(shù)
# echo -e "vm.max_map_count=655350 \nvm.overcommit_memory=1">>/etc/sysctl.conf
# sysctl -p
1.4 三臺節(jié)點(diǎn)修改limits參數(shù)
# echo -e "* soft nofile 65536 \n* hard nofile 65536 \n* soft nproc 65536 \n* hard nproc 65536 \n* hard memlock unlimited \n* soft memlock unlimited" >>/etc/security/limits.conf
1.5 三臺節(jié)點(diǎn)安裝jdk
# tar xf jdk-8u231-linux-x64.tar.gz -C /opt/
# echo "export JAVA_HOME=/opt/jdk1.8.0_231" >>/etc/profile
# echo "export PATH=\$PATH:\$JAVA_HOME/bin" >>/etc/profile
# source /etc/profile
2. 安裝elasticsearch
將elasticsearch-8.7.1-linux-x86_64.tar上傳到服務(wù)器并解壓。后面的步驟均使用sre用戶操作。
2.1 創(chuàng)建證書
注意: 生成的證書要放在config目錄下,否則可能會啟動失敗。在1臺服務(wù)器上生成,再同步到另外兩臺服務(wù)器,該證書保持三個es節(jié)點(diǎn)一致。
$ ./bin/elasticsearch-certutil ca --pem --out ca.zip --days 36500 -s
2.2 三臺節(jié)點(diǎn)修改配置文件
主要在配置文件config/elasticsearch.yml修改或添加以下配置:
cluster.name: sretest
node.name: es01 #配置各節(jié)點(diǎn)hostname
path.data: /home/elasticsearch-8.7.1/data
path.logs: /home/elasticsearch-8.7.1/logs
network.host: 10.0.0.101 #配置各節(jié)點(diǎn)IP
http.port: 9200
discovery.seed_hosts: ["es01", "es02","es03"]
cluster.initial_master_nodes: ["es01", "es02","es03"]
http.cors.enabled: true
http.cors.allow-origin: "*"
xpack.security.enabled: true
xpack.security.transport.ssl.enabled: true
xpack.security.transport.ssl.verification_mode: certificate
xpack.security.transport.ssl.key: /home/elasticsearch-8.7.1/config/cert/ca/ca.key #上一步驟生成的證書
xpack.security.transport.ssl.certificate: /home/elasticsearch-8.7.1/config/cert/ca/ca.crt
2.3 三臺節(jié)點(diǎn)創(chuàng)建data目錄
$ mkdir /home/elasticsearch-8.7.1/data
2.4 三臺節(jié)點(diǎn)sre用戶啟動elasticsearch
$ nohup /home/elasticsearch-8.7.1/bin/elasticsearch >/dev/null 2>&1 &
2.5 生成賬號密碼
在其中一臺節(jié)點(diǎn)執(zhí)行命令設(shè)置賬號密碼
$ ./bin/elasticsearch-setup-passwords interactive #跟著提示一步步設(shè)置密碼即可
3. 集群驗(yàn)證
3.1 查看集群節(jié)點(diǎn)
[root@es01 home]# curl -u "elastic:Sre@202308" http://10.0.0.101:9200/_cat/nodes
10.0.0.101 36 98 2 0.16 0.11 0.13 cdfhilmrstw - es01
10.0.0.102 66 91 6 0.03 0.10 0.13 cdfhilmrstw - es02
10.0.0.103 38 98 7 0.09 0.14 0.16 cdfhilmrstw * es03
[root@es01 home]#
3.2 查看集群健康狀態(tài)
[root@es01 home]# curl -u "elastic:Sre@202308" http://10.0.0.101:9200/_cat/health
1692270404 11:06:44 sretest green 3 3 3213 1653 0 0 0 0 - 100.0%
[root@es0-1 home]#
關(guān)于ES的常見錯誤,請見:
《總結(jié)—elasticsearch啟動失敗的幾種情況及解決》
《升級Elasticsearch到8.7.1版本,我給自己挖了很多坑…》