日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

ES:记录curator+nfs进行索引备份、创建快照的一次实践

發(fā)布時(shí)間:2023/12/10 编程问答 29 豆豆
生活随笔 收集整理的這篇文章主要介紹了 ES:记录curator+nfs进行索引备份、创建快照的一次实践 小編覺得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.

1. 安裝curator工具

下面是我離線安裝的過程
https://blog.csdn.net/weixin_43736084/article/details/121775484?spm=1001.2014.3001.5501

2.使用fs建立es存儲(chǔ)庫

我們使用NFS,下面是官網(wǎng)給出的幾種倉庫類型

2.1 fs建立存儲(chǔ)庫的注意事項(xiàng)

注意事項(xiàng),要不然后面創(chuàng)建倉庫會(huì)失敗:

  • 各臺(tái)機(jī)器之間使用的用戶的uid和gid必須一樣(啟動(dòng)es的用戶),我這里uid=1000 gid=1003,不一樣需要進(jìn)行修改
  • 查看:

    # 各臺(tái)機(jī)器都是一樣的1000和1003 [root@localhost yuantek]# id es uid=1000(es) gid=1003(xyc) groups=1003(xyc)

    修改:

    usermod -u 1000 es groupmod -g 1003 es

    2.2 NFS建立共享文件夾

    在某一臺(tái)節(jié)點(diǎn)上創(chuàng)建目錄, 注:快照數(shù)據(jù)會(huì)全部寫入到當(dāng)前節(jié)點(diǎn)的當(dāng)前目錄下,并不是分布式的,注意磁盤空間

    # 來查看下所要備份的索引的大小,我這里1.1T的大小 GET /_cat/indices?v green open xxxx RGagjw1FSnSB5Y38kV-JaF 12 1 154756020 34013577 1.1tb 567.3gb
  • 創(chuàng)建目錄
  • [root@localhost ~]# mkdir /chun/snapshot -R es:es如果已經(jīng)創(chuàng)建了好了,就修改權(quán)限 [root@localhost ~]# chown es:es /chun/snapshot
  • 編輯 nfs 配置文件
  • [root@localhost /]# cat /etc/exports /chun/snapshot *(insecure,rw,sync,no_root_squash,anonuid=1000,anongid=1003)
  • 查看共享目錄和狀態(tài)
  • [root@localhost /]# exportfs -rv exporting *:/chun/snapshot

    4.其他節(jié)點(diǎn)掛在共享目錄:(在其他節(jié)點(diǎn)上執(zhí)行)

    (192.168.2.132,192.168.2.133上分別執(zhí)行)[root@localhost ~]# mount -t nfs 192.168.2.131:/chun/snapshot /chun/snapshot

    5.開機(jī)掛載(因?yàn)殚_機(jī)后失效)

    開機(jī)掛載NFS目錄(在其他節(jié)點(diǎn)上執(zhí)行)#編輯fstab文件 [root@localhost ~]# cat /etc/fstab |grep nfs 192.168.2.131:/chun/snapshot /chun/snapshot nfs defaults,_netdev 0 0

    2.3 修改ES配置文件,每臺(tái)節(jié)點(diǎn)都加入

    添加存儲(chǔ)庫路徑,添加: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.最好是一臺(tái)一臺(tái)重啟,防止es重新索引時(shí)間過長,導(dǎo)致集群長時(shí)間red
    2.關(guān)閉分片

    PUT /_cluster/settings {"transient": {"cluster.routing.allocation.enable":"none"} }

    3.kill掉es進(jìn)程

    jps -l |grep Elastic |awk '{print $1}' |xargs kill -9

    4.重啟es

    su es;./elasticsearch -d

    5.開啟分片

    PUT /_cluster/settings {"transient": {"cluster.routing.allocation.enable":"all"} }

    6.等待集群green后,重復(fù)上述步驟,重啟其他節(jié)點(diǎn),master最后再重啟就行

    3.4 創(chuàng)建快照庫

    location如果是相對路徑就是在path.repo配置的目錄下創(chuàng)建快照庫文件
    如果是絕對路徑父目錄也要是path.repo,/chun/snapshot/chun_backup

    PUT /_snapshot/chun_backup {"type": "fs","settings": {"location": "chun_backup","compress": true} } 參數(shù)介紹,根據(jù)實(shí)際情況選擇,默認(rèn)速率是20MB {"type": "fs", #共享文件夾"settings": {"location": "chun_backup", #存儲(chǔ)庫位置"max_restore_bytes_per_sec":"10mb", #恢復(fù)最大速率"compress":"true", #是否壓縮"max_snapshot_bytes_per_sec":"10mb", #創(chuàng)建最大速率"chunk_size":"100mb" #壓縮塊大小 }

    查看快照庫
    POST /_snapshot/chun_backup/_verify

    3.5 curator備份索引

    工具安裝在最上面
    文件如何寫參照官網(wǎng)配置,下面是我實(shí)際使用的:

    創(chuàng)建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#日志路經(jīng)logfile: /chun/curator-5.8.4/log/run.loglogformat: defaultblacklist: ['elasticsearch', 'urllib3']

    創(chuàng)建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'

    執(zhí)行:

    命令: curator --config config.yml action.yml**最好在后臺(tái)執(zhí)行,防止備份時(shí)間長想要關(guān)閉終端導(dǎo)致失敗,使用screen建立一個(gè)后臺(tái)終端 [root@localhost ~]# screen -S esbak執(zhí)行備份命令 [root@localhost curator-5.8.4]# curator --config curator.yml action.yml退出此終端 按快捷鍵 ctrl + a + d查看創(chuàng)建的screen終端 [root@localhost ~]# screen -ls There is a screen on:37910.esbak (Detached) 1 Socket in /var/run/screen/S-root.重新進(jìn)入 [root@localhost ~]# screen -r esbak

    至此整個(gè)備份過程就結(jié)束了。

    總結(jié)

    以上是生活随笔為你收集整理的ES:记录curator+nfs进行索引备份、创建快照的一次实践的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

    如果覺得生活随笔網(wǎng)站內(nèi)容還不錯(cuò),歡迎將生活随笔推薦給好友。