搭建Elasticsearch快照环境备忘录
首先
作为备忘录,记录Elasticsearch快照环境建设的笔记。
环境
-
- OS: CentOS6
- Elasticsearch: 2.3.3
建立
1.NFS服务器设置(192.168.1.1)
创建目标存储库目录用于挂载。
$ mkdir -p /mount/snapshot
$ chown -R elasticsearch:elasticsearch /mount/snapshot
安装挂载
$ vim /etc/exports
/mount/snapshot 192.168.1.1/32(rw,no_root_squash,sync,wdelay)
/mount/snapshot 192.168.1.2/32(rw,no_root_squash,sync,wdelay)
nfs设置已更新
$ exportfs -ra
2.NFS客户端设置(192.168.1.1、192.168.1.2)
创建用于挂载的目录
$ mkdir -p /var/lib/snapshot
$ chown -R elasticsearch:elasticsearch /var/lib/snapshot
执行“攀登技巧”
$ mount -t nfs 192.168.1.1:/mount/snapshot/ /var/lib/snapshot/
3.Elasticsearch配置(192.168.1.1、192.168.1.2)
修改配置文件
$ vim /etc/elasticsearch/elasticsearch.yml
path.repo: ["/var/lib/snapshot"]
重新启动Elasticsearch
$ service elasticsearch restart
4. 存储库注册(192.168.1.1)
$ curl -XPUT 'http://localhost:9200/_snapshot/my_repo?pretty=true' -d '{
"type" : "fs",
"settings" : {
"location" : "/var/lib/snapshot/my_repo",
"compress" : true
}
}'
在这里卡住的关键点。
在注册存储库时,出现了以下错误,导致注册存储库失败。
$ curl -XPUT 'http://localhost:9200/_snapshot/my_repo?pretty=true' -d '{
"type" : "fs",
"settings" : {
"location" : "/var/lib/snapshot/my_repo",
"compress" : true
}
}'
{
"error" : {
"root_cause" : [ {
"type" : "repository_verification_exception",
"reason" : "[my_repo] [1234567890abcdefghijkl, 'RemoteTransportException[[May Parker][192.168.1.2:9300][internal:admin/repository/verify]]; nested: RepositoryVerificationException[[my_repo] store location [/var/lib/snapshot/my_repo] is not accessible on the node [{May Parker}{1234567890abcdefghijkl}{192.168.1.2}{192.168.1.2:9300}]]; nested: NotSerializableExceptionWrapper[access_denied_exception: /var/lib/snapshot/my_repo/tests-0987654321zyxwvutsrqpo/data-1234567890abcdefghijkl.dat];']]"
} ],
"type" : "repository_verification_exception",
"reason" : "[my_repo] [1234567890abcdefghijkl, 'RemoteTransportException[[May Parker][192.168.1.2:9300][internal:admin/repository/verify]]; nested: RepositoryVerificationException[[my_repo] store location [/var/lib/snapshot/my_repo] is not accessible on the node [{May Parker}{1234567890abcdefghijkl}{192.168.1.2}{192.168.1.2:9300}]]; nested: NotSerializableExceptionWrapper[access_denied_exception: /var/lib/snapshot/my_repo/tests-0987654321zyxwvutsrqpo/data-1234567890abcdefghijkl.dat];']]"
},
"status" : 500
}
如果每个节点的elasticsearch用户的userid或groupid不统一,则会发生这种情况。
#192.168.1.1
$ cat /etc/passwd | grep elasticsearch
elasticsearch:x:487:486:elasticsearch user:/home/elasticsearch:/sbin/nologin
#192.168.1.2
$ cat /etc/passwd | grep elasticsearch
elasticsearch:x:493:493:elasticsearch user:/home/elasticsearch:/bin/bash
为了避免冲突,统一每个节点的elasticsearch用户的userid和groupid。
请用192.168.1.2进行操作。
# いったんelasticsearchを停止
$ service elasticsearch stop
# elasticsearchユーザのuseridとgroupidを#1の環境と合わせる
$ usermod -u 487 elasticsearch
$ groupmod -g 486 elasticsearch
# 関連ファイルの所有者情報を最新化する
$ find / -group 493 -exec chgrp -h elasticsearch {} \;
$ find / -user 493 -exec chown -h elasticsearch {} \;
# elasticsearchを起動
$ service elasticsearch start
五、获取快照(192.168.1.1)
$ curl -XPUT 'http://192.168.1.1:9200/_snapshot/my_repo/my_ss-2019.12.25?wait_for_completion=true' -d '{
"indices": "*",
"ignore_unavailable": true,
"include_global_state": false
}'