
This setup will introduce the ZEO server using mkzeoinstance and we will have to modify the configuration files, specifically zeo.conf and zope.conf. That’s it! No need to change the code. Connecting and dealing with objects is all the same.
ZEO server is the native solution for database load balancing. it allows us to access the Data.fs over the network. Also, it takes care of object locking!
a. Configuring zeo.conf
In zeo.conf, what is important is to specify the database files it should manage.
<zeo>
address 8800
read-only false
invalidation-queue-size 100
# pid-filename $INSTANCE/var/ZEO.pid
# monitor-address PORT
# transaction-timeout SECONDS
</zeo>
<filestorage 1>
path $INSTANCE/var/Data1.fs
</filestorage>
<filestorage 2>
path $INSTANCE/var/Data2.fs
</filestorage>
So now we have our database stored at the ZEO server.
b. Configuring zope.conf
Now we must configure zope.conf to get access to the database via the ZEO server.
<zodb 1>
<zeoclient>
server localhost:8800
storage 1
# ZEO client cache, in bytes
cache-size 20MB
# Uncomment to have a persistent disk cache
#client zeo1
</zeoclient>
</zodb>
<zodb 2>
<zeoclient>
server localhost:8800
storage 2
# ZEO client cache, in bytes
cache-size 20MB
# Uncomment to have a persistent disk cache
#client zeo2
</zeoclient>
</zodb>
When the ZEO server and Zope instance are started, the Zope instance will look for the ZEO server and it will connect to the database. The Zope instance will keep on searching at a regular interval if it fails to find the ZEO.
We don’t have to make any changes in the code to migrate from the previous setup to this setup.
0 Responses to “One Zope instance and ZEO server with two database”