ElasticSearch查看删除关闭索引
curl -XDELETE 'http://10.1.2.2:9200/iis_log_2019-07' #删除名为/iis_log_2019-07的索引
curl -XPOST 'http://10.1.2.2:9200/iis_log_2019-07/_close/' #关闭名为/iis_log_2019-07的索引(_open打开)
curl 10.1.2.2:9200/_cat/indices/iis_log* #查看iis_log开头的所有索引
curl 10.1.2.2:9200/_cat/indices/iis_log_2018-07' #查看iis_log_2018-07的索引
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import datetime,os
from dateutil.relativedelta import relativedelta #关闭前第3个月的索引
def index_close(indexname,hmonths):
dt_m = (datetime.date.today() - relativedelta(months=hmonths)).strftime('%Y-%m')
iname = '%s_%s' % (indexname,dt_m)
url = 'http://10.1.2.2:9200/%s/_close/' % iname
print(url)
m = os.popen('curl -XPOST %s' % url)
print(m.readlines()) # index_close('iis_logl',3) #删除前第12个月的索引
def index_delete(indexname,hmonths):
dt_m = (datetime.date.today() - relativedelta(months=hmonths)).strftime('%Y-%m')
iname = '%s_%s' % (indexname,dt_m)
url = 'http://10.1.2.2:9200/%s' % iname
print(url)
m = os.popen('curl -XDELETE %s' % url)
print(m.readlines()) index_delete('iis_log',12)
#关闭前1个月的索引,索引以天为单位产生,如sec_mail_2020-04-28)
def index_close_days(indexname,nmonths):
dt_m = (datetime.date.today() - relativedelta(months=nmonths)).strftime('%Y-%m')
dt_n = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
y,m = dt_m.split('-')
days = (calendar.monthrange(int(y),int(m)))[1]
for d in range(days):
d = str(d+1).rjust(2,'')
iname = '%s_%s-%s' % (indexname,dt_m,d)
url = 'http://10.1.2.2:9200/%s/_close/' % iname
# print(url)
rs = os.popen('curl -XPOST %s' % url)
with open(logfile,'a') as fw:
fw.write('%s\n%s\n%s\n'% (dt_n,url,rs.read())) #删除前3个月的索引,索引以天为单位产生,如sec_mail_2020-04-28)
def index_delete_days(indexname,nmonths):
dt_m = (datetime.date.today() - relativedelta(months=nmonths)).strftime('%Y-%m')
dt_n = datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')
y,m = dt_m.split('-')
days = (calendar.monthrange(int(y),int(m)))[1]
for d in range(days):
d = str(d+1).rjust(2,'')
iname = '%s_%s-%s' % (indexname,dt_m,d)
url = 'http://10.1.2.2:9200/%s' % iname
# print(url)
rs = os.popen('curl -XDELETE %s' % url)
with open(logfile,'a') as fw:
fw.write('%s\n%s\n%s\n'% (dt_n,url,rs.read())) index_close_days('sec_mail',1)
index_delete_days('sec_mail',3)
ElasticSearch查看删除关闭索引的更多相关文章
- mysql中怎样查看和删除唯一索引
mysql中怎样查看和删除唯一索引. 查看唯一索引: show index from mytable;//mytable 是表名 查询结果例如以下: 查询到唯一索引后,怎样删除唯一索引呢,使用例如以下 ...
- Elasticsearch之删除索引
1. #删除指定索引 # curl -XDELETE -u elastic:changeme http://localhost:9200/acc-apply-2018.08.09 {&qu ...
- mysql索引创建&查看&删除
1.索引作用 在索引列上,除了上面提到的有序查找之外,数据库利用各种各样的快速定位技术,能够大大提高查询效率.特别是当数据量非常大,查询涉及多个表时,使用索引往往能使查询速度加快成千上万倍. 例如,有 ...
- mysql如何查看表的索引以及如何删除表的索引
mysql中如何查看和删除唯一索引. 查看唯一索引: show index from mytable;//mytable 是表名 查询结果如下: 查询到唯一索引后,如何删除唯一索引呢,使用如下命令: ...
- Elasticsearch 集群和索引健康状态及常见错误说明
之前在IDC机房线上环境部署了一套ELK日志集中分析系统, 这里简单总结下ELK中Elasticsearch健康状态相关问题, Elasticsearch的索引状态和集群状态传达着不同的意思. 一. ...
- elasticsearch系列二:索引详解(快速入门、索引管理、映射详解、索引别名)
一.快速入门 1. 查看集群的健康状况 http://localhost:9200/_cat http://localhost:9200/_cat/health?v 说明:v是用来要求在结果中返回表头 ...
- ES之四、Elasticsearch集群和索引常用命令
REST API用途 elasticsearch支持多种通讯,其中包括http请求响应服务,因此通过curl命令,可以发送http请求,并得到json返回内容. ES提供了很多全面的API,常用的RE ...
- 〈二〉ElasticSearch的认识:索引、类型、文档
目录 上节回顾 本节前言 索引index 创建索引 查看索引 查看单个索引 查看所有索引 删除索引 修改索引 修改副本分片数量 关闭索引 索引别名 增加索引别名: 查看索引别名: 删除索引别名: 补充 ...
- Elasticsearch 创建以及修改索引结构
从问题出发,这篇内容可以解决以下几个问题: 一:如何开启关闭Es索引(数据库)? 二:如何创建索引(数据库)结构? 三:如何向已有索引(数据库)中添加类型(表)结构? 四:如何向已有类型(表)中添加新 ...
随机推荐
- centos7 ntp server & samba
最近公司内部一个需求:必须 Linux建个 ntp server ,并且 Windows可以net time \\ip 访问. 想要解决问题,还得解决前置问题. 服务器不能上网,无法直接访问外部 yu ...
- E05 【餐厅】What kind of coffee or tea would you like?
核心句型 What kind of coffee or tea would you like? 你想喝什么咖啡或者茶? What would you like? 你喜欢什么?/你想要什么? ...
- github配置密钥
我们在githob创建项目后,本地使用git 克隆代码 需要在githob配置密钥,才可以 步骤: 下载git,进行安装,安装好后.点击桌面,右键,选择>>git bash 在弹出的黑框 ...
- nginx开启网站目录浏览功能
一.开启全站目录浏览功能 编辑nginx.conf, 在http下面添加以下内容: autoindex on; # 开启目录文件列表 autoindex_exact_size on; # 显示出文件的 ...
- 洛谷 P1182 数列分段 Section II
洛谷 P1182 数列分段 Section II 洛谷传送门 题目描述 对于给定的一个长度为N的正整数数列A-iA−i,现要将其分成M(M≤N)M(M≤N)段,并要求每段连续,且每段和的最大值最小. ...
- JDOJ 1162 是否闰年
1162: 是否闰年 https://neooj.com:8082/oldoj/problem.php?id=1162 题目描述 输入一个年份year,求year是否是闰年,如果是闰年输出L,否则输出 ...
- Springboot配置ssl使用https
SSL(Secure Sockets Layer 安全套接层)是为网络通信提供安全及数据完整性的一种安全协议,SSL在网络传输层对网络连接进行加密,SSL协议位于TCP/IP协议与各种应用层协议之间, ...
- 使用lombok的利弊
使用lombok的好处是:1.减少大量的模板代码,get和set方法,从代码封装维度看,将大量的模板代码进行封装,不需要其他人员来不断编写,哪怕是IDE可以生成的代码,这也是重复代码,减少重复的出现; ...
- Win10 Mactype 字体优化
1.下载安装 Mactype :http://www.mactype.net/ 2. 打开MacType Tray.exe,右键其在任务栏图标就能选择配置文件. 分享一个配置文件: [General] ...
- Python进阶-XI 常用模块之一:collections、time、random、os、sys
简要介绍一下各种集合: 列表.元组.字典.集合(含frozenset).字符串.堆栈(如手枪弹夹:先进后出).队列(如马克沁机枪的弹夹:先进先出) 1.collections 1)queue 队列介绍 ...