ES:记录curator+nfs进行索引备份、创建快照的一次实践
1. 安裝curator工具
下面是我離線安裝的過程
https://blog.csdn.net/weixin_43736084/article/details/121775484?spm=1001.2014.3001.5501
2.使用fs建立es存儲庫
我們使用NFS,下面是官網給出的幾種倉庫類型
2.1 fs建立存儲庫的注意事項
注意事項,要不然后面創建倉庫會失敗:
查看:
# 各臺機器都是一樣的1000和1003 [root@localhost yuantek]# id es uid=1000(es) gid=1003(xyc) groups=1003(xyc)修改:
usermod -u 1000 es groupmod -g 1003 es2.2 NFS建立共享文件夾
在某一臺節點上創建目錄, 注:快照數據會全部寫入到當前節點的當前目錄下,并不是分布式的,注意磁盤空間
# 來查看下所要備份的索引的大小,我這里1.1T的大小 GET /_cat/indices?v green open xxxx RGagjw1FSnSB5Y38kV-JaF 12 1 154756020 34013577 1.1tb 567.3gb4.其他節點掛在共享目錄:(在其他節點上執行)
在(192.168.2.132,192.168.2.133上分別執行)[root@localhost ~]# mount -t nfs 192.168.2.131:/chun/snapshot /chun/snapshot5.開機掛載(因為開機后失效)
開機掛載NFS目錄(在其他節點上執行)#編輯fstab文件 [root@localhost ~]# cat /etc/fstab |grep nfs 192.168.2.131:/chun/snapshot /chun/snapshot nfs defaults,_netdev 0 02.3 修改ES配置文件,每臺節點都加入
添加存儲庫路徑,添加:path.repo: ["/chun/snapshot"]
[root@localhost ~]# cat /opt/elasticsearch-6.5.1/config/elasticsearch.yml |grep path.repo path.repo: ["/chun/snapshot"]3.3 重啟ES集群,使配置生效
1.最好是一臺一臺重啟,防止es重新索引時間過長,導致集群長時間red
2.關閉分片
3.kill掉es進程
jps -l |grep Elastic |awk '{print $1}' |xargs kill -94.重啟es
su es;./elasticsearch -d5.開啟分片
PUT /_cluster/settings {"transient": {"cluster.routing.allocation.enable":"all"} }6.等待集群green后,重復上述步驟,重啟其他節點,master最后再重啟就行
3.4 創建快照庫
location如果是相對路徑就是在path.repo配置的目錄下創建快照庫文件
如果是絕對路徑父目錄也要是path.repo,/chun/snapshot/chun_backup
查看快照庫
POST /_snapshot/chun_backup/_verify
3.5 curator備份索引
工具安裝在最上面
文件如何寫參照官網配置,下面是我實際使用的:
創建curator.yml文件
--- # Remember, leave a key empty if there is no value. None will be a string, # # not a Python "NoneType" client:#es集群iphosts:- 192.68.2.131- 192.68.2.132- 192.68.2.133port: 9201url_prefix:use_ssl: Falsecertificate:client_cert:client_key:ssl_no_validate: Falseusername: elasticpassword: chunchuntimeout: 30master_only: Falselogging:loglevel: INFO#日志路經logfile: /chun/curator-5.8.4/log/run.loglogformat: defaultblacklist: ['elasticsearch', 'urllib3']創建action.yml文件
actions:1:action: snapshotdescription: >-Back up the index, and then solve the inconsistency between ES and HBase data.options:repository: chun_back# Leaving name blank will result in the default 'curator-%Y%m%d%H%M%S'name: chun_back_2021-12-09wait_for_completion: True# max_wait: 3600# wait_interval: 10ignore_unavailable: Falseinclude_global_state: Truepartial: Falseskip_repo_fs_check: Falsefilters:- filtertype: patternkind: prefixvalue: 'chun'執行:
命令: curator --config config.yml action.yml**最好在后臺執行,防止備份時間長想要關閉終端導致失敗,使用screen建立一個后臺終端 [root@localhost ~]# screen -S esbak執行備份命令 [root@localhost curator-5.8.4]# curator --config curator.yml action.yml退出此終端 按快捷鍵 ctrl + a + d查看創建的screen終端 [root@localhost ~]# screen -ls There is a screen on:37910.esbak (Detached) 1 Socket in /var/run/screen/S-root.重新進入 [root@localhost ~]# screen -r esbak至此整個備份過程就結束了。
總結
以上是生活随笔為你收集整理的ES:记录curator+nfs进行索引备份、创建快照的一次实践的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: OSG踩坑
- 下一篇: oracle更新数据没反应,ORACLE