基于Docker搭建ES集群,并设置冷热数据节点

1.背景

存在三台服务器分别是 192.168.2.91(master节点、data-content节点、data-hot节点)、192.168.2.92(data-cold节点、ingest节点)、192.168.2.93(master节点、data-content节点、data-hot节点)

冷热数据分离搭建教程

2.搭建91节点 热数据节点

(1)获取到elasticsearch.tar包,使用

java 复制代码
docker load -i elasticsearch.tar

命令生成elasticsearch镜像。

(2)执行命令

java 复制代码
 docker run -t -d --name node-database -p 19200:19200/tcp -p 19201:19201/tcp --restart always 镜像ID 

生成 elasticsearch 容器

(3)进入当前生成的容器内部

docker exec -it 容器ID bash

(4)进入config目录

cd config/

(5)修改elasticsearch.yml 配置文件

java 复制代码
#绑定ip地址
network.host: 0.0.0.0

#绑定端口
http.port: 19200
transport.port: 19201

#索引目录
path.data: /自定义目录/elasticsearch

#日志目录
path.logs: /自定义目录/logs/elasticsearch
####### 集群信息 #######
network.publish_host: 192.168.2.91  集群内部互相暴露出地址 便于互相发现
http.publish_host: 192.168.2.91    集群内部互相暴露出地址 便于互相发现
transport.publish_host: 192.168.2.91  集群内部互相暴露出地址 便于互相发现
transport.publish_port: 19201   集群内部互相暴露出地址 便于互相发现
#集群名称
cluster.name: group

节点角色,master,data_hot,data_content 热数据节点 以及 master节点

java 复制代码
node.roles: [master,data_hot,data_content]
node.attr.temperature: hot  #说明该节点是热数据节点
#节点名称
node.name: group-node-1

#节点自定义属性
#node.attr.rack: r1

#启动时传递节点列表
discovery.seed_hosts: ["192.168.2.91", "192.168.2.92","192.168.2.93"]

#集群节点
cluster.initial_master_nodes: ["group-node-1","group-node-2","group-node-3"]

####### 集群信息 #######
#设置在节点间传输数据时是否压缩,默认为 False,不压缩。
#transport.tcp.compress: true
 #心跳超时时间
#discovery.zen.ping_timeout: 120s
#节点检测时间
#discovery.zen.fd.ping_interval: 120s
#ping 超时时间
#discovery.zen.fd.ping_timeout: 120s
#心跳重试次数
#discovery.zen.fd.ping_retries: 6

#自动创建索引
action.auto_create_index: false
#index.mapper.dynamic: false
#设置堆大小,内存占比
indices.fielddata.cache.size: 30%
#内存
indices.memory.index_buffer_size: 30%

ingest.geoip.downloader.enabled: false

action.destructive_requires_name: false
#锁定内存
bootstrap.memory_lock: false

index.codec: best_compression

#threadpool.index.type: fixed
#threadpool.index.size: 100
#threadpool.index.queue_size: 500
#threadpool.bulk.queue_size: 1000

cluster.max_shards_per_node: 100000

thread_pool.write.queue_size: 2000

#增加新的参数,head插件可以访问es
http.cors.enabled: true
http.cors.allow-origin: "*"

#Enable security features
xpack.security.enabled: true
xpack.security.enrollment.enabled: true

#是否开启ssl
xpack.security.http.ssl:
  enabled: false
  keystore.path: certs/http.p12

#节点之间数据传输加密
xpack.security.transport.ssl:
  enabled: true
  verification_mode: certificate
  keystore.path: certs/elastic-certificates.p12
  truststore.path: certs/elastic-certificates.p12

(7)重启当前服务器中的ES容器

java 复制代码
docker restart 容器ID

3.搭建92节点

(1)

java 复制代码
重复91节点所有工作,只不过在修改elasticsearch.yml 配置文件中修改为如下信息
####### 集群信息 #######
network.publish_host: 192.168.2.92
http.publish_host: 192.168.2.92
transport.publish_host: 192.168.2.92
transport.publish_port: 19201
#节点角色,冷数据节点、ingest计算节点
node.roles: [data_cold,ingest]
#标记为冷数据节点
node.attr.temperature: cold
#节点名称
node.name: group-node-2

(2)重启当前服务器中的ES容器

java 复制代码
docker restart 容器ID

4.搭建93节点

(1)重复91节点所有工作,只不过在修改elasticsearch.yml 配置文件中修改为如下信息

java 复制代码
#集群名称
network.publish_host: 192.168.2.93
http.publish_host: 192.168.2.93
transport.publish_host: 192.168.2.93
transport.publish_port: 19201
#节点角色,热数据节点、数据存储节点、mater节点
node.roles: [master,data_hot,data_content]
#标记为冷数据节点
node.attr.temperature: hot
#节点名称
node.name: group-node-3

(2)重启当前服务器中的ES容器

java 复制代码
docker restart 容器ID

5.测试是否搭建成功

浏览器输入https://192.168.2.91:19200/_cluster/health 说明有一个集群产生了 包含3个节点

相关推荐
Elasticsearch26 分钟前
使用 Node.js Elasticsearch 客户端索引大型 CSV 文件
elasticsearch
没有bug.的程序员1 小时前
微服务基础设施清单:必须、应该、可以、无需的四级分类指南
java·jvm·微服务·云原生·容器·架构
Elastic 中国社区官方博客1 小时前
Elasticsearch:构建一个 AI 驱动的电子邮件钓鱼检测
大数据·数据库·人工智能·elasticsearch·搜索引擎·ai·全文检索
Elastic 中国社区官方博客2 小时前
Kibana 数据可视化的新配色方案 —— 我们如何以及为什么创建它
大数据·elasticsearch·搜索引擎·信息可视化·全文检索·kibana
卡布叻_星星2 小时前
Docker之Windows与Linux不同架构部署理解
linux·windows·docker
weixin_462446233 小时前
【实战原创】Docker 清理指南:以 Coze Studio 为例的资源保留与清理实践(非万能方案)
docker·容器·eureka
hkNaruto3 小时前
【docker】docker exec -it 报错 open /dev/pts/0: operation not permitted
运维·docker·容器
米花町的小侦探3 小时前
WSL创建pgsql容器脚本
docker·postgresql
一个想打拳的程序员3 小时前
无需复杂配置!用%20docker-webtop%20打造跨设备通用%20Linux%20桌面,加载cpolar远程访问就这么简单
java·人工智能·docker·容器
山沐与山3 小时前
【K8S】Kubernetes架构与原理详解
容器·架构·kubernetes