es数据的冷热分离实验
admin
2023-02-22 21:00:08
0

注意:演示用的2节点es,有些参数配置不太合理,生产环境还需要更严格的参数设定(例如必须开启密码验证)。


系统版本: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 

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 

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 

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 

# es 依赖高版本的jdk 需要先export下
export JAVA_HOME=./jdk/
nohup ./bin/elasticsearch >/dev/null 2>&1 &



停止脚本:

# cat stop.sh 

kill $(jps| grep Elasticsearch | awk '{print $1}')



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

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"
}'


es数据的冷热分离实验



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

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



流程跑通后,我们可以写个脚本,作用有2个:

1、提前创建后一天的索引,并确保将其落到hot节点

2、将7天前的索引,打标签,存放到es的warm节点(大容量HDD磁盘):

#!/bin/bash

# 创建新的索引,语句类似下面5行,需要根据自己情况修改(建议使用for循环创建index)
# 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"
# }'

day=$(date +"%Y.%m.%d" -d -7day)

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官方的文档(个人还是比较喜欢用上面的这种脚本的方案)。



相关内容

热门资讯

蒋万安借“725上凯道”成蓝营... 中国国民党25日将于台北凯道举办“我是人,我反毒台”集会,向民进党当局抗议中联毒油案。对此,资深媒体...
波轮式全自动洗衣机脱水时波轮转 波轮式全自动洗衣机脱水时波轮转1、衣物放置不平导致;2、排水系统发生阻塞。3、顶部的安全开关损坏;4...
洗衣机不出水怎么查原因 当洗衣机不出水时,一定是出了问题。下面就是一些可能的原因及其解决方法:1. 电源问题洗衣机不能正常工...
半自动洗衣机放不出水是什么原因... 1、检查过滤网是否堵塞。若堵塞了需要将脏东西取出来,然后再用清水将过滤网清洗干净。2、检查一下是不是...
全自动洗衣机不出水是什么原因 1、进水口的滤网被水中的杂质堵住。2、控制板上的进水继电器坏了。3、电路故障,进水电磁阀有故障或者插...
抽油烟机只通电不转怎么回事 只通电不转的故障原因和解决方法:1、电容量减小或损坏。解决方法:抽油烟机电机不转,还有嗡嗡声,一般是...
谷歌被罚9亿欧元后,特朗普称欧... 当地时间7月23日,欧盟委员会指控美国谷歌公司违反欧盟《数字市场法》,对其处以8.9亿欧元罚款。这一...
14对14,中国反击欧盟,干净... 对于欧盟的指手画脚,中国第一时间反击了。14:14。干净利落,来而不往非礼也。国际博弈,从来如此:没...
风未到,人已行!凌晨不眠!一场... 7月24日晚,台风“红霞”持续逼近,市应急管理局五楼会议室灯火通明,市应急管理局党委书记、局长李见秋...
省自然资源厅部署12号台风“红... 受今年第12号台风“红霞”影响,我省中部和南部地区有一轮强降雨过程,部分地区有较高的地质灾害风险。自...