前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >es数据的冷热分离实验

es数据的冷热分离实验

作者头像
保持热爱奔赴山海
发布2019-12-24 14:54:25
1.1K0
发布2019-12-24 14:54:25
举报
文章被收录于专栏:数据库相关

系统版本:CentOS7

节点规划:

热数据节点:  192.168.2.4

温数据节点:  192.168.2.190

PS:这里就没分 hot warm cold 这种三级存储,我们一般使用 hot warm 2种即可。

我们这里使用 tar.gz 通用二进制文件

useradd es

# cat /etc/security/limits.d/elasticsearch.conf 

代码语言:javascript
复制
es - nofile 65535
es - noproc 65535
es - memlock unlimited

cd /usr/local/elasticsearch-7.4.2/

mkdir data logs 

chown es.es  /usr/local/elasticsearch-7.4.2/ -R

su - es

cd /usr/local/elasticsearch-7.4.2/

热数据节点:  192.168.2.4 的配置如下:

cat config/elasticsearch.yml 

代码语言:javascript
复制
cluster.name: my-application

node.name: node-1
node.attr.rack: r1

node.attr.temperature: hot

path.data: ./data/
path.logs: ./logs

node.master: true
node.data: true
node.ingest: true

bootstrap.memory_lock: true

network.host: 0.0.0.0
http.port: 9200

cluster.initial_master_nodes: 
  - 192.168.2.4:9300
  - 192.168.2.190:9300
  
discovery.seed_hosts:
  - 192.168.2.4
  - 192.168.2.190
  
gateway.recover_after_nodes: 1
#action.destructive_requires_name: true
############# xpack 的配置项 ####################
#xpack.security.enabled: true
#xpack.security.transport.ssl.enabled: true
xpack.security.audit.enabled: true
xpack.security.audit.logfile.events.include: access_denied, access_granted, anonymous_access_denied, authentication_failed,connection_denied, tampered_request, run_as_denied, run_as_granted
xpack.security.audit.logfile.emit_node_host_address: true
xpack.security.audit.logfile.emit_node_host_name: true
xpack.sql.enabled: true
xpack.ilm.enabled: true

温数据节点:  192.168.2.190

cat config/elasticsearch.yml 

代码语言:javascript
复制
cluster.name: my-application

node.name: es11
node.attr.rack: r1

node.attr.temperature: warm

path.data: ./data/
path.logs: ./logs

node.master: true
node.data: true
node.ingest: true

bootstrap.memory_lock: true

network.host: 0.0.0.0
http.port: 9200

cluster.initial_master_nodes: 
  - 192.168.2.4:9300
  - 192.168.2.190:9300
  
discovery.seed_hosts:
  - 192.168.2.4
  - 192.168.2.190
gateway.recover_after_nodes: 1

#action.destructive_requires_name: true

############# xpack 的配置项 ####################
#xpack.security.enabled: true
#xpack.security.transport.ssl.enabled: true
xpack.security.audit.enabled: true
xpack.security.audit.logfile.events.include: access_denied, access_granted, anonymous_access_denied, authentication_failed,connection_denied, tampered_request, run_as_denied, run_as_granted
xpack.security.audit.logfile.emit_node_host_address: true
xpack.security.audit.logfile.emit_node_host_name: true
xpack.sql.enabled: true
xpack.ilm.enabled: true

启动脚本: 

# cat start.sh 

代码语言:javascript
复制
# es 依赖高版本的jdk 需要先export下
export JAVA_HOME=./jdk/
nohup ./bin/elasticsearch >/dev/null 2>&1 &

停止脚本:

# cat stop.sh 

代码语言:javascript
复制
kill $(jps| grep Elasticsearch | awk '{print $1}')

创建索引,并将数据搬迁到hot节点:

代码语言:javascript
复制
curl -H 'Content-Type: application/json' -X PUT http://localhost:9200/index-2019.10.19?pretty
curl -H 'Content-Type: application/json' -X PUT http://localhost:9200/index-2019.10.19/_settings -d '
{
  "index.routing.allocation.require.temperature": "hot"
}'
image.png
image.png

如果要将 index-2019.10.19 的数据搬迁到温节点,我们使用下面的这个命令就行

代码语言:javascript
复制
curl -H 'Content-Type: application/json' -X PUT http://localhost:9200/index-2019.10.19/_settings -d '
{
  "index.routing.allocation.require.temperature": "warm"
}'

流程跑通后,我们可以写个脚本,将7天前的索引,打标签,存放到es的warm节点(大容量HDD磁盘):

代码语言:javascript
复制
#!/bin/bash

day=$(date +"%Y.%m.%d" -d -7day)
# echo ${day}

curl -H 'Content-Type: application/json'  -X PUT http://192.168.2.4:9200/*-${day}/_settings -d '
{
  "index.routing.allocation.require.temperature": "warm"
}'

另外, 在es7里面 提供 index-lifecycle-management 这个功能, 我们在kibana 界面里面就可以进行配置。 具体可以查阅es官方的文档(个人还是比较喜欢用上面的这种脚本的方案)。

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2019/12/22 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
相关产品与服务
Elasticsearch Service
腾讯云 Elasticsearch Service(ES)是云端全托管海量数据检索分析服务,拥有高性能自研内核,集成X-Pack。ES 支持通过自治索引、存算分离、集群巡检等特性轻松管理集群,也支持免运维、自动弹性、按需使用的 Serverless 模式。使用 ES 您可以高效构建信息检索、日志分析、运维监控等服务,它独特的向量检索还可助您构建基于语义、图像的AI深度应用。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档