一篇帶給你ElasticSearch集群部署
ElasticSearch集群部署
下載
安裝包下載地址
https://www.elastic.co/cn/downloads/elasticsearch
上傳到服務(wù)器/usr/elastic目錄
解壓
cd /usr/elastic
tar -zxvf elasticsearch-7.17.0-linux-x86_64.tar.gz
修改jdk環(huán)境變量
使用安裝包自帶的jdk,防止使用本機(jī)安裝的jdk版本不兼容導(dǎo)致無法啟動(dòng)
cd /usr/elastic/elasticsearch-7.17.0/bin
vim elasticsearch-env
增加配置節(jié),指定使用安裝包中自帶的jdk
JAVA_HOME="/usr/elastic/elasticsearch-7.17.0/jdk"
修改jvm.options
-Xms1g
-Xmx1g
8-13:-XX:+UseG1GC
配置集群信息
cd /usr/elastic/elasticsearch-7.17.0/config
vim elasticsearch.yml
配置信息每個(gè)節(jié)點(diǎn)只有node.name不同
#集群名字
cluster.name: my-application
#節(jié)點(diǎn)名字
node.name: node-1
#IP地址
network.host: 0.0.0.0
#端口號(hào)
http.port: 9200
#是否有資格當(dāng)主節(jié)點(diǎn)
node.master: true
#是否存儲(chǔ)數(shù)據(jù)
node.data: true
#節(jié)點(diǎn)發(fā)現(xiàn),所有節(jié)點(diǎn)的ip地址
discovery.seed_hosts: ["192.168.32.132", "192.168.32.133","192.168.32.136"]
#選舉master
cluster.initial_master_nodes: ["node-1", "node-2", "node-3"]
#允許跨域訪問
http.cors.enabled: true
http.cors.allow-origin: "*"
配置ES環(huán)境變量
vim /etc/profile
增加
export ES_HOME=/usr/elastic/elasticsearch-7.17.0
export PATH=$ES_HOME/bin:$PATH
使配置文件生效
source /etc/profile
配置es可以創(chuàng)建的最大線程數(shù)量
vim /etc/security/limits.conf
增加
es soft nofile 65535
es hard nofile 65535
es soft nproc 4096
es hard nproc 4096
修改最大虛擬內(nèi)存
vim /etc//sysctl.conf
增加
vm.max_map_count = 655360
執(zhí)行加載虛擬內(nèi)存
sysctl -p
root用戶無法啟動(dòng)es,所以創(chuàng)建用戶
useradd es
passwd es
修改文件夾權(quán)限給es用戶
chown -Rf es:es /usr/elastic/ elasticsearch-7.17.0
暫時(shí)關(guān)閉防火墻
systemctl stop firewalld
訪問
訪問192.168.32.133:9200
返回如下json表示成功
Kibana安裝
下載地址
https://www.elastic.co/cn/downloads/kibana
下載與elasticsearch相同版本號(hào)的安裝包
上傳到/usr/elastic
解壓
tar -zxvf kibana-7.17.0-linux-x86_64.tar.gz
修改配置kibana.yml
server.port: 5601
server.host: "0.0.0.0"
server.name: "kibana"
elasticsearch.hosts: ["http://192.168.32.132:9200", "http://192.168.32.132:9200","http://192.168.32.136:9200"]
啟動(dòng)kibana
cd /usr/elastic/kibana-7.17.0-linux-x86_64/bin
./kibana --allow-root
訪問地址
http://192.168.32.132:5601/