EFK教程(3)

Wesley13
• 阅读 736

EFK教程(3)

基于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盘上


架构

架构图

EFK教程(3)

服务器配置

EFK教程(3)


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"

EFK教程(3)

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

EFK教程(3)

# 安装包下载和部署请参考第一篇《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"

EFK教程(3)


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"

EFK教程(3)

EFK教程(3)

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

EFK教程(3)

# 安装包下载和部署请参考第一篇《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"

EFK教程(3)


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"

EFK教程(3)

EFK教程(3)

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

EFK教程(3)

# 安装包下载和部署请参考第一篇《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"

EFK教程(3)


测试

将所有索引移到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"

EFK教程(3)

将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)

点赞
收藏
评论区
推荐文章
blmius blmius
3年前
MySQL:[Err] 1292 - Incorrect datetime value: ‘0000-00-00 00:00:00‘ for column ‘CREATE_TIME‘ at row 1
文章目录问题用navicat导入数据时,报错:原因这是因为当前的MySQL不支持datetime为0的情况。解决修改sql\mode:sql\mode:SQLMode定义了MySQL应支持的SQL语法、数据校验等,这样可以更容易地在不同的环境中使用MySQL。全局s
皕杰报表之UUID
​在我们用皕杰报表工具设计填报报表时,如何在新增行里自动增加id呢?能新增整数排序id吗?目前可以在新增行里自动增加id,但只能用uuid函数增加UUID编码,不能新增整数排序id。uuid函数说明:获取一个UUID,可以在填报表中用来创建数据ID语法:uuid()或uuid(sep)参数说明:sep布尔值,生成的uuid中是否包含分隔符'',缺省为
Jacquelyn38 Jacquelyn38
3年前
2020年前端实用代码段,为你的工作保驾护航
有空的时候,自己总结了几个代码段,在开发中也经常使用,谢谢。1、使用解构获取json数据let jsonData  id: 1,status: "OK",data: 'a', 'b';let  id, status, data: number   jsonData;console.log(id, status, number )
Wesley13 Wesley13
3年前
mysql设置时区
mysql设置时区mysql\_query("SETtime\_zone'8:00'")ordie('时区设置失败,请联系管理员!');中国在东8区所以加8方法二:selectcount(user\_id)asdevice,CONVERT\_TZ(FROM\_UNIXTIME(reg\_time),'08:00','0
Wesley13 Wesley13
3年前
00:Java简单了解
浅谈Java之概述Java是SUN(StanfordUniversityNetwork),斯坦福大学网络公司)1995年推出的一门高级编程语言。Java是一种面向Internet的编程语言。随着Java技术在web方面的不断成熟,已经成为Web应用程序的首选开发语言。Java是简单易学,完全面向对象,安全可靠,与平台无关的编程语言。
Stella981 Stella981
3年前
Django中Admin中的一些参数配置
设置在列表中显示的字段,id为django模型默认的主键list_display('id','name','sex','profession','email','qq','phone','status','create_time')设置在列表可编辑字段list_editable
Stella981 Stella981
3年前
Docker 部署SpringBoot项目不香吗?
  公众号改版后文章乱序推荐,希望你可以点击上方“Java进阶架构师”,点击右上角,将我们设为★“星标”!这样才不会错过每日进阶架构文章呀。  !(http://dingyue.ws.126.net/2020/0920/b00fbfc7j00qgy5xy002kd200qo00hsg00it00cj.jpg)  2
Wesley13 Wesley13
3年前
EFK教程
!(https://fzxiaomange.com/img/efk/rolesepcover.png)通过将elasticsearch的data、ingest、master角色进行分离,搭建起高性能高可用的ES架构作者:“发颠的小狼”,欢迎转载与投稿目录▪用途▪架构▪步骤说明▪e
Wesley13 Wesley13
3年前
MySQL部分从库上面因为大量的临时表tmp_table造成慢查询
背景描述Time:20190124T00:08:14.70572408:00User@Host:@Id:Schema:sentrymetaLast_errno:0Killed:0Query_time:0.315758Lock_
Python进阶者 Python进阶者
9个月前
Excel中这日期老是出来00:00:00,怎么用Pandas把这个去除
大家好,我是皮皮。一、前言前几天在Python白银交流群【上海新年人】问了一个Pandas数据筛选的问题。问题如下:这日期老是出来00:00:00,怎么把这个去除。二、实现过程后来【论草莓如何成为冻干莓】给了一个思路和代码如下:pd.toexcel之前把这