es部署安装
安装说明
- 下文会解释es、kibana、中文分词ik的安装,es的安装又会分为单机和集群版。
- es和kibana的版本号要一样。
- 官网上的安装包下载很慢,部分组件会选择华为云镜像作为下载源。
组件 | 版本 | 下载地址 |
---|---|---|
es | 7.14.0 | https://mirrors.huaweicloud.com/elasticsearch/7.14.0/ |
kibana | 7.14.0 | https://repo.huaweicloud.com/kibana/7.14.0/ |
ik | 8.1.0 | https://github.com/medcl/elasticsearch-analysis-ik |
单机部署
解压安装、添加es专用用户
tar -zxvf elasticsearch-7.14.0-linux-x86_64.tar.gz
mv elasticsearch-7.14.0 elasticsearch
mv elasticsearch /home/
cd /home/
groupadd esgroup
useradd esuser -g esgroup -p espwd
chown -R esuser.esgroup elasticsearch
修改配置文件
vim elasticsearch.yml,添加如下内容
cluster.name: es-cluster
node.name: node-2
network.host: 192.168.88.207
http.port: 9200
cluster.initial_master_nodes: ["node-2"]
ingest.geoip.downloader.enabled: false
xpack.security.enabled: false
修改系统配置
1.vim /etc/sysctl.conf,添加如下内容
net.core.somaxconn = 20000
vm.max_map_count=655360
执行:sysctl -p,使其生效。
2.执行下面命令,修改/etc/security/limits.conf
echo '* soft nofile 65535' >>/etc/security/limits.conf
echo '* hard nofile 65535' >>/etc/security/limits.conf
echo '* soft nproc 65535' >>/etc/security/limits.conf
echo '* hard nproc 65535' >>/etc/security/limits.conf
关闭防火墙(或放行9200端口)
service firewalld stop
或
firewall-cmd --zone=public --add-port=9200/tcp --permanent
firewall-cmd --reload
切换用户
su esuser
后台启动
./elasticsearch -d
可以先直接启动./elasticsearch,没有问题后在切换后台运行
集群部署
集群部署说明
- 集群部署和单机部署过程一样,只是配置文件内容不同。本次集群按三个节点部署。
- 默认tcp通信端口是9300,如果是不同机器上,transport.port可以去掉,discovery.seed_hosts不用填写端口,即:discovery.seed_hosts: [“192.168.88.207”,“192.168.88.207”,“192.168.88.207”]
- 下文只罗列集群中不同节点的配置文件内容,节点部署过程参考上述单机过程,略。
在一台机器上
三个节点的配置文件内容分别如下
node1:
cluster.name: es-cluster-test
node.name: node-1
node.master: true
node.data: true
network.host: 192.168.88.207
http.port: 9200
transport.port: 9300
discovery.seed_hosts: ["192.168.88.207:9300","192.168.88.207:9301","192.168.88.207:9302"]
cluster.initial_master_nodes: ["node-1"]
ingest.geoip.downloader.enabled: false
xpack.security.enabled: false
node2:
cluster.name: es-cluster-test
node.name: node-2
node.master: true
node.data: true
network.host: 192.168.88.207
http.port: 9201
transport.port: 9301
discovery.seed_hosts: ["192.168.88.207:9300","192.168.88.207:9301","192.168.88.207:9302"]
cluster.initial_master_nodes: ["node-1"]
ingest.geoip.downloader.enabled: false
xpack.security.enabled: false
node3:
cluster.name: es-cluster-test
node.name: node-3
node.master: true
node.data: true
network.host: 192.168.88.207
http.port: 9202
transport.port: 9302
discovery.seed_hosts: ["192.168.88.207:9300","192.168.88.207:9301","192.168.88.207:9302"]
cluster.initial_master_nodes: ["node-1"]
ingest.geoip.downloader.enabled: false
xpack.security.enabled: false
在三台机器上
三个节点的配置文件内容分别如下
node1:
cluster.name: es-cluster-test
node.name: node-1
node.master: true
node.data: true
network.host: 192.168.88.207
http.port: 9200
transport.port: 9300
discovery.seed_hosts: ["192.168.88.207:9300","192.168.88.207:9301","192.168.88.207:9302"]
cluster.initial_master_nodes: ["node-1"]
ingest.geoip.downloader.enabled: false
xpack.security.enabled: false
node2:
cluster.name: es-cluster-test
node.name: node-2
node.master: true
node.data: true
network.host: 192.168.88.207
http.port: 9201
transport.port: 9301
discovery.seed_hosts: ["192.168.88.207:9300","192.168.88.207:9301","192.168.88.207:9302"]
cluster.initial_master_nodes: ["node-1"]
ingest.geoip.downloader.enabled: false
xpack.security.enabled: false
node3:
cluster.name: es-cluster-test
node.name: node-3
node.master: true
node.data: true
network.host: 192.168.88.207
http.port: 9202
transport.port: 9302
discovery.seed_hosts: ["192.168.88.207:9300","192.168.88.207:9301","192.168.88.207:9302"]
cluster.initial_master_nodes: ["node-1"]
ingest.geoip.downloader.enabled: false
xpack.security.enabled: false
kibana部署
解压安装
tar -zxvf kibana-7.14.0-linux-x86_64.tar.gz
mv kibana-7.14.0-linux-x86_64 kibana
mv kibana /home/
cd /home
chown -R esuser.esgroup kibana/
修改配置文件
vim kibana.yml
server.port: 5601
server.host: "192.168.88.207"
server.name: "kibana207"
elasticsearch.hosts: ["http://192.168.88.207:9200"]
切换用户
su esuser
后台启动
nohup ./kibana &
ik部署
- 安装和使用见文档:https://github.com/medcl/elasticsearch-analysis-ik
- 如果报版本不一致问题,可以先离线下载zip包。然后解压后将配置文件中的版本号改掉,改成实际es版本即可。vim plugin-descriptor.properties,elasticsearch.version=7.14.0。