[elk]elasticsearch dashboard+保留10天内索引+导入导出备份

es dashboard

有两款

先修改es的配置文件: elasticsearch.yml追加
http.cors.enabled: true
http.cors.allow-origin: "*"

docker run -d -v /etc/localtime:/etc/localtime --restart=always -p 9100:9100 mobz/elasticsearch-head:5

docker run  -d     --net=host     --restart=always     -v /etc/localtime:/etc/localtime:ro     -v /root/elasticsearch-HQ/royrusso-elasticsearch-HQ-eb117d4:/usr/share/nginx/html     --name nginx 

es数据保留10天以内

#!/bin/bash

###################################
#删除早于十天的ES集群的索引
###################################
function delete_indices() {
    comp_date=`date -d "10 day ago" +"%Y-%m-%d"`
    date1="$1 00:00:00"
    date2="$comp_date 00:00:00"

    t1=`date -d "$date1" +%s`
    t2=`date -d "$date2" +%s`

    if [ $t1 -le $t2 ]; then
        echo "$1时间早于$comp_date,进行索引删除"
        #转换一下格式,将类似2017-10-01格式转化为2017.10.01
        format_date=`echo $1| sed ‘s/-/\./g‘`
        curl -XDELETE http://192.168.x.x:9200/*$format_date
    fi
}

curl -XGET http://192.168.x.x:9200/_cat/indices | awk -F" " ‘{print $3}‘ | awk -F"-" ‘{print $NF}‘ | egrep "[0-9]*\.[0-9]*\.[0-9]*" | sort | uniq  | sed ‘s/\./-/g‘ | while read LINE
do
    #调用索引删除函数
    delete_indices $LINE
done

es数据备份: elasticsearch-dump

https://github.com/taskrabbit/elasticsearch-dump

  • 安装
npm install elasticdump
./bin/elasticdump
  • 使用
支持导出文件
支持导出文件压缩
支持导出后直接导入到另一个stage escluster
elasticdump --help
# Backup index data to a file:
elasticdump   --input=http://production.es.com:9200/my_index   --output=/data/my_index_mapping.json   --type=mapping
elasticdump   --input=http://production.es.com:9200/my_index   --output=/data/my_index.json   --type=data

# Backup and index to a gzip using stdout:
elasticdump   --input=http://production.es.com:9200/my_index   --output=$   | gzip > /data/my_index.json.gz

# Backup the results of a query to a file
elasticdump   --input=http://production.es.com:9200/my_index   --output=query.json   --searchBody ‘{"query":{"term":{"username": "admin"}}}‘

1g的日志不到四五分钟就导完毕: 从一个集群到另一个集群

时间: 2024-08-02 23:18:08

[elk]elasticsearch dashboard+保留10天内索引+导入导出备份的相关文章

ELK学习总结(4-1)elasticsearch更改mapping(不停服务重建索引)

elasticsearch更改mapping(不停服务重建索引)原文 http://donlianli.iteye.com/blog/1924721Elasticsearch的mapping一旦创建,只能增加字段,而不能修改已经mapping的字段.但现实往往并非如此啊,有时增加一个字段,就好像打了一个补丁,一个可以,但是越补越多,最后自己都觉得惨不忍睹了.怎么办??这里有一个方法修改mapping,那就是重新建立一个index,然后创建一个新的mapping.你可能会问,这要是在生产环境,可行

ELK(elasticsearch+logstash+kibana)开源日志分析平台搭建

环境介绍 System:   CentOS7.2 x86_64 hostname: elk-server.huangming.org IP Address: 10.0.6.42.10.17.83.42 本篇的ELK环境为单机部署方式,即将ELK所有的软件包都安装在一台服务器上,配置如下: CPU:   4c Mem:   8G Disk:  50 一.Elasticsearch安装 1.安装jdk 1.8及以上的版本(安装过程略) [[email protected] elk]# java -v

elasticsearch 索引数据快照备份和恢复

最近线上的ES集群埋点数据量暴涨,机器的内存磁盘空间眼看就要炸了.但这部分数据又是冷数据,现时不需要查询,但又不能直接delete,需保留日后数据分析.由于前期急于上线,业务代码没有合理分配索引按月切割,全年数据丢进单个索引,导致单索引数据暴涨到100G+为解决磁盘空间的瓶颈,针对不常用的分片数据,做快照冷存储.应用场景:三节点的ES集群:192.168.85.39 ,192.168.85.36,192.168.85.33 找一台有磁盘空间的服务器,搭建NFS,用于共享目录挂载.已192.168

Elasticsearch系列---实战零停机重建索引

前言 我们使用Elasticsearch索引文档时,最理想的情况是文档JSON结构是确定的,数据源源不断地灌进来即可,但实际情况中,没人能够阻拦需求的变更,在项目的某个版本,可能会对原有的文档结构造成冲击,增加新的字段还好,如果要修改原有的字段,只能重建索引了. 概要 本篇以实战方式讲解如何零停机完成索引重建的三种方案. 外部数据导入方案 整体介绍 系统架构设计中,有关系型数据库用来存储数据,Elasticsearch在系统架构里起到查询加速的作用,如果遇到索引重建的操作,待系统模块发布新版本后

shell脚本精华----在10秒内SSH登录失败次数超过3次就使用iptables/tcpwrappers拒绝

#!/bin/bash while true do badip=$(lastb -i -a | awk '/ssh:notty/ {print $NF}'|sort|uniq -c|awk '($1>3) {print $2}') for i in $badip do iptables -t filter -I INPUT -s $i -p tcp --dport 22 -j DROP done : > /var/log/btmp sleep 10s done shell脚本精华----在10

老笔记整理五:C实现10阶内通过展开代数余子式求行列式的值

这个分为两部分,先是写出了C实现计算三阶行列式,然后过了一段时间突然有了思路才写下了10阶内这段代码.真怀念那段写代码的日子. 一:C实现计算三阶行列式 最近高数课在上线性代数,二阶的还能口算,三阶的有点麻烦,想陆陆续续地把公式都用C来实现.因为二阶的行列式如果用C来写就是一句话:val=det[0][0]*det[1][1]-det[0][1]*det[1][0];太简单了这里就不写了,主要写关于三阶的.只要把这个三阶行列式里每一个元素打进去就能算出值来了.过两天再写余子式的展开. 1 #in

Hadoop-1.2.1伪分布下 hive-0.10.0内嵌模式安装

Hadoop-1.2.1伪分布下 hive-0.10.0内嵌模式安装 1.下载hive-0.10.0 网址是:http://archive.apache.org/dist/hive/hive-0.10.0/   下载的安装包为:hive-0.10.0.tar.gz   2012-12-18 23:21  35M  2.把hive-0.10.0拷进 /usr/ 目录下,并进行解压 tar  –zxvf hive-0.10.0.tar.gz 解压完毕如下图: 3.修改文件名.修改hive文件权限.删

PostgreSQL 10数据类型与索引

PostgreSQL 10常用的索引类型有btree,hash,gin,gist,spgist,brin六种,btree和hash是最长用的,基本所有数据类型都支持,以下对gin,gist,spgist,brin索引支持的数据类型总结如下: 原文地址:http://blog.51cto.com/tongcheng/2321912

使用python求10万内的所有素数的个数

#求10万内的所有素数(9592) print(2) count = 1 for i in range(3,100000): for j in range(2,i): if i%j ==0: break if j==i-1: print(i) 优化: count = 1 for i in range(3,100000,2):#跳过所有偶数 for j in range(2,i): if i%j ==0: break if j==i-1: count +=1 print(count) 再优化: c