随笔(三十二)『Linux - es集群 + kibana』

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台都操作)

#停止firewalld服务
systemctl stop firewalld

#禁止firewalld服务开机启动
systemctl disable firewalld

4、创建目录,并把es压缩包放入(3台都操作)

mkdir -p /usr/es

image

5、解压es压缩包,并修改名称(3台都操作)

解压:
tar -zvxf elasticsearch-7.8.0-linux-x86_64.tar.gz

修改名称:
mv elasticsearch-7.8.0 es-cluster

image

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
#ip 地址,每个节点的地址不能重复
network.host: 192.168.195.102
#是不是有资格主节点
node.master: true
node.data: true
#服务端口号,在同一机器下必须不一样,不同的机器,一般是9200
http.port: 9200
#集群间通信端口号,在同一机器下必须不一样,不同的机器,一般是9300
transport.tcp.port: 9300
# head 插件需要这打开这两个配置
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
#es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举 master
cluster.initial_master_nodes: ["node-1"]
#es7.x 之后新增的配置,节点发现
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
#集群内同时启动的数据任务个数,默认是 2 个
cluster.routing.allocation.cluster_concurrent_rebalance: 16
#添加或删除节点及负载均衡时并发恢复的线程个数,默认 4 个
cluster.routing.allocation.node_concurrent_recoveries: 16
#初始化数据恢复时,并发恢复线程的个数,默认 4 个
cluster.routing.allocation.node_initial_primaries_recoveries: 16

7.2、 103节点

#集群名称
cluster.name: cluster-es
#节点名称,每个节点的名称不能重复
node.name: node-2
#ip 地址,每个节点的地址不能重复
network.host: 192.168.195.103
#是不是有资格主节点
node.master: true
node.data: true
#服务端口号,在同一机器下必须不一样,不同的机器,一般是9200
http.port: 9200
#集群间通信端口号,在同一机器下必须不一样,不同的机器,一般是9300
transport.tcp.port: 9300
# head 插件需要这打开这两个配置
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
#es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举 master
cluster.initial_master_nodes: ["node-1"]
#es7.x 之后新增的配置,节点发现
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
#集群内同时启动的数据任务个数,默认是 2 个
cluster.routing.allocation.cluster_concurrent_rebalance: 16
#添加或删除节点及负载均衡时并发恢复的线程个数,默认 4 个
cluster.routing.allocation.node_concurrent_recoveries: 16
#初始化数据恢复时,并发恢复线程的个数,默认 4 个
cluster.routing.allocation.node_initial_primaries_recoveries: 16

7.3、 104节点

#集群名称
cluster.name: cluster-es
#节点名称,每个节点的名称不能重复
node.name: node-3
#ip 地址,每个节点的地址不能重复
network.host: 192.168.195.104
#是不是有资格主节点
node.master: true
node.data: true
#服务端口号,在同一机器下必须不一样,不同的机器,一般是9200
http.port: 9200
#集群间通信端口号,在同一机器下必须不一样,不同的机器,一般是9300
transport.tcp.port: 9300
# head 插件需要这打开这两个配置
http.cors.allow-origin: "*"
http.cors.enabled: true
http.max_content_length: 200mb
#es7.x 之后新增的配置,初始化一个新的集群时需要此配置来选举 master
cluster.initial_master_nodes: ["node-1"]
#es7.x 之后新增的配置,节点发现
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
#集群内同时启动的数据任务个数,默认是 2 个
cluster.routing.allocation.cluster_concurrent_rebalance: 16
#添加或删除节点及负载均衡时并发恢复的线程个数,默认 4 个
cluster.routing.allocation.node_concurrent_recoveries: 16
#初始化数据恢复时,并发恢复线程的个数,默认 4 个
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

14、测试 浏览器 http://192.168.195.102:9200/_cat/nodes

image

15、es部署启动-碰到的问题

15.1、集群失败,各自为主

原因:配置文件elasticsearch.yml没编写好,然后启动了es。

解决方案:elasticsearch.yml编写好,删除了所有节点的data目录。

16、部署kibana(此时在root账户)

16.1、创建目录,并把kibana压缩包放入(任意节点都可,这个放在192.168.195.102节点)

mkdir -p /usr/kibana

image

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

image

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 &

16.7、测试 浏览器 http://192.168.195.102:5601

image

posted @   小昕昕  阅读(40)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· DeepSeek 开源周回顾「GitHub 热点速览」
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET 10首个预览版发布:重大改进与新特性概览!
· AI与.NET技术实操系列(二):开始使用ML.NET
· 单线程的Redis速度为什么快?
点击右上角即可分享
微信分享提示