为生产 Plone 实例自动执行 ZODB 包的建议方法是什么?

发布于 2024-10-21 18:13:06 字数 271 浏览 2 评论 0原文

查看 plone.org 以找到一种定期打包实例 ZODB 的方法,我只能找到 http://plone.org/documentation/faq/how-do-i-pack-the-zodb 没有讨论自动包,而只是手动启动的包。

我知道我可以使用 wget 或 curl 模拟手动包,但我想知道这是否是生产站点使用的最佳实践。

Looking at plone.org to find a way to periodically pack my instance's ZODB I could only find http://plone.org/documentation/faq/how-do-i-pack-the-zodb that doesn't talk about automated packs, but just manually initiated ones.

I know I can simulate the manual pack with wget or curl, but I'd like to know if that is the best practice in use for production sites.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(7

还给你自由 2024-10-28 18:13:06

如果您使用 ZEO,您可以将以下内容添加到您的 Crontab 中来执行此操作:

0 1 * * 6 <path-to-buildout>/bin/zeopack

如果您不想手动执行此操作,请将其添加到您的 buildout.cfg 中,上面的 crontab 条目将在您运行 bin/buildout 时自动添加:

parts += crontab_zeopack

# pack your ZODB each Sunday morning and hence make it smaller and faster
[crontab_zeopack]
recipe = z3c.recipe.usercrontab
times = 0 1 * * 6
command = ${buildout:directory}/bin/zeopack

If you are using ZEO you can add the following to your Crontab to do this:

0 1 * * 6 <path-to-buildout>/bin/zeopack

If you don't want to do it manually, add this to your buildout.cfg and the crontab entry above will be added automatically when you run bin/buildout:

parts += crontab_zeopack

# pack your ZODB each Sunday morning and hence make it smaller and faster
[crontab_zeopack]
recipe = z3c.recipe.usercrontab
times = 0 1 * * 6
command = ${buildout:directory}/bin/zeopack
是你 2024-10-28 18:13:06

如果您不使用ZEO:

curl -X POST -d 'days:float=0' http://admin:admin@localhost:8080/Control_Panel/Database/main/manage_pack

If you do not use ZEO:

curl -X POST -d 'days:float=0' http://admin:admin@localhost:8080/Control_Panel/Database/main/manage_pack
云裳 2024-10-28 18:13:06

我这样做(来自 https://raw.github.com/plock/pins/主/zeo):

[backup]
recipe = collective.recipe.backup

# Backup daily
[backups]
recipe = z3c.recipe.usercrontab
times = 0 0 * * * 
command = ${buildout:bin-directory}/bin/backup

# Pack once a month
[packups]
recipe = z3c.recipe.usercrontab
times = 0 0 1 * * 
command = ${buildout:bin-directory}/bin/zeopack

I do it like this (from https://raw.github.com/plock/pins/master/zeo):

[backup]
recipe = collective.recipe.backup

# Backup daily
[backups]
recipe = z3c.recipe.usercrontab
times = 0 0 * * * 
command = ${buildout:bin-directory}/bin/backup

# Pack once a month
[packups]
recipe = z3c.recipe.usercrontab
times = 0 0 1 * * 
command = ${buildout:bin-directory}/bin/zeopack
冷夜 2024-10-28 18:13:06

您可能需要查看 collective.migrator。其中有一个 pack_db 配方。

You may want to check out collective.migrator. It has a pack_db recipe among others.

年少掌心 2024-10-28 18:13:06

将 zeopack 用于 ZEO(请参阅其他答案),将 zodbpack 用于 RelStorage(包含在内,请参阅 RelStorage 文档)。两者都很容易设置。

Use zeopack for ZEO (see other answers), and zodbpack for RelStorage (included, see RelStorage docs). Both are easy to set up.

柠檬色的秋千 2024-10-28 18:13:06

有关 python/urllib 解决方案,请参阅:http://www.zope。 org/Documentation/Books/ZopeBook/2_6Edition/MaintainingZope.stx

#!/usr/bin/python
import sys, urllib
host = sys.argv[1]
days = sys.argv[2]
url = "%s/Control_Panel/Database/manage_pack?days:float=%s" % \
      (host, days)
try: 
    f = urllib.urlopen(url).read()
except IOError:
    print "Cannot open URL %s, aborting" % url
print "Successfully packed ZODB on host %s" % host

For a python/urllib solution, see: http://www.zope.org/Documentation/Books/ZopeBook/2_6Edition/MaintainingZope.stx

#!/usr/bin/python
import sys, urllib
host = sys.argv[1]
days = sys.argv[2]
url = "%s/Control_Panel/Database/manage_pack?days:float=%s" % \
      (host, days)
try: 
    f = urllib.urlopen(url).read()
except IOError:
    print "Cannot open URL %s, aborting" % url
print "Successfully packed ZODB on host %s" % host
Spring初心 2024-10-28 18:13:06

wget -O/dev/null -q --post-data='days:float=10' --user=adminuser --password=password http://localhost:PORT//Control_Panel/Database/main/manage_pack

如果您更喜欢 wget。

wget -O/dev/null -q --post-data='days:float=10' --user=adminuser --password=password http://localhost:PORT//Control_Panel/Database/main/manage_pack

If you prefer wget.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文