Multiple Plone sites per zope instance -- using separate Data.fs files for each one.
This How-to applies to:
Plone 2.5.x, Plone 2.1.x, Plone 2.0.x
This How-to is intended for:
Server Administrators
Introduction
In some cases, administrators with multiple Plone sites may want to isolate each site in a distinct database file. By default there is just one "Data.fs" file containing the entire Zope site. If each Plone site is in a distinct file, issues of backup, deletion, and relocation can (hopefully) be separable. This is an alternative to running multiple Zope instances. Discussion is welcome, since the author was attempting to optimize the problem of running multiple Plone sites corresponding to different user groups. N.B. this discussion applies only to vanilla ZODB sites and not to ZEO sites. See the comment below regarding ZEO sites.
Steps to carry out
1.) Edit Zope.conf
In zope.conf, the main Data.fs storage is defined by
<zodb_db main>
# Main FileStorage database
<filestorage>
path $INSTANCE/var/Data.fs
</filestorage>
mount-point /
</zodb_db>
Adding another section below this like
<zodb_db group1>
# FileStorage for group1
<filestorage>
path $INSTANCE/var/Data_group1.fs
</filestorage>
mount-point /group1
</zodb_db>
Restarting zope will establish a new the file Data_group1.fs and make the mount point "/group1" available under the zope structure.
However, the new mount point "/group1", is not yet usable.
2.) Use the zope management interface to enable the mount point.
The next step is to go to the Zope management page (not Plone's ZMI), and go to the Root Folder. In the "Add" pull down menu near the bottom, find the "ZODB Mount Point" entry and choose it. The "/group1" entry added above should be there, but not yet enabled. Select the new mount point via the check box, and click on "Create Selected Mount Points" After doing this, the new mount point should appear in the Root Folder as a subfolder.
3.) Create the Plone site inside the new subfolder.
Click on the new subfolder "/group1" and go inside. Once there, use the pull down "Add" menu and choose the "Plone Site" entry. Create a Plone site as usual and you are on your way. The site will be contained in the distinct "Data_group1.fs" file.
IssuesThe path to the plone site is http://yoursite:8080/group1/<sitename> where <sitename> is the name given the Plone site on creation. It makes sense to choose the names of "group1" and "sitename" in some sensible fashion to avoid a redundant name (easy to get this wrong the first time).
This technique is largely untested by the author of this How-to, hence tread carefully. Feedback is welcome.
- This discussion does NOT apply to ZEO based sites. In particular: "the recipe only applies to Zope installs without ZEO. There is considerably more than needs to be done to get a mount point in ZEO. See: http://trizpug.org/Members/cbc/mkzeowmp.txt/file_view and http://thread.gmane.org/gmane.org.user-groups.zope.trizpug/528/focus=528"
First think then write ... ;)
Your correct Sir!!!
A best practice (for me) is that each site has it's own .fs, and therefore it's own directory, and therefore it's own plone site. Nothing else is included in the .fs.
converting existing plone instances to mounted
cut&paste Plone Site to new mount makes it disappear
I then tried to do the same thing with *copy* and paste and it worked. The Test1.fs database size increased by about 900kB, and after deleting the Plone Site from the main DB and packing the main DB everything was fie without errors.
Maybe this is obvious to those with more in-depth Zope knowledge, as it seems to me that cut and paste only transfers the reference to the Plone Site and not the site itself, whereas copy and paste (with subsequent deletion of the original site) actually creates a new copy of the Plone Site object in the newly mounted database as intended.
zeo and zodb mounts
in server/etc/zeo.conf add:
<filestorage 2>
path $INSTANCE/var/mynew.fs
</filestorage>
then in the client1 and client2 zope.conf add the new mount point
<zodb_db mynew>
<zeoclient>
server servername:port
storage 2
name mynewdb
var $INSTANCE/var
</zeoclient>
mount-point mynew
</zodb_db>
then kick 'er over, you will see the new mynew.fs created and it will appear in the databases under control panel. Just go and add the new ZODB mount as normal.
It appears to be working fine for me.
To your point
I do this all the time (make sure your zope and plone versions are the same!!!)
plone upgrades
It also makes Plone upgrades easier; simply install the desired new Zope in a unique location (e.g. /opt/zope/296), create a new Zope instance with the latest Plone products installed (e.g. /var/lib/zope/instances/migrate-target), *copy* the old Plone site's Data.fs (ZODB mount point), and run portal migration. This way, migration kinks can be worked out safely; if necessary, start over with a fresh copy of Data.fs. When migration is complete and tested, Apache rewrites can be changed for a near seamless migration.
Note, in the <zodb_db> section, I typically also add::
#explicit declaration of object ZODB mount point object type
container-class OFS.Folder.Folder
#performance/memory tuning
pool-size 8
cache-size 2000
Previous Plone Version
Sorry to point this bue this practice is allowed in previous plone versions, are there any particular reason to say that's a plone 2.5 one ?
kind regards
r.
Re: Previous Plone Version
So yes, you can apply that technique to sites running older Plone versions :-)
Mounting an existing Plone site
There seems to be a little trick which seems not to be documented very well. Zope actually doesn't mount the "root" of object tree, which would be a behaviour similiar to Unix mount. What it does is mounting an _object_ within that tree, which has the same name as the mount point. So if, for example, we want to access a folder called "mysites" located at the root of a ZODB we're trying to mount, we have to call the mount point "mysites" as well.
Also, in case we want to mount a Plone Site (or some other object different from Folder), there's a container-class parameter in <zodb_db> section.
Disintegrate multiple Plones
-Jürgen