一.为了方便查看管理es的索引,安装head插件
1.安装node
cd /usr/local/src/ wget https://npm.taobao.org/mirrors/node/latest-v4.x/node-v4.4.7-linux-x64.tar.gz
|
---|
2.下载head插件
wget https://github.com/mobz/elasticsearch-head/archive/master.zip unzip master.zip -d /usr/local/
|
---|
3.安装grunt
npm config set registry https://registry.npm.taobao.org --global npm config set disturl https://npm.taobao.org/dist --global cd /usr/local/elasticsearch-head-master/ npm install -g grunt-cli //执行后会生成node_modules文件夹 |
---|
4.修改head插件
修改es的 config/elasticsearch.yml,加两行配置
http.cors.enabled: true
http.cors.allow-origin: "*"
修改服务器监听地址:Gruntfile.js
修改连接地址:_site/app.js
5.启动head
npm install grunt server |
---|
二. es 节点级别配置
在 hot 组的节点的 elasticsearch.yml 配置文件 Node 配置段中增加
node.attr.box_type: hot
在 cold 组的节点 elasticsearch.yml 配置文件 Node 配置段中增加
node.attr.box_type: cold
三. 索引级别配置
curl -XPUT http://192.168.1.165:9200/_template/jsonlog/ -d '
{
"order": 0,
"template": "jsonlog*",
"settings": {
"index.routing.allocation.include.tag": "hot",
"index.refresh_interval": "30s",
"index.number_of_replicas": "1",
"index.number_of_shards": "1",
"index.translog.flush_threshold_ops": "30000"
}
}
'
四. 定时任务将历史索引分配到cold下面
1.安装pip
yum -y install epel-release
yum -y install python-pip
pip install elasticsearch-curator==3.5
2.定时分配老索引到cold节点下
curator allocation --rule tag=cold --type include indices --time-unit days --older-than 7 --timestring '%Y.%m.%d' --prefix jsonlog