ES集群部署 8.4.3
零、準(zhǔn)備工作
準(zhǔn)備至少三個節(jié)點(diǎn),配置至少為4核心8G內(nèi)存
節(jié)點(diǎn)名稱 節(jié)點(diǎn)IP node1 192.168.0.1 node2 192.168.0.2 node3 192.168.0.3 關(guān)閉三個節(jié)點(diǎn)的防火墻
#必須關(guān)閉防火墻,否則無法正常啟動集群 #三個節(jié)點(diǎn)分別執(zhí)行以下命令 systemctl stop firewalld
一、修改操作系統(tǒng)配置
? 1、添加ES用戶 es不允許root啟動
#添加用戶 es useradd es #設(shè)置es密碼 密碼為:elasticsearch passwd es
2、創(chuàng)建安裝目錄并授權(quán)
#創(chuàng)建目錄 mkdir /app/elasticsearch #授權(quán) chown -R es:es elasticsearch/
3、修改操作系統(tǒng)配置
#-------修改es用戶最大文件描述符------------ vim /etc/security/limits.conf #插入以下配置 es soft nofile 65536 es hard nofile 65536 #----------保存并退出---------------- #----------修改最大虛擬內(nèi)存------------------- vim /etc/sysctl.conf #追加以下配置并保存 vm.max_map_count=655360 #執(zhí)行如下命令 sysctl -p # 顯示 vm.max_map_count = 655360 就OK了
二、ES集群配置
? 注意:請嚴(yán)格按照安裝順序來,否則都是坑
? 以下步驟都在用戶es下進(jìn)行。切換用戶為:es
#切換用戶
su es
1、安裝包準(zhǔn)備
- 將elasticsearch-8.4.3-linux-x86_64.tar.gz 分別拷貝到三個節(jié)點(diǎn)
2、配置 node-1
解壓安裝包:tar -zxvf xxxx.gar.gz
配置 elasticsearch.yml 【關(guān)鍵】
cd /app/elasicsearch/elasticsearch-8.4.3/config vim elasticsearch.yml # 只配置以下選項(xiàng),其他不能動,因?yàn)閑s會自行配置,我們只配置基礎(chǔ)必須的項(xiàng)。否則各種坑。 #集群名稱:自定義,三個節(jié)點(diǎn)都必須配置為相同 cluster.name: udss-es #該節(jié)點(diǎn)名稱:唯一不重復(fù) node.name: node-1 #該節(jié)點(diǎn)對外能提供訪問的IP,如果填寫ip不能被訪問,則集群無法加入。 network.host: 10.248.190.176 #只配置以上三個項(xiàng)目,其他別動
配置jvm.options文件
vim jvm.options #將內(nèi)存最大最小配置為4G 其他不動 -Xms4g -Xmx4g
3、啟動node-1,記錄日志
#啟動該節(jié)點(diǎn)并記錄啟動日志 cd /app/elasicsearch/elasticsearch-8.4.3 #啟動es節(jié)點(diǎn),后臺啟動 bin/elasticsearch -d #正常啟動,關(guān)注如下日志: ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ ? Elasticsearch security features have been automatically configured! ? Authentication is enabled and cluster connections are encrypted. #生成默認(rèn)用戶:elastic 密碼:Z8Scc-c0KGoJV3QPg++S ?? Password for the elastic user (reset with `bin/elasticsearch-reset-password -u elastic`): Z8Scc-c0KGoJV3QPg++S ?? HTTP CA certificate SHA-256 fingerprint: d673d6c209a69753a82ded21ccb7791aa667761619a865ca58929f3f2edb7f14 #生成kibana鏈接es的token,有效時間:30分鐘 如果失效,往下看第五步 ?? Configure Kibana to use this cluster: ? Run Kibana and click the configuration link in the terminal when Kibana starts. ? Copy the following enrollment token and paste it into Kibana in your browser (valid for the next 30 minutes): eyJ2ZXIiOiI4LjQuMyIsImFkciI6WyIxMC4yNDguMTkwLjE3Njo5MjAwIl0sImZnciI6ImQ2NzNkNmMyMDlhNjk3NTNhODJkZWQyMWNjYjc3OTFhYTY2Nzc2MTYxOWE4NjVjYTU4OTI5ZjNmMmVkYjdmMTQiLCJrZXkiOiI4czY0UFlRQkEyYkIza3RQYnJ3Mjp0amx1ZzNaVFNHS2dPbURScW5wVXpRIn0= #生成es其他節(jié)點(diǎn)加入該集群的token,有效時間:30分鐘 如果失效,往下看第五步 ?? Configure other nodes to join this cluster: ? Copy the following enrollment token and start new Elasticsearch nodes with `bin/elasticsearch --enrollment-token <token>` (valid for the next 30 minutes): eyJ2ZXIiOiI4LjQuMyIsImFkciI6WyIxMC4yNDguMTkwLjE3Njo5MjAwIl0sImZnciI6ImQ2NzNkNmMyMDlhNjk3NTNhODJkZWQyMWNjYjc3OTFhYTY2Nzc2MTYxOWE4NjVjYTU4OTI5ZjNmMmVkYjdmMTQiLCJrZXkiOiI5TTY0UFlRQkEyYkIza3RQYnJ3NDp6VTByVFp3bVR3S1R4MUk5TzRNVS1nIn0= If you're running in Docker, copy the enrollment token and run: `docker run -e "ENROLLMENT_TOKEN=<token>" docker.elastic.co/elasticsearch/elasticsearch:8.4.3` ━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━ #啟動后,ES會自動配置集群配置、安全配置,并追加到elasticsearch.yml文件中 #ssl證書等配置,生成到config/certs目錄中。 #后續(xù)節(jié)點(diǎn)加入集群,會自動同步該節(jié)點(diǎn)的配置,不要人工手動配置。
4、啟動node-2
配置node-2
基礎(chǔ)配置與配置node-1相同【不要啟動】
注意使用用戶:es 非root
解壓安裝包,配置elasticsearch.yml與jvm.options
不要把ip與節(jié)點(diǎn)名稱配置重復(fù)了。
其余不要動
啟動node-2
#node2啟動與node1不同,node2啟動通過node-1提供的token直接加入集群,同步node-1的所有默認(rèn)配置。 cd /app/elasicsearch/elasticsearch-8.4.3 #第一次啟動node-2 es節(jié)點(diǎn),后臺啟動 bin/elasticsearch -d --enrollment-token 復(fù)制日志中的node-token #啟動成功后,es自動配置elasticsearch.yml中集群以及安全等,不要去改動配置。 #如果后續(xù)關(guān)閉節(jié)點(diǎn)重啟,則使用以下命令: bin/elasticsearch -d
查看node-1日志
#查看日志確認(rèn)節(jié)點(diǎn)加入集群 #node-1節(jié)點(diǎn)操作 cd /app/elasicsearch/elasticsearch-8.4.3 cat logs/udss-es_server.json #發(fā)現(xiàn) node add日志則表示加入成功
node-3配置與啟動,與node-2相同,按照步驟操作即可。token可重復(fù)使用。
證書配置
將 /app/elasicsearch/elasticsearch-8.4.3/config/certs/http_ca.crt 文件,下載拷貝至需要鏈接ES的應(yīng)用服務(wù)器。
并執(zhí)行以下命令,安裝到j(luò)dk證書目錄中,使機(jī)器能夠鏈接ES服務(wù)。
#將http_ca.crt文件拷貝到服務(wù)器并安裝: keytool -import -alias es_cert -keystore "$JAVA_HOME/jre/lib/security/cacerts" -file http_ca.crt #輸入密碼: changeit #回車,輸入yes,安裝完成。該服務(wù)器可以使用https鏈接es.否則無法鏈接。
5、token失效
? ES提供了token生成工具進(jìn)行生成對應(yīng)的token,在失效時刻隨時生成。
#進(jìn)入es目錄 cd /app/elasicsearch/elasticsearch-8.4.3 #生成node 加入集群的token bin/elasticsearch-create-enrollment-token -s node #生成kibana接入的token bin/elasticsearch-create-enrollment-token -s kibana
6、配置安裝kibana
下載kibana安裝包:8.4.3并上傳到服務(wù)器
解壓安裝包:tar -zxvf xxxx.tar.gz
配置kibana.yml文件
cd /app/kibana/kibana-8.4.3/config vim kibana.yml #host修改為如下: # Specifies the address to which the Kibana server will bind. IP addresses and host names are both valid values. # The default is 'localhost', which usually means remote machines will not be able to connect. server.host: "0.0.0.0"
保存配置文件并啟動kibana
cd /app/kibana/kibana-8.4.3/ nohup bin/kibana --allow-root &
瀏覽器登陸kibana首頁:
輸入上面日志中的token或命令生成的kibana token,進(jìn)行首次配置。
配置完畢后,即可登錄使用
用戶名:elastic
密碼:上述日志中的用戶密碼文章來源:http://www.zghlxwxcb.cn/news/detail-429444.html
?文章來源地址http://www.zghlxwxcb.cn/news/detail-429444.html
到了這里,關(guān)于ES8 集群部署的文章就介紹完了。如果您還想了解更多內(nèi)容,請?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!