elasticsearch-curator创建索引
1.elasticsearch-curator安装
pip命令安装,如果没有pip命令需要先安装pip命令
[root@ecs]# pip install elasticsearch-curator
可以使用==指定版本
[root@ecs]# pip install elasticsearch-curator==5.6.0
2.elasticsearch-curator创建索引
在 /usr/目录下创建目录 :curator
[root@ecs]# cd /usr
[root@ecs]# mkdir curator
在/usr/curator目录下创建文件config.yml和action.yml
config.yml内容如下:
client:
hosts:
- 127.0.0.1
port: 9200
url_prefix:
use_ssl: False
certificate:
client_cert:
client_key:
ssl_no_validate: False
http_auth:
timeout: 30
master_only: False
logging:
loglevel: INFO
logfile:
logformat: default
blacklist: ['elasticsearch', 'urllib3']
action.yml内容如下:
actions:
1:
action: create_index
description: "创建索引名为:'junan-%Y-%m-%d-%H:%M:%S'的索引"
options:
name: junan-%Y-%m-%d-%H:%M:%S #索引名称
extra_settings: #索引信息
settings:
number_of_shards: 2
number_of_replicas: 1
mappings:
student:
_routing:
required: true
properties:
name:
type: keyword
age:
type: integer
执行命令curator命令创建索引:
[root@ecs]# curator --config /usr/curator/config.yml /usr/curator/action.yml
如果需要定时创建索引,可以创建Linux定时任务命令:crontab
[root@ecs]# crontab -e
添加内容:
curator --config /usr/curator/config.yml /usr/curator/action.yml
保存退出即可定时创建索引