es集群迁移操作

news/2024/11/19 5:56:50/文章来源:https://www.cnblogs.com/yxh168/p/18198017

logstash迁移集群

     /home/secure/logstash-7.8.1/bin/logstash -f /home/secure/logstash-7.8.1/config/event0515.conf -f --debug
     -f 检查配置文件语法

    /home/secure/logstash-7.8.1/bin/logstash -f /home/secure/logstash-7.8.1/config/event0515.conf > /home/secure/ca/event0515.log 2>&1

    可以使用ssl加密传输并且忽略证书内容验证

input{elasticsearch{hosts =>  ["10.30.90.147:9200"]user => "elastic"password => "11111"index => "full_flow_file_202311,full_flow_file_202312,prob_file_description_202402"//index => "full_flow*,-.security*" //正则匹配多个索引docinfo=>trueslices => 1size => 10000ssl => trueca_file => "/home/secure/147/ca.crt"}
}filter {mutate {remove_field => ["@timestamp", "@version"]}
}output{elasticsearch{hosts => ["https://121.229.203.43:9200"]user => "elastic"password => "111111"index => "%{[@metadata][_index]}"ilm_enabled => falsessl => truessl_certificate_verification => false //这个配置如果配置在input那么就会提示unknow settings
    }
}
logstash.conf示例

 

es集群密码重置

     1.先修改es的配置文件不启用安全认证 然后再重启es服务

      2.重新生成keystore文件

        rm -fr elasticsearch.keystore
       ./elasticsearch-keystore create
        chown -R admin:admin /app/taishi/elasticsearch-7.8.1/config/elasticsearch.keystore

     3.拷贝到其它节点

       scp -r elasticsearch.keystore admin@10.72.17.15:/app/taishi/elasticsearch-7.8.1/config/
       scp -r elasticsearch.keystore admin@10.72.17.23:/app/taishi/elasticsearch-7.8.1/config/

     4.删除原来的系统索引

        curl -X DELETE "10.72.17.7:9200/.security-*"

     5.修改elasticsearch.yml文件配置重新启用安全认证

     6.开始重新设置新的用户密码

        ./elasticsearch-setup-passwords  interactive  --batch --url https://instance:9200

     7.集群启动正常

es迁移字段过大问题

        迁移的时候提示字段内容太长,无法同步成功

        

        

      这个问题在源索引中字段是text类型,同步到新的索引中就自动设置为keyword类型

      同步索引之前必须先给索引创建好索引模板

es索引模板操作

      1.模板操作

         curl -k -u elastic:Transfar111 -XGET http://121.229.203.22:9200/_template/event
         curl -k -u elastic:Transfar111 -XDELETE http://121.229.333.46:9200/_template/event

         同步索引数据前必须先创建索引模板 否则某些列的值会转换异常导致同步丢失
         curl -k -u elastic:Transfar111 -XPUT http://121.229.22.46:9200/_template/event -H 'content-Type:application/json' -d @./event.json

     2.模板操作脚本

#!/bin/baship=${IP}
echo $ip
DATE=`date +%Y%m`
DATE1=`date +%Y`
result_event=`curl -k -s -u elastic:${ES_PASSWD} -XGET https://${ip}:9200/_cat/indices/event_${DATE}`
result_alarm=`curl -k -s -u elastic:${ES_PASSWD} -XGET https://${ip}:9200/_cat/indices/alarm_${DATE}`
DATE2=`date +%m`
if [ ${DATE2} -le 6 ] ; then
result_incident=`curl -k -s -u elastic:${ES_PASSWD} -XGET https://${ip}:9200/_cat/indices/incident_${DATE1}01`
result_merge=`curl -k -s -u elastic:${ES_PASSWD} -XGET https://${ip}:9200/_cat/indices/merge_alarm_${DATE1}01`
DATE3=${DATE1}01
else
result_incident=`curl -k -s -u elastic:${ES_PASSWD} -XGET https://${ip}:9200/_cat/indices/incident_${DATE1}02`
result_merge=`curl -k -s -u elastic:${ES_PASSWD} -XGET https://${ip}:9200/_cat/indices/merge_alarm_${DATE1}02`
DATE3=${DATE1}02
fi
#result_incident=`curl -k -s -u elastic:${ES_PASSWD} -XGET https://${ip}:9200/_cat/indices/incident_${DATE}`
#result_merge=`curl -k -s -u elastic:${ES_PASSWD} -XGET https://${ip}:9200/_cat/indices/merge_alarm_${DATE}`
result_operation=`curl -k -s -u elastic:${ES_PASSWD} -XGET https://${ip}:9200/_cat/indices/operation_incident`
echo -e "####导入event模板####"
curl -k -u elastic:${ES_PASSWD} -XPUT https://${ip}:9200/_template/event -H 'content-Type:application/json' -d @./template/event.json
echo -e "\n"
sleep 1
echo -e "####导入alarm模板####"
curl -k -u elastic:${ES_PASSWD} -XPUT https://${ip}:9200/_template/alarm -H 'content-Type:application/json' -d @./template/alarm.json
echo -e "\n"
sleep 1
echo -e "####导入excep模板####"
curl -k -u elastic:${ES_PASSWD} -XPUT https://${ip}:9200/_template/excep -H 'content-Type:application/json' -d @./template/excep.json
echo -e "\n"
sleep 1
echo "####导入incident模板####"
curl -k -u elastic:${ES_PASSWD} -XPUT https://${ip}:9200/_template/incident -H 'content-Type:application/json' -d @./template/incident.json
echo -e "\n"
sleep 1
echo "####导入merge_alarm模板####"
curl -k -u elastic:${ES_PASSWD} -XPUT https://${ip}:9200/_template/merge_alarm -H 'content-Type:application/json' -d @./template/merge_alarm.json
echo -e "\n"
sleep 1
echo "####导入operation模板####"
curl -k -u elastic:${ES_PASSWD} -XPUT https://${ip}:9200/_template/operation -H 'content-Type:application/json' -d @./template/operation.json
echo -e "\n"
sleep 1
echo "####导入unmatch模板####"
curl -k -u elastic:${ES_PASSWD} -XPUT https://${ip}:9200/_template/unmatch -H 'content-Type:application/json' -d @./template/unmatch.json
echo -e "\n"
sleep 1
echo "####导入ES_label模板####"
curl -k -u elastic:${ES_PASSWD} -XPUT https://${ip}:9200/_template/label -H 'content-Type:application/json' -d @./template/ES_label.json
echo -e "\n"
echo "####导入offline_merge_alarm.json模板####"
curl -k -u elastic:${ES_PASSWD} -XPUT https://${ip}:9200/_template/offline_merge_alarm -H 'content-Type:application/json' -d @./template/offline_merge_alarm.json
echo -e "\n"
echo "####导入offline_incident.json模板####"
curl -k -u elastic:${ES_PASSWD} -XPUT https://${ip}:9200/_template/offline_incident -H 'content-Type:application/json' -d @./template/offline_incident.json
echo -e "\n"
echo "####导入offline_alarm.json模板####"
curl -k -u elastic:${ES_PASSWD} -XPUT https://${ip}:9200/_template/offline_alarm -H 'content-Type:application/json' -d @./template/offline_alarm.json
echo -e "\n"
sleep 1
echo "####设置分片副本####"
curl -k -u elastic:${ES_PASSWD} -XPUT https://${ip}:9200/_settings -H 'content-Type:application/json' -d @./template/replicas.json
echo -e "\n"
echo "####设置分片10000####"
curl -k -u elastic:${ES_PASSWD} -XPUT https://${ip}:9200/_cluster/settings -H 'content-Type:application/json' -d @./template/EePerNode.json
echo -e "\n"
echo "####删除默认event索引####"
if [[ ${result_event} =~ "error" ]];thenecho "默认event索引不存在"echo -e "\n"sleep 1
elsecurl -k -u elastic:${ES_PASSWD} -XDELETE https://${ip}:9200/event_${DATE}echo -e "\n"echo "默认event索引删除成功"echo -e "\n"sleep 1
fi
echo "####删除默认alarm索引####"
if [[ ${result_alarm} =~ "error" ]];thenecho "默认alarm索引不存在"echo -e "\n"sleep 1
elsecurl -k -u elastic:${ES_PASSWD} -XDELETE https://${ip}:9200/alarm_${DATE}echo -e "\n"echo "默认alarm索引删除成功"echo -e "\n" sleep 1
fi
echo "####删除默认incident索引####"
if [[ ${result_incident} =~ "error" ]];thenecho "默认incident索引不存在"echo -e "\n"sleep 1
elsecurl -k -u elastic:${ES_PASSWD} -XDELETE https://${ip}:9200/incident_${DATE3}echo -e "\n"echo "默认incident索引删除成功"echo -e "\n"sleep 1
fi
echo "####删除默认merge_alarm索引####"
if [[ ${result_merge} =~ "error" ]];thenecho "默认merge_alarm索引不存在"echo -e "\n"sleep 1
elsecurl -k -u elastic:${ES_PASSWD} -XDELETE https://${ip}:9200/merge_alarm_${DATE3}echo -e "\n"echo "默认merge_alarm索引删除成功" echo -e "\n"sleep 1
fi
echo "####删除默认operation索引####"
if [[ ${result_operation} =~ "error" ]];thenecho "默认operation索引不存在"echo -e "\n"sleep 1
elsecurl -k -u elastic:${ES_PASSWD} -XDELETE https://${ip}:9200/operation_incidentecho -e "\n"echo "默认operation索引删除成功"echo -e "\n"sleep 1
fi
echo -e "####模板导入完成####\n"
echo -e "\033[33m ###安装完成#### \033[0m\n"
View Code
{"index_patterns" : ["event*"],"settings" : { "index" : {"number_of_shards" : "1","number_of_replicas" : "0"}},"mappings" : {"_meta" : { },"_source" : { },"dynamic_templates": [{"strings": {"mapping": {"type": "keyword"},"match_mapping_type": "string"}}],"properties" : {"asset_ids": {"type": "keyword"},"dev_address": {"type": "keyword"},"dev_port": {"type": "keyword"},"label_id": {"type": "keyword"},"protocol": {"type": "keyword"},"product": {"type": "keyword"},"vendor": {"type": "keyword"},"data_source": {"type": "keyword"},"dst_address": {"type": "keyword"},"dst_port": {"type": "keyword"},"event_id": {"type": "keyword"},"event_name": {"type": "keyword"},"equipment": {"type": "keyword"},"event_type": {"type": "keyword"},"event_type_name": {"type": "keyword"},"input_id": {"type": "long"},"log_id": {"type": "keyword"},"occur_time": {"type": "date"},"opt_time": {"type": "keyword"},"original_log": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"out_index_or_topic": {"type": "keyword"},"parse_filter_name": {"type": "keyword"},"parse_filter_ruleid": {"type": "keyword"},"receive_time": {"type": "date"},"src_address": {"type": "keyword"},"src_port": {"type": "keyword"},"syslog_facility": {"type": "long"},"syslog_level": {"type": "long"},"level": {"type": "keyword"},"dev_name": {"type": "keyword"},"threat_category": {"type": "keyword"},"classify": {"type": "keyword"},"log_source": {"type": "keyword"},"rule_tags": {"type": "keyword"},"dept_id": {"type": "long"},"packet_data": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"potential_impact": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"rsp_body": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"rsp_header": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"referer": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"user_agent": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"info_content": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"req_arg": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"req_body": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"req_header": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"req_info": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"bulletin": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"operation_command": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}},"threat_advice": {"type": "text","fields": {"keyword": {"type": "keyword","ignore_above": 256}}}}},"aliases" : { }
}
event.json

    event.json定义了新创建以event开头的索引的所有列的属性,这样在创建索引后写入数据的时候就不会用默认的所有的列都是keyword类型

     

    不需要每个索引都单独设置一个mapping了

 

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.hqwc.cn/news/707912.html

如若内容造成侵权/违法违规/事实不符,请联系编程知识网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

智慧园区可视化大屏设计

首先,让我们来了解一下什么是智慧园区可视化大屏。简单来说,它是一种将复杂的数据通过图形化的方式展示出来的技术。这种技术的出现,让我们可以更直观、更清晰地理解数据,从而做出更准确的决策。那么,为什么我们要讨论智慧园区可视化大屏设计呢?因为,它不仅仅是一种技术…

【Modbus】转发:Modbus通讯模拟仿真环境的搭建

文章目录一、概要二、所需工具介绍三、搭建虚拟仿真环境1.Modbus RTU虚拟仿真环境搭建1.1.虚拟串口工具(VSPD)使用1.2.虚拟从站工具(ModSim32)使用1.3.虚拟主站工具(Modscan32)使用1.4.更改虚拟从站工具(ModSim32)的Modbus寄存器的值1.5.更改虚拟主站工具(Modscan32)…

深度学习项目-MobileNetV2水果识别模型

本项目旨在研究利用深度学习模型进行水果图像分类的方法,具体包括两个主要任务:一是使用卷积神经网络(CNN)模型进行水果图片的分类,二是探索轻量级神经网络模型MobileNetV2在水果图像分类中的应用。FruitRecognition DeepLearning深度学习小项目,利用CNN和MobileNetV2搭建…

celery异步框架

celery 介绍 https://github.com/celery/celery/ https://docs.celeryq.dev/en/stable/celery是一个分布式异步任务框架,是一个灵活且可靠的,处理大量消息的分布式系统,可以在多个节点之间处理某个任务,是一个专注于实时处理的任务队列,支持任务调度,所以 celery 本质上是…

北航研究生算法期末复习整理

算法设计与分析 数据结构 二叉树 线索二叉树(Threaded Binary Tree) 利用二叉链表中空的指针域指出结点在某种遍历序列中的直接前驱或直接后继 指向前驱和后继的指针称为线索 实现不用栈的树深度优先遍历算法 二叉查找树(Binary Search Tree, BST) 左子树都更小,右子树都更大…

让你的电脑准时“打个盹”:Win10定时休眠

哈喽,大家好,我是木头左!一、Windows 10任务计划程序 在快节奏的工作生活中,常常需要让电脑在特定时间执行某些任务,而Windows 10的任务计划程序就是为此而生的神器。它不仅可以自动更新系统、备份文件,甚至还能帮你管理休息时间。想象一下,工作到深夜,电脑突然自己进入…

说说JavaScript中的事件模型

一、事件与事件流 javascript中的事件,可以理解就是在HTML文档或者浏览器中发生的一种交互操作,使得网页具备互动性, 常见的有加载事件、鼠标事件、自定义事件等 由于DOM是一个树结构,如果在父子节点绑定事件时候,当触发子节点的时候,就存在一个顺序问题,这就涉及到了事…

数据库系统概念 B+树 学习笔记

因为画图所以是纸质的,在这留个档本文来自博客园,作者:lei_yu,转载请注明原文链接:https://www.cnblogs.com/lytql/p/18198419

完整的牛津3000词汇表及牛津5000词汇表

Oxford 3000(牛津3000词)列出了每个英语学习者需要掌握的3000个核心词汇。根据牛津英语语料库中的频率和与英语学习者的相关性进行选择;涵盖CEFR等级A1-B2学习者需要掌握的总单词的75%左右;每个单词都与CEFR等级对标,指导学习者明确所处等级应该掌握的单词;权威专家指导—…

Redis 的安装与配置详解【Redis系列一】

本文介绍了什么是 Redis,安装,以及详细的配置项的介绍。〇、前言 关于 Redis 在日常开发中还是用的比较多的,特别是在秒杀、消息队列、排行榜等数据交互时效要求较高的场景,Redis 都可以轻松应对。 本文将针对 Redis 进行简单介绍,以及如何安装,并罗列下全部配置项。后续…

【土地效能大探秘】低效利用土地如何认定?

在快速推进的城市化进程中,土地资源的有效利用成为了关乎经济可持续发展的关键议题。今天,我们就来深入探讨一个核心问题:低效利用土地是如何被认定的?这不仅关系到土地资源的优化配置,也是提升城市发展质量的关键一环。低效利用土地的定义首先,我们需要明确“低效利用土…