目录
一、使用NFS作为存储仓库
这边测试使用一台机器 源ES:一个ES6存储 目标ES:一个ES7作为读取
1、安装nfs
yum install nfs-utils -y
systemctl start nfs-utils
systemctl enable nfs-utils
systemctl start nfs
systemctl enable nfs
2、添加es的repo存放地址
需要在2个es里面都修改:在elasticsearch.yml中添加配置
data.repo: /opt/my_repo_floder
3、对nfs进行配置
vim /etc/exports
/opt/my_repo_floder *(rw,sync,no_root_squash)
# *表示允许任意用户使用,也可以使用具体的ip,如本机可用192.168.1.168,
# 括号中rw代表可读写,
# ro只读的权限
# sync资料同步写入内存与硬盘中,
# async资料会先写入内存,而非直接写入硬盘中,
# no_root_suqash意思是以root权限访问该共享文件夹
重启nfs
systemctl restart nfs
4、添加NFS挂载
mount 192.168.204.128:/opt/my_repo_floder /opt/my_repo_floder
5、重启2个es服务
二、创建快照仓库
需要在2个es里面都创建
PUT _snapshot/my_repo
{
"type": "fs",
"settings": {
"location": "/opt/my_repo_floder",
"compress": true, #是否压缩
"max_restore_bytes_per_sec": "50mb", #快照恢复的速度,默认20mb/s
"max_snapshot_bytes_per_sec": "50mb" #制作快照的速度,默认20mb/s
}
}
三、生成快照数据
在源es中创建快照
这边以metricbeat数据为例
PUT _snapshot/my_repo/test_metricbeat
{
"indices": "metric*",
"ignore_unavailable": true, #支持多个索引语法的 indices 参数来指定,快照请求也支持 ignore_unavailable 选项,该选项设置为 true 时,在创建快照时会忽略不存在的索引
"include_global_state": true #防止集群的全局状态被作为快照的一部分存储起来
}
四、在目标es中生成数据
POST _snapshot/my_repo/test_metricbeat/_restore
{
"indices": "metric*",
"ignore_unavailable": true,
"include_global_state": false
}
五、验证数据查询
1、ES6中验证
GET /metric*/_search
{
"query": {
"match_all": {}
}
}
2、ES7验证数据
GET /metric*/_search
{
"query": {
"match_all": {}
}
}
tip:
es7中查询数据量超过1万的数据total总返回10000,如需正常显示总数需要添加一个参数
GET /metric*/_search
{
"query": {
"match_all": {}
},
"track_total_hits":true
}
3、结论
数据115929条全部迁移成功,总条数显示方式与ES6有所不同
六、与ES6的不同
es6显示的总数为hits.total
es7显示的总数为hits.total.value
其中hits.total.relation
为value的条件比值