EFK教程(3) - ElasticSearch冷热数据分离

基于ElasticSearch多实例架构,实现资源合理分配、冷热数据分离
作者:“发颠的小狼”,欢迎转载与投稿
目录
▪ 用途
▪ 架构
▪ 192.168.1.51 elasticsearch-data部署双实例
▪ 192.168.1.52 elasticsearch-data部署双实例
▪ 192.168.1.53 elasticsearch-data部署双实例
▪ 测试
用途
前情提要:
▷ 在第一篇《EFK教程 - 快速入门指南》中,阐述了EFK的安装部署,其中ES的架构为三节点,即master、ingest、data角色同时部署在三台服务器上。
▷ 在第二篇《EFK教程 - ElasticSearch高性能高可用架构》中,阐述了EFK的data/ingest/master角色的用途及分别部署三节点,在实现性能最大化的同时保障高可用
前两篇文章,ES集群中只存在一个实例,而在本文中,将在一个集群中部署多个ES实例,来实现资源合理分配。例如data服务器存在SSD与SAS硬盘,可以将热数据存放到SSD,而冷数据存放到SAS,实现数据冷热分离。
在本文中,将为data服务器创建2个实例,分别基于SSD和基于SAS硬盘,将nginx的9月份索引放在SAS盘上,其它的全放在SSD盘上
架构
架构图

服务器配置

192.168.1.51 elasticsearch-data部署双实例
索引迁移(此步不能忽略):将192.168.1.51上的索引放到其它2台data节点上
curl -X PUT "192.168.1.31:9200/*/_settings?pretty" -H 'Content-Type: application/json' -d'
{
"index.routing.allocation.include._ip": "192.168.1.52,192.168.1.53"
}'
确认当前索引存储位置:确认所有索引不在192.168.1.51节点上
curl "http://192.168.1.31:9200/_cat/shards?h=n"

停掉192.168.1.51的进程,修改目录结构及配置:请自行按SSD和SAS硬盘挂载好数据盘

# 安装包下载和部署请参考第一篇《EFK教程 - 快速入门指南》
cd /opt/software/
tar -zxvf elasticsearch-7.3.2-linux-x86_64.tar.gz
mv /opt/elasticsearch /opt/elasticsearch-SAS
mv elasticsearch-7.3.2 /opt/
mv /opt/elasticsearch-7.3.2 /opt/elasticsearch-SSD
chown elasticsearch.elasticsearch /opt/elasticsearch-* -R
rm -rf /data/SAS/*
chown elasticsearch.elasticsearch /data/* -R
mkdir -p /opt/logs/elasticsearch-SAS
mkdir -p /opt/logs/elasticsearch-SSD
chown elasticsearch.elasticsearch /opt/logs/* -R
SAS实例/opt/elasticsearch-SAS/config/elasticsearch.yml配置
cluster.name: my-application
node.name: 192.168.1.51-SAS
path.data: /data/SAS
path.logs: /opt/logs/elasticsearch-SAS
network.host: 192.168.1.51
http.port: 9200
transport.port: 9300
# discovery.seed_hosts和cluster.initial_master_nodes 一定要带上端口号,不然会走http.port和transport.port端口
discovery.seed_hosts: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]
cluster.initial_master_nodes: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: false
node.ingest: false
node.data: true
# 本机只允行启2个实例
node.max_local_storage_nodes: 2
SSD实例/opt/elasticsearch-SSD/config/elasticsearch.yml配置
cluster.name: my-application
node.name: 192.168.1.51-SSD
path.data: /data/SSD
path.logs: /opt/logs/elasticsearch-SSD
network.host: 192.168.1.51
http.port: 9201
transport.port: 9301
# discovery.seed_hosts和cluster.initial_master_nodes 一定要带上端口号,不然会走http.port和transport.port端口
discovery.seed_hosts: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]
cluster.initial_master_nodes: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: false
node.ingest: false
node.data: true
# 本机只允行启2个实例
node.max_local_storage_nodes: 2
SAS实例和SSD实例启动方式
sudo -u elasticsearch /opt/elasticsearch-SAS/bin/elasticsearch
sudo -u elasticsearch /opt/elasticsearch-SSD/bin/elasticsearch
确认SAS和SSD已启2实例
curl "http://192.168.1.31:9200/_cat/nodes?v"

192.168.1.52 elasticsearch-data部署双实例
索引迁移(此步不能忽略):将192.168.1.52上的索引放到其它2台data节点上
curl -X PUT "192.168.1.31:9200/*/_settings?pretty" -H 'Content-Type: application/json' -d'
{
"index.routing.allocation.include._ip": "192.168.1.51,192.168.1.53"
}'
确认当前索引存储位置: 确认所有索引不在192.168.1.52节点上
curl "http://192.168.1.31:9200/_cat/shards?h=n"


停掉192.168.1.52的进程,修改目录结构及配置:请自行按SSD和SAS硬盘挂载好数据盘

# 安装包下载和部署请参考第一篇《EFK教程 - 快速入门指南》
cd /opt/software/
tar -zxvf elasticsearch-7.3.2-linux-x86_64.tar.gz
mv /opt/elasticsearch /opt/elasticsearch-SAS
mv elasticsearch-7.3.2 /opt/
mv /opt/elasticsearch-7.3.2 /opt/elasticsearch-SSD
chown elasticsearch.elasticsearch /opt/elasticsearch-* -R
rm -rf /data/SAS/*
chown elasticsearch.elasticsearch /data/* -R
mkdir -p /opt/logs/elasticsearch-SAS
mkdir -p /opt/logs/elasticsearch-SSD
chown elasticsearch.elasticsearch /opt/logs/* -R
SAS实例/opt/elasticsearch-SAS/config/elasticsearch.yml配置
cluster.name: my-application
node.name: 192.168.1.52-SAS
path.data: /data/SAS
path.logs: /opt/logs/elasticsearch-SAS
network.host: 192.168.1.52
http.port: 9200
transport.port: 9300
# discovery.seed_hosts和cluster.initial_master_nodes 一定要带上端口号,不然会走http.port和transport.port端口
discovery.seed_hosts: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]
cluster.initial_master_nodes: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: false
node.ingest: false
node.data: true
# 本机只允行启2个实例
node.max_local_storage_nodes: 2
SSD实例/opt/elasticsearch-SSD/config/elasticsearch.yml配置
cluster.name: my-application
node.name: 192.168.1.52-SSD
path.data: /data/SSD
path.logs: /opt/logs/elasticsearch-SSD
network.host: 192.168.1.52
http.port: 9201
transport.port: 9301
# discovery.seed_hosts和cluster.initial_master_nodes 一定要带上端口号,不然会走http.port和transport.port端口
discovery.seed_hosts: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]
cluster.initial_master_nodes: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: false
node.ingest: false
node.data: true
# 本机只允行启2个实例
node.max_local_storage_nodes: 2
SAS实例和SSD实例启动方式
sudo -u elasticsearch /opt/elasticsearch-SAS/bin/elasticsearch
sudo -u elasticsearch /opt/elasticsearch-SSD/bin/elasticsearch
确认SAS和SSD已启2实例
curl "http://192.168.1.31:9200/_cat/nodes?v"

192.168.1.53 elasticsearch-data部署双实例
索引迁移(此步不能忽略):一定要做这步,将192.168.1.53上的索引放到其它2台data节点上
curl -X PUT "192.168.1.31:9200/*/_settings?pretty" -H 'Content-Type: application/json' -d'
{
"index.routing.allocation.include._ip": "192.168.1.51,192.168.1.52"
}'
确认当前索引存储位置:确认所有索引不在192.168.1.52节点上
curl "http://192.168.1.31:9200/_cat/shards?h=n"


停掉192.168.1.53的进程,修改目录结构及配置:请自行按SSD和SAS硬盘挂载好数据盘

# 安装包下载和部署请参考第一篇《EFK教程 - 快速入门指南》
cd /opt/software/
tar -zxvf elasticsearch-7.3.2-linux-x86_64.tar.gz
mv /opt/elasticsearch /opt/elasticsearch-SAS
mv elasticsearch-7.3.2 /opt/
mv /opt/elasticsearch-7.3.2 /opt/elasticsearch-SSD
chown elasticsearch.elasticsearch /opt/elasticsearch-* -R
rm -rf /data/SAS/*
chown elasticsearch.elasticsearch /data/* -R
mkdir -p /opt/logs/elasticsearch-SAS
mkdir -p /opt/logs/elasticsearch-SSD
chown elasticsearch.elasticsearch /opt/logs/* -R
SAS实例/opt/elasticsearch-SAS/config/elasticsearch.yml配置
cluster.name: my-application
node.name: 192.168.1.53-SAS
path.data: /data/SAS
path.logs: /opt/logs/elasticsearch-SAS
network.host: 192.168.1.53
http.port: 9200
transport.port: 9300
# discovery.seed_hosts和cluster.initial_master_nodes 一定要带上端口号,不然会走http.port和transport.port端口
discovery.seed_hosts: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]
cluster.initial_master_nodes: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: false
node.ingest: false
node.data: true
# 本机只允行启2个实例
node.max_local_storage_nodes: 2
SSD实例/opt/elasticsearch-SSD/config/elasticsearch.yml配置
cluster.name: my-application
node.name: 192.168.1.53-SSD
path.data: /data/SSD
path.logs: /opt/logs/elasticsearch-SSD
network.host: 192.168.1.53
http.port: 9201
transport.port: 9301
# discovery.seed_hosts和cluster.initial_master_nodes 一定要带上端口号,不然会走http.port和transport.port端口
discovery.seed_hosts: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]
cluster.initial_master_nodes: ["192.168.1.31:9300","192.168.1.32:9300","192.168.1.33:9300"]
http.cors.enabled: true
http.cors.allow-origin: "*"
node.master: false
node.ingest: false
node.data: true
# 本机只允行启2个实例
node.max_local_storage_nodes: 2
SAS实例和SSD实例启动方式
sudo -u elasticsearch /opt/elasticsearch-SAS/bin/elasticsearch
sudo -u elasticsearch /opt/elasticsearch-SSD/bin/elasticsearch
确认SAS和SSD已启2实例
curl "http://192.168.1.31:9200/_cat/nodes?v"

测试
将所有索引移到SSD硬盘上
# 下面的参数会在后面的文章讲解,此处照抄即可
curl -X PUT "192.168.1.31:9200/*/_settings?pretty" -H 'Content-Type: application/json' -d'
{
"index.routing.allocation.include._host_ip": "",
"index.routing.allocation.include._host": "",
"index.routing.allocation.include._name": "",
"index.routing.allocation.include._ip": "",
"index.routing.allocation.require._name": "*-SSD"
}'
确认所有索引全在SSD硬盘上
curl "http://192.168.1.31:9200/_cat/shards?h=n"

将nginx9月份的日志索引迁移到SAS硬盘上
curl -X PUT "192.168.1.31:9200/nginx_*_2019.09/_settings?pretty" -H 'Content-Type: application/json' -d'
{
"index.routing.allocation.require._name": "*-SAS"
}'
确认nginx9月份的日志索引迁移到SAS硬盘上
curl "http://192.168.1.31:9200/_cat/shards"

EFK教程(3) - ElasticSearch冷热数据分离的更多相关文章
- EFK教程(4) - ElasticSearch集群TLS加密通讯
基于TLS实现ElasticSearch集群加密通讯 作者:"发颠的小狼",欢迎转载 目录 ▪ 用途 ▪ ES节点信息 ▪ Step1. 关闭服务 ▪ Step2. 创建CA证书 ...
- ELK冷热数据分离
通常情况下,我们使用ELK日志分析平台最常用的数据时间为1周或一个月(因业务场景不同,可能存在差别),时间比较长的数据没有特殊情况可能我们就没有必要再进行查询了,但是因业务需求或者作为凭证,这些日 ...
- elasticsearch 冷热数据的读写分离
步骤 一.冷热分离集群配置 比如三个机器共六个node的es集群. 每个机器上各挂载一个ssd 和 一个sata.每个机器需要启动两个es进程.每个进程对应不同类型的磁盘. 关键配置: node.ma ...
- [elk]elasticsearch实现冷热数据分离
本文以最新的elasticsearch-6.3.0.tar.gz为例,为了节约资源,本文将副本调为0, 无client角色 https://www.elastic.co/blog/hot-warm-a ...
- EFK教程(5) - ES集群开启用户认证
基于ES内置及自定义用户实现kibana和filebeat的认证 作者:"发颠的小狼",欢迎转载 目录 ▪ 用途 ▪ 关闭服务 ▪ elasticsearch-修改elastics ...
- ElasticSearch实战系列十: ElasticSearch冷热分离架构
前言 本文主要介绍ElasticSearch冷热分离架构以及实现. 冷热分离架构介绍 冷热分离是目前ES非常火的一个架构,它充分的利用的集群机器的优劣来实现资源的调度分配.ES集群的索引写入及查询速度 ...
- ElasticSearch——冷热(hot&warm)架构部署
背景 最近在做订单数据存储到ElasticSearch,考虑到数据量比较大,采用冷热架构来存储,每月建立一个新索引,数据先写入到热索引,通过工具将3个月后的索引自动迁移到冷节点上. ElasticSe ...
- 分布式mysql 和 zk ( zookeeper )的分布式的区别 含冷热数据讨论
zk ( zookeeper )的分布式仅仅指的是备份模式. 分布式 mysql 不仅仅要关注备份(从以往的半主,主主,到 paxos). (mysql 比 hbase 的region成熟, hdfs ...
- elasticsearch 索引数据多了怎么办,如何调优,部署 ?
面试官:想了解大数据量的运维能力. 解答:索引数据的规划,应在前期做好规划,正所谓"设计先行,编码在后", 这样才能有效的避免突如其来的数据激增导致集群处理能力不足引发的线上客户 ...
随机推荐
- Netty源码分析之ChannelPipeline(一)—ChannelPipeline的构造与初始化
Netty中ChannelPipeline实际上类似与一条数据管道,负责传递Channel中读取的消息,它本质上是基于责任链模式的设计与实现,无论是IO事件的拦截器,还是用户自定义的ChannelHa ...
- Django之CBV视图源码分析(工作原理)
1.首先我们先在urls.py定义CBV的路由匹配. FBV的路由匹配: 2.然后,在views.py创建一名为MyReg的类: 注意:该类必须继续View类,且方法名必须与请求方式相同(后面会详解) ...
- < 配置jupyer notebook遇到的问题 - 500 : Internal Server Error >
< anaconda配置jupyer notebook遇到的问题 - 500 : Internal Server Error > 问题描述: 我的jupyer notebook是在anac ...
- 《利用Python进行数据分析·第2版》第四章 Numpy基础:数组和矢量计算
<利用Python进行数据分析·第2版>第四章 Numpy基础:数组和矢量计算 numpy高效处理大数组的数据原因: numpy是在一个连续的内存块中存储数据,独立于其他python内置对 ...
- dubbo初学采坑记
写在前面的话 dubbo 现在是apache组织旗下的项目,相信国内也有很多人使用.最近一个同事离职,我就接手了他的项目.远程通讯就是用的dubbo框架来实现的.使用Intelij idea 写了一个 ...
- Eureka -- 浅谈Eureka
目录: 一:Eureka介绍 二:Eureka架构图 三:Eureka组件 四:Eureka作用 五:Eureka和Zookeeper对比 什么是Eureka 引入SpringCloud中文文档介绍 ...
- Linux x64 Hadoop-2.4.1配置-解决错误Unable to load native-hadoop library for your platform
网上配置hadoop的教程一堆,各不尽相同,但没有一个是完整系统的. 下面给出遇到的错误的解决方法,相信能解决很多人的问题. 错误:Exception in thread "main&quo ...
- 函数进阶(三) day14
目录 昨日内容 迭代器 可迭代对象 迭代器对象 for循环原理 三元表达式 列表推导式 字典生成式 zip 生成器表达式 生成器 yield 递归 今日内容 匿名函数 内置方法 掌握 了解 异常处理 ...
- fenby C语言 P16
while先判断,不符合,不执行 dowhile后判断,不符合,执行一次 #include <stdio.h> int main(){ int i=1,sum=0; do{ sum=sum ...
- 完美解决Python与anaconda之间的冲突问题
anaconda指的是一个开源的Python发行版本,其包含了conda.Python等180多个科学包及其依赖项.因为包含了大量的科学包,Anaconda 的下载文件比较大(约 515 MB),如果 ...