How to build a simple shared zeoserver-only setup for Plone 3

Note: The following is probably very adaptable to Plone 4. In fact, I suspect it’s even easier in Plone 4. But I’m working on Plone 3 right now, so there you go.

When you first install Plone, you get everything together: server, client, whatever, it just works. I’m sure not everybody knows, or cares, that Zope can be run as a zeoserver distinct from the zeoclient. But there are some reasons to care:

  1. Simplicity: Plone can seem complex, but zeoserver is dead simple. Separating it from the clients is the easiest way to see this.
  2. Flexibility: Need to reboot or migrate a server without site downtime? You can’t, unless you’re using load-balancing proxies. But with zeoserver on a separate machine from the clients, the clients can withstand short outages of the zeoserver without apparent downtime, even if you don’t have a load balancer! (YMMV depending on demand, zeoserver’s reboot time and the clients’ caches.) Moving the clients gets easier, too.
  3. Backups: I don’t need to backup all of Plone. The only important part is the Data.fs (and in Plone 4, the blobs, but that’s for another day). Now my backup scenario can effectively ignore the client servers, and just back up what’s on the server with the ZODBs on it.
  4. Scalability: I’ll let these results speak for themselves:
    Before
    $ du -hs --exclude '*.log' plone
    526M     site1
    407M     site2
    676M     site3
    After:
    $ du -hs *
    53M	Python-2.4
    73M	Zope-2.10.11-final-py2.4
    11M	site1
    11M	site2
    11M	site3

    Well, that’s not quite fair – the client code isn’t listed there, but it’s no longer an issue for this server.

Hopefully that’s enough to get you interested.

Getting started

  1. Decide how you will structure your filesystem:
    • Where the Data.fs will be stored: /srv/plone/testcase/Data.fs
    • Shared Python 2.4: /opt/plone/Python-2.4
    • Shared Zope 2.10: /opt/plone/Zope-2.10.11-final-py2.4
    • Buildout for zeo: /opt/plone/testcase
  2. Create the user that the zeoservers will run as. Create the parents of the above paths and give that user ownership. Become that user for the rest of these instructions.
    useradd zeo
    mkdir /srv/plone && chown zeo /srv/plone
    mkdir /opt/plone && chown zeo /opt/plone
    su - zeo || sudo -u zeo bash
  3. Download and unpack the Universal Installer (UI) from Plone.org. Use the UI to install a shared Zope and Python, but nuke the rest of what it installs for now.
    ./install.sh --target=/opt/plone zeo && rm -rf /opt/plone/{buildout-cache,zeocluster}
  4. Use the UI to install an actual zeoserver using that shared Python and Zope:
    ./install.sh --target=/opt/plone/testcase --with-python=/opt/plone/Python-2.4/bin/python --with-zope=/opt/plone/Zope-2.10.11-final-py2.4 zeo
  5. Go to the zeocluster directory and clean out the buildout stuff that is only needed for Plone clients. You really only need bin/buildout, buildout.cfg. If you’re using bash you can do this quickly with extglob:
    cd /opt/plone/testcase/zeocluster && shopt -s extglob
    rm -rf ../buildout-cache/ bin/!(buildout) !(bin|buildout.cfg|versions.cfg) .installed.cfg
  6. Create a backup of the buildout file and begin working on it. You can delete almost everything in there, just keep the zope2 and zeoserver parts and fix any broken references. Here’s what mine looks like:
    [buildout]
    extends = versions.cfg
    versions = versions
    extensions = buildout.dumppickedversions
    dump-picked-versions-file = picked-versions.cfg
    zeo-address = 8100
    file-storage = /srv/plone/testcase/Data.fs
    parts =
    	zope2
    	zeoserver
    
    [zope2]
    recipe = plone.recipe.zope2install
    url = ${versions:zope2-url}
    fake-zope-eggs = true
    additional-fake-eggs =
    	ZConfig
    	pytz
    
    [zeoserver]
    recipe = plone.recipe.zope2zeoserver
    zope2-location = ${zope2:location}
    zeo-address = ${buildout:zeo-address}
    effective-user = zeo
    file-storage = ${buildout:file-storage}
  7. Once you’re satisfied with your buildout configuration, run buildout, fix permissions and try to start the instance. (Note: buildout always crashes the first time I do this because of a setuptools incompatibility. Just run it again if it fails.):
    bin/buildout || bin/buildout && chown -R zeo:zeo . && bin/zeoserver start
  8. That’s it! Now to create a new zeoserver, just repeat steps 5-8, updating the paths and port number (zeo-address) to suit.

That’s really all there is to it. Tomorrow I’ll post how to put together the client side.

One thought on “How to build a simple shared zeoserver-only setup for Plone 3”

Comments are closed.