点击上方“IT那活儿”公众号,关注后了解更多内容,不管IT什么活儿,干就完了!!!
单索引跨集群迁移:_reindex方式



jps|grep -i elasticsearch|awk '{print $1}'|xargs kill –-停止新ES集群各节点
./elasticsearch -d --启动新ES集群各节点

curl -u xxx.x.xxx.65:9201/_template/template_ shsnc-crm_tpt_tj* >> template.txt

curl -H "Content-Type: application/json"
-XPUT http://xxx.x.XXX.214:9201/_template/template_shsnc-
crm_tpt_tj_dtfjzl_data -d'{"order": 0, "index_patterns":
["shsnc-crm_tpt_tj_dtfjzl_data"], "settings": {"index":
{"number_of_shards": "1", "number_of_replicas": "0"}},
"mappings": {"_doc":{"dynamic": false, "properties":
{"appname": {"ignore_above": 10000, "type": "keyword"},
"createTime": {"format": "yyyy-MM-dd HH:mm:ss.SSS", "type": "date"}, "raw_message": {"analyzer": "ik_smart", "type":
"text"}, "startLine": {"ignore_above": 10000, "type":
"keyword"}, "op_time": {"format": "yyyy-MM-dd HH:mm:ss", "type": "date"}, "COUNT": {"ignore_above": 10000, "type":
"keyword"}, "cmdb_id": {"ignore_above": 10000, "type":
"keyword"}, "agentip": {"ignore_above": 10000, "type":
"keyword"}}}}, "aliases": {}}'


5. 从源ES集群中reindex数据到新ES集群
curl -H 'Content-Type: application/json'
-XPOST "http://xxx.x.xxx.214:9201/_reindex?pretty" -d '{
"source": {
"remote": {"host": "http://xxx.x.xxx.65:9201"},
"username": "xxxxxx", --username、password若有则指定,若无则去掉此项
"password": "xxxxxx",
"index": "shsnc-crm_tpt_tj_dtfjzl_data",
"type": "_doc"},
"dest": {"index": "shsnc-crm_tpt_tj_dtfjzl_data"}}'



全部索引跨集群迁移:_snapshot方式



curl -H 'Content-Type: application/json'
-XPUT http://xxx.x.xxx.65:9201/_snapshot/my_backup -d '{
"type": "fs",
"settings": {
"location": "/home/elk/es-repo-test",
"compress": true,
"max_snapshot_bytes_per_sec":"20mb",
"max_restore_bytes_per_sec":"20mb"}}'

注:
max_snapshot_bytes_per_se:快照数据进入仓库时,限流每秒20mb; max_restore_bytes_per_sec:从仓库恢复数据时,限流每秒20mb。
Curl -H 'Content-Type: application/json' -XPUT
http://xxx.x.xxx.65:9201/_snapshot/my_backup/es-snapshot-1?wait_for_completion=true




curl -H 'Content-Type: application/json'
-XPUT http://xxx.x.xxx.20:9201/_snapshot/my_backup -d '{
"type": "fs",
"settings": {
"location": "/home/elk/es-repo-test",
"compress": true,
"max_snapshot_bytes_per_sec":"20mb",
"max_restore_bytes_per_sec":"20mb"}}'



curl -XPOST http://xxx.x.xxx.20:9201/_snapshot/my_backup/es-snapshot-1/_restore







本文作者:方 威(上海新炬中北团队)
本文来源:“IT那活儿”公众号

文章转载自IT那活儿,如果涉嫌侵权,请发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。




