一、搭建ES集群
1.集群環(huán)境安裝
本集群使用Centos7.5操作系統(tǒng),2G 2C 60G(如果主機(jī)好點(diǎn)的節(jié)點(diǎn)配置可以搞高點(diǎn))
分別修改三臺(tái)集群服務(wù)器配置:
?1.1.修改系統(tǒng)配置文件/etc/security/limits.conf
* soft nofile 65536 # 設(shè)置每個(gè)進(jìn)程可以打開(kāi)的文件數(shù)的限制
* hard nofile 65536
* soft nproc 2048 # 設(shè)置線程數(shù)
* hard nproc 4096
1.2.修改/etc/sysctl.conf
#一個(gè)進(jìn)程可以擁有的VMA數(shù)量設(shè)置為655360(默認(rèn)為65536)
vm.max_map_count=655360
1.3.#sysctl -p?
重新加載
集群服務(wù)器如下:
機(jī)器地址 | 節(jié)點(diǎn)名稱 | 節(jié)點(diǎn)角色 | 節(jié)點(diǎn)功能 |
---|---|---|---|
192.168.206.101 | es-node-1 | Master,data | 主+數(shù)據(jù)節(jié)點(diǎn) |
192.168.206.102 | es-node-2 | Master,data | 主+數(shù)據(jù)節(jié)點(diǎn) |
192.168.206.103 | es-node-3 | Master,data | 主+數(shù)據(jù)節(jié)點(diǎn) |
2.下載ES并解壓
???ES-8.1.0下載地址:??????Elasticsearch 8.1.0 | Elastic
將es解壓到指定的目錄:
tar -zxvf elasticsearch-8.1.0-linux-x86_64.tar.gz -C /opt/module/
?3.新增用戶es
#新增用戶
useradd es
passwd es
# 創(chuàng)建數(shù)據(jù)文件目錄
mkdir /opt/module/elasticsearch-8.1.0/data/
# 創(chuàng)建證書目錄
mkdir /opt/module/elasticsearch-8.1.0/config/certs
# 修改文件擁有者
chown -R es:es /opt/module/elasticsearch-8.1.0
4.在第一臺(tái)服務(wù)器節(jié)點(diǎn)上生成安全證書
#切換用戶
su es
# 簽發(fā)ca證書 直接敲回車 不需要輸入密碼
bin/elasticsearch-certutil ca
# 用ca證書簽發(fā)節(jié)點(diǎn)證書 敲三次回車
bin/elasticsearch-certutil cert --ca elastic-stack-ca.p12
# 將生成的證書文件移動(dòng)到config/certs目錄中
mv elastic-certificates.p12 config/certs
5.在第一臺(tái)服務(wù)器節(jié)點(diǎn)上生成http證書
# 簽發(fā)Https證書
bin/elasticsearch-certutil http
關(guān)鍵環(huán)節(jié)如下:
Generate? a? CRS? [y/n]n? (是否發(fā)送認(rèn)證證書請(qǐng)求)
Use? an existing CA? [y/n]y (是否使用已存在的CA證書)
CA? Path: certs/elastic-stack-ca.p12 (CA證書路徑)
Password? for elastic-stack-ca.p12:? (輸入CA證書密碼、上面生成CA證書未設(shè)置密碼、直接回車)
For? how long should? your certificate be valid: [5y] 20y (輸入證書使用年限)
Generate a? certificate per node: [y/n] n(是否每個(gè)節(jié)點(diǎn)都 生成證書)
Enter all the hostnames that you need,one per line. (輸入主機(jī)名稱、回車)
when you are done,press <enter> once more to move on to the next step
linux001
linux002
linux003
Is this correct [y/n] n(輸入的主機(jī)名稱是否正確)
Enter all the ip address that you need,one per line. (輸入節(jié)點(diǎn)ip地址、回車)
when you are done,press <enter> once more to move on to the next step
192.168.206.101
192.168.206.102
192.168.206.103
Is this correct [y/n] n(輸入的ip地址是否正確)
DO you wish to change any of these options [y/n] n (是否修改證書配置)
Provide a password for the "http.p12" file:[<enter> for none] (輸入密碼、沒(méi)配置密碼、直接回車)?
What filename should be used for the output zip files?[/opt/module/elasticsearch-8.1.0/elasticsearch-ssl-http.zip] (是否自定義名稱、直接回車)
解壓并移動(dòng)到config/certs目錄里
unzip elasticsearch-ssl-http.zip
# 證書文件移動(dòng)到指定目錄下
mv elasticsearch/http.p12 kibana/elasticsearch-ca.pem config/certs
6.配置第一個(gè)服務(wù)器節(jié)點(diǎn)
#vim conf/elasticsearch.yml
# ES集群配置
cluster.name: cluster-es
node.name: es-node-1
#設(shè)置數(shù)據(jù)
path.data: /opt/module/elasticsearch-8.1.0/data/
path.logs: /opt/module/elasticsearch-8.1.0/logs/
# 網(wǎng)絡(luò)訪問(wèn)節(jié)點(diǎn)名稱(需要在/etc/hosts里設(shè)置解析)
network.host: linux001
# Rest訪問(wèn)端口9200 ES集群內(nèi)部端口為9300
http.port: 9200
# 初始節(jié)點(diǎn)
discovery.seed_hosts: ["linux001"]
# 安全認(rèn)證
xpack.security.enabled: true
xpack.security.enrollment.enabled: true
xpack.security.http.ssl:
enabled: true
keystore.path: /opt/module/elasticsearch-8.1.0/config/certs/http.p12
truststore.path: /opt/module/elasticsearch-8.1.0/config/certs/http.p12
xpack.security.transport.ssl:
enabled: true
verification_mode: certificate
keystore.path: /opt/module/elasticsearch-8.1.0/config/certs/elastic-certificates.p12
truststore.path: /opt/module/elasticsearch-8.1.0/config/certs/elastic-certificates.p12
# 集群初始化的主節(jié)點(diǎn)
cluster.initial_master_nodes: ["es-node-1"]
http.host: [_local_, _site_]
ingest.geoip.downloader.enabled: false
xpack.security.http.ssl.client_authentication: none
7.配置其他服務(wù)器節(jié)點(diǎn)
其余節(jié)點(diǎn)的配置文件只需要修改node.name和network.host即可。
注意:
如果es是從第一臺(tái)服務(wù)器節(jié)點(diǎn)上使用rsync/scp拷貝過(guò)去的。先刪除data和logs文件、重新創(chuàng)建再啟動(dòng)es、否則會(huì)出現(xiàn)找不到其他服務(wù)器節(jié)點(diǎn)問(wèn)題、如果同第一個(gè)節(jié)點(diǎn)一樣是解壓安裝的忽略。
服務(wù)器節(jié)點(diǎn)2:
服務(wù)器節(jié)點(diǎn)3:
8.啟動(dòng)ES服務(wù)器
#bin/elasticsearch
第一次啟動(dòng)會(huì)顯示密碼、最好保存后、免得后面忘記、
忘記密碼:bin/elasticsearch-reset-password -u elastic
?重置登錄es的密碼
#bin/elasticsearch -d? (依次啟動(dòng)三臺(tái)服務(wù)器、-d是后臺(tái)啟動(dòng))
這里如果不進(jìn)行密碼重置或者修改的話,三臺(tái)機(jī)器登錄的賬號(hào)是共享密碼的
#tail? -f? ?logs/cluster-es.log (查看es日志)
網(wǎng)頁(yè)訪問(wèn)查看es集群信息:(帶*的是主節(jié)點(diǎn))
https://linux001:9200/_cat/nodes?v文章來(lái)源:http://www.zghlxwxcb.cn/news/detail-650877.html
文章來(lái)源地址http://www.zghlxwxcb.cn/news/detail-650877.html
到了這里,關(guān)于Elasticsearch--01.ES8.1.0集群搭建的文章就介紹完了。如果您還想了解更多內(nèi)容,請(qǐng)?jiān)谟疑辖撬阉鱐OY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!