es dashboard
有兩款
- head 這款我一直在用
https://github.com/mobz/elasticsearch-head
先修改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
- elasticsearch-HQ這款相對好看點
https://github.com/royrusso/elasticsearch-HQ

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的日志不到四五分鍾就導完畢: 從一個集群到另一個集群

