elasticsearch迁移--利用腾讯云cos和nfs

一、在公有云服务器上备份ES

1、创建备份repo

curl -uelastic:'ES&ceshi720' -XPUT "http://172.30.0.17:9200/_snapshot/my_cos_backup" -d '{"type": "cos","setti,"access_key_secret": "Secret","bucket": "estest","region": "ap-guangzhou","compress": true,"chunk_size": "500mb","base_path": "/"}}' -H'Content-Type: application/json'

2、执行snapshot备份

curl -uelastic:'123' -XPUT "http://172.30.0.17:9200/_snapshot/my_cos_backup/snapshot_1?wait_for_completion=true"

=================================

二、在腾讯云服务器上做快照

3、在ES节点1上,到COS上下载所有备份

安装coscmd

yum install python-pip -y

pip install coscmd

 

配置coscmd初始参数

coscmd config -a accesskeyid -s Secret -b estest -r ap-guangzhou

 

配置coscmd优化参数

vim /root/.cos.conf

[common]

secret_id = accesskeyid

secret_key = Secret

bucket = estest-1300672061

region = ap-guangzhou

max_thread = 20

part_size = 1

schema = http

verify = md5

anonymous = False

 

coscmd将整个存储桶拖回本地,临时存放在一个目录

coscmd download -r / /data/esback

4、修改所有本地ES配置

mkdir -p /data/essnapshot

chown -R elasticsearch:elasticsearch /data/essnapshot

vim config/elasticsearch.yml

增加一行

path.repo: ["/data/essnapshot"]

重启ES服务

 

5、在ES节点1上安装NFS服务

 

yum install nfs* rpcbind -y

 

vim /etc/exports

 

添加一行:

 

/data/essnapshot *(rw,no_root_squash,no_all_squash,sync)

 

重启服务

 

exportfs -r

 

service rpcbind restart

 

service nfs restart

 

6、在ES节点23及其他节点上挂载NFS

showmount -e x.x.x.x查看是否正常释放挂载点

接下来开始挂载

mkdir -p /data/essnapshot

chown -R elasticsearch:elasticsearch /data/essnapshot

mount -t nfs 10.0.1.111:/data/essnapshot /data/essnapshot1 -o proto=tcp -o nolock

确保所有节点都能看到/data/essnapshot里的文件

 

 

7、在其中一台ES上执行命令,创建备份repo

 

curl -XPUT 'http://10.0.0.7:9200/_snapshot/my_backup' -d '{"type":"fs","settings":{"location":"/data/essnapshot","compress":"true"}}' -H'Content-Type: application/json'

 

8、将文件移动到snapshot目录

 

mv /data/esback/* /data/essnapshot

 

9restore

curl -XPOST 'http://10.0.0.7:9200/_snapshot/my_backup/snapshot_1/_restore?wait_for_completion=true'

 

posted @ 2020-03-12 14:49  littlevigra  阅读(513)  评论(1编辑  收藏  举报