1、使用VMware安装虚拟机
参考:
http://e.betheme.net/article/show-298568.html?action=onClick
2、准备3台虚拟机
IP分别为:
vm_es_1:192.168.195.102
vm_es_2:192.168.195.103
vm_es_3:192.168.195.104
3、关闭防火墙(3台都操作)
systemctl stop firewalld
systemctl disable firewalld
4、创建目录,并把es压缩包放入(3台都操作)
mkdir -p /usr/es

5、解压es压缩包,并修改名称(3台都操作)
解压:
tar -zvxf elasticsearch-7.8.0-linux-x86_64.tar.gz
修改名称:
mv elasticsearch-7.8.0 es-cluster

6、创建用户es并赋权,elasticsearch不允许root直接运行(3台都操作)
#新增 es 用户
useradd es
#为 es 用户设置密码 - shendian
passwd es
# 赋权
chown -R es:es /usr/es/es-cluster
7、修改配置文件 vim /usr/es/es-cluster/config/elasticsearch.yml
7.1、 102节点
cluster.name: cluster-es
node.name: node-1
network.host: 192.168.195.102
node.master: true
node.data: true
http.port: 9200
transport.tcp.port: 9300
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
cluster.initial_master_nodes: ["node-1"]
discovery.seed_hosts: ["192.168.195.102:9300","192.168.195.103:9300","192.168.195.104:9300"]
gateway.recover_after_nodes: 2
network.tcp.keep_alive: true
network.tcp.no_delay: true
transport.tcp.compress: true
cluster.routing.allocation.cluster_concurrent_rebalance: 16
cluster.routing.allocation.node_concurrent_recoveries: 16
cluster.routing.allocation.node_initial_primaries_recoveries: 16
7.2、 103节点
cluster.name: cluster-es
node.name: node-2
network.host: 192.168.195.103
node.master: true
node.data: true
http.port: 9200
transport.tcp.port: 9300
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
cluster.initial_master_nodes: ["node-1"]
discovery.seed_hosts: ["192.168.195.102:9300","192.168.195.103:9300","192.168.195.104:9300"]
gateway.recover_after_nodes: 2
network.tcp.keep_alive: true
network.tcp.no_delay: true
transport.tcp.compress: true
cluster.routing.allocation.cluster_concurrent_rebalance: 16
cluster.routing.allocation.node_concurrent_recoveries: 16
cluster.routing.allocation.node_initial_primaries_recoveries: 16
7.3、 104节点
cluster.name: cluster-es
node.name: node-3
network.host: 192.168.195.104
node.master: true
node.data: true
http.port: 9200
transport.tcp.port: 9300
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
cluster.initial_master_nodes: ["node-1"]
discovery.seed_hosts: ["192.168.195.102:9300","192.168.195.103:9300","192.168.195.104:9300"]
gateway.recover_after_nodes: 2
network.tcp.keep_alive: true
network.tcp.no_delay: true
transport.tcp.compress: true
cluster.routing.allocation.cluster_concurrent_rebalance: 16
cluster.routing.allocation.node_concurrent_recoveries: 16
cluster.routing.allocation.node_initial_primaries_recoveries: 16
8、修改文件 vim /etc/security/limits.conf(3台都操作)
# 修改内容添加到末尾
es soft nofile 65536
es hard nofile 65536
9、修改文件 vim /etc/security/limits.d/20-nproc.conf(3台都操作)
es soft nofile 65536
es hard nofile 65536
* hard nproc 4096
10、修改文件 vim /etc/sysctl.conf(3台都操作)
vm.max_map_count=655360
11、重新加载,使修改的文件生效(3台都操作)
sysctl -p
12、切换为es用户(3台都操作)
su es
13、启动es(3台都操作)
cd /usr/es/es-cluster/
bin/elasticsearch -d

15、es部署启动-碰到的问题
15.1、集群失败,各自为主
原因:配置文件elasticsearch.yml没编写好,然后启动了es。
解决方案:elasticsearch.yml编写好,删除了所有节点的data目录。
16、部署kibana(此时在root账户)
16.1、创建目录,并把kibana压缩包放入(任意节点都可,这个放在192.168.195.102节点)
mkdir -p /usr/kibana

16.2、解压kibana压缩包,并修改名称
解压:tar -zvxf kibana-7.8.0-linux-x86_64.tar.gz
改名:mv kibana-7.8.0-linux-x86_64 kibana-7.8.0

16.3、修改配置文件 vim /usr/kibana/kibana-7.8.0/config/kibana.yml
i18n.locale: "zh-CN"
kibana.index: ".kibana"
server.port: 5601
server.host: "192.168.195.102" # kibana本机的地址
elasticsearch.hosts: ["http://192.168.195.102:9200","http://192.168.195.102:9200","http://192.168.195.104:9200"]
16.4、赋权
chown -R es:es /usr/kibana/kibana-7.8.0/
16.5、切换为es用户
su es
16.6、启动kibana
cd /usr/kibana/kibana-7.8.0/bin
nohup ./kibana &

【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?