简体   繁体   English

lsyncd 中的动态排除列表

[英]Dynamic exclusion list in lsyncd

Our cloud platform is powered by opennebula.我们的云平台由 opennebula 提供支持。 So we have two instances of the frontend in "cold swap".所以我们在“冷交换”中有两个前端实例。 We use lsyncd daemon trying to keep instances in datastores synced, but there are some points: we don't want to sync VM's images that have an extension .bak cause of the other script moves all the .bak to other storage on schedule.我们使用 lsyncd 守护进程尝试保持数据存储中的实例同步,但有几点:我们不想同步具有扩展名.bak的 VM 映像,因为其他脚本会按计划将所有.bak移动到其他存储。 The sync script logic looks like find all the.bak in /var/lib/one/datastores/ then create exclude.lst and then start lsyncd.同步脚本逻辑看起来像是find all the.bak in /var/lib/one/datastores/ then create exclude.lst and then start lsyncd. Seems OK until we take a look at the datastores:在我们查看数据存储之前似乎没问题:

oneadmin@nola:~/cluster$ dir /var/lib/one/datastores/1/
006e099c57061d87d4b8f78ec7199221
008a10fa0764c9ac8d6fb9206c9b69bd
069299977f2fea243a837efed271182f
0a73a9adf74d92b4f175abcb578cabac
0b1cc002e370e1acd880cf781df0a6fb
0b470b182ac6d554774a3615ce87e292
0c0d98d1e0aabc23ef548ddb564c578d
0c3fad9c92a8efc7e13a73d8ae85caa3

..and so on. ..等等。

We solved it with this monstrous function:我们用这个可怕的 function 解决了它:

function create_exclude {
  oneimage list -x | \
    xmlstarlet sel -t -m "IMAGE_POOL/IMAGE" -v "ID" -o ";" -v "NAME" -o ";" -v "SOURCE" -o ":" | \
    sed s/:/'\n'/g | \
    awk -F";" '/.bak;\/var\/lib/  {print $3}' | \
    cut -d / -f8 > /var/lib/one/cluster/exclude.lst
}

The result is the list which contains VM IDs with .bak images inside so we can exclude the whole VM folder from syncing.结果是包含带有.bak图像的 VM ID 的列表,因此我们可以将整个 VM 文件夹排除在同步之外。 That's not kinda what we wanted, as the original image stays not synced.这不是我们想要的,因为原始图像保持不同步。 But it could be solved by restart the lsyncd script at the moment when other script moves all the .bak to other storage.但可以通过在其他脚本将所有.bak移动到其他存储时重新启动 lsyncd 脚本来解决。

Now we get to the topic of the question.现在我们进入问题的主题。

It works until a new .bak will created.它一直有效,直到创建一个新的.bak No way to add new string in exclude.lst "on the go" but to stop lsync and restart script which re-creates exclude.lst.没有办法在 exclude.lst “on the go”中添加新字符串,而是停止 lsync 并重新启动重新创建 exclude.lst 的脚本。 But there is also no possibility to check the moment of creation a new.bak except another script that will monitor it in some period.但是也没有可能检查创建 new.bak 的时刻,除非另一个脚本会在一段时间内对其进行监控。

I believe that less complicated solution exists.我相信存在不太复杂的解决方案。 It depends on opennebula of course, particularly in the way of the /datastores/ folder stores VMs.当然,这取决于 opennebula,尤其是 /datastores/ 文件夹存储 VM 的方式。

Glad to know you are using OpenNebula to run your cloud:) Have you tried to use our Community Forum for support?很高兴知道您正在使用 OpenNebula 来运行您的云:) 您是否尝试使用我们的社区论坛寻求支持? I'm sure the rest of the Community will be happy to give a hand!我相信社区的 rest 将很乐意提供帮助!

Cheers!干杯!

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM