Suggestions for master/slave configuration?

Forum for questions and support relating to the 1.24.x releases only.
Post Reply
Posts: 69
Joined: Fri Jul 30, 2010 12:29 am

Suggestions for master/slave configuration?

Post by Pada » Wed Oct 13, 2010 8:24 pm


I'm looking for suggestions on how to configure ZoneMinder such that a single user can view/control all the servers and their associated cameras.

I really don't know what the best way to set up such a configuration. The reasons why I have multiple servers, are due to the limited amount of cameras that can be connected to the capturing card + the resources (CPU usage & storage) required for the capturing of the video feeds.

My idea of how the setup would look:
Master server/PC:
  • Central database for access control
  • Web interface for control panel / montage view
  • 100Mbps link to slave servers
Slave servers:
  • Typically 8 cameras
  • Local video capturing
  • Local video streaming facility
  • Local HDD's for video storage
  • Remote database
Perhaps the central database for storing the events is not a good idea, but I'm not sure how to modify/optimize ZoneMinder for a better configuration.

Currently I have tried to write an addon to ZoneMinder's classic skin which allow 1 server to specify multiple slave server databases, but this idea of mine did not work that well, due to all the PHP constants being used.

Ideas/suggestions/comments are much appreciated.

Thank you in advance,

Posts: 69
Joined: Fri Jul 30, 2010 12:29 am

Post by Pada » Mon Oct 18, 2010 12:54 am

I would really appreciate input on this matter, even if it's as simple as saying that my idea should work, but would require lots of modifications to the existing code....

So far I've only came across a similar thread once, but that was for 1.22.3: N00b - zoneminder in a "distributed" environment

Posts: 69
Joined: Fri Jul 30, 2010 12:29 am

Post by Pada » Fri Oct 22, 2010 9:16 pm

OK, I have now tried running 2 ZM machines from a shared database (simply changing the ZM_DB_HOST) and this did not work as I'd anticipated.

Now both machines are trying to capture from the same cameras and the web interface always tries to use the zms-nph running from the same machine as the website the user is viewing.

So it seems like I have to make a couple of source code modifications to ensure that each ZM machine can only capture and stream its own cameras.

I would still very much like advice on this topic.

Posts: 195
Joined: Mon Dec 10, 2007 5:53 pm
Location: San Jose, CA

Post by timcraig » Fri Oct 22, 2010 11:18 pm

One zero customization way would be to:

- Move all the storage to the master.
- Have all the slaves only monitor and not record.
- Have the master use all the monitors on the slaves as a remote monitor (a url like http://<slave>/cgi-bin/zms?mode=jpeg&monitor=<slave>)

This however won't provide a performance benefit as the master would be doing all the motion detection and writing to the harddisk.

I don't think there's any way to configure ZM so that you have a master/slave setup where the slaves do all the work and the master simply pipes the video stream to the user. You'll have to do some kind of custom programming.

The simplest way to do a custom programming job that I can think of is:

- Customize the web interface ZM master so that monitors are only in 'monitor' mode. (So when you add a monitor, it is forever in monitor mode)
- Add all the slave monitors as remote monitors on the master.

This takes care of live viewing. Now do the following for events:

- Customize Zoneminder -or- write an external cron script that will look at all of the masters remote monitors, look at which slave ip address and monitor id the remote monitor is pulling the feed from, and mount the slave monitor’s event folder to the as a event folder on the mater (via sftp, samba, NFS, etc).
So, for example, the Master has a monitor of ID 1 is using that isthe remote url http://<slave1>/cgi-bin/zms?mode=jpeg&monitor=5), the mount will <on>:/var/www/zoneminder/events/4 to <on>:/var/www/zonminder/events/1

- Write a script or a daemon that syncs the databases of the slaves to the master based on the mapping of the master’s remote cameras. So in our example of master-with-monitor-ID-1 being linked slave-with-monitor-id-4, the script will sync all the event data the slave has for monitor-id-4 in the slaves database and insert it the masters database replacing the monitor from 4 to 1.
And when I say sync, I mean all the data except for the unique ids on tables (e.g the EventId and FrameID)

This keeps all the storage and motion detection on the slaves and leaves the master with a relatively intact Zoneminder interface. However the main drawback is that the slave will be pulling a lot of jpegs across the network when streaming events and there will be a lag of when new events show up on the master. A way to cut down on the event update lag is to customize the slave version of Zoneminder to sync the event data to the slave as soon as they come in.

Edit: fixed some typos.
Last edited by timcraig on Sat Oct 23, 2010 5:34 pm, edited 1 time in total.

Posts: 69
Joined: Fri Jul 30, 2010 12:29 am

Post by Pada » Sat Oct 23, 2010 1:44 am

Thank you so much tim! I am really grateful for this.

I really love your "zero customization" way!
For a Montage view of all the cameras this is definitely the easiest way to go, and to simplify things more, I'm going to keep the slave servers as is (local db + storage for recording).

I will definitely give this complicated custom programming idea of yours a thought, but I definitely won't be trying to program something as complicated as this soon.
The only thing that I don't like about this kind of setup is the amount of network, storage and CPU resources that you would require to pull this off.

My current idea is to:
  1. Run central database on master server
  2. Keep monitoring & capturing on slave servers
  3. Add table on master server to identify all the slave servers (which would contain their ID #, IP address and path to zms, etc)
  4. Add slave server ID # field for the monitors
  5. Add the slave server ID (given by master server) in the corresponding slave server's config
  6. Now the big coding part comes (although it shouldn't be too complicated) where I would:
    1. allow the slave server to capture & record from the monitor if the slave server ID matches its own
    2. and on the master server I would have to modify the camera feed URL's to point to the slave zms apps - both for live and event viewing
    3. and I would have to get an ajax script to get the camera status

Posts: 195
Joined: Mon Dec 10, 2007 5:53 pm
Location: San Jose, CA

Post by timcraig » Sat Oct 23, 2010 5:50 pm

Your idea sounds good. Keep us updated with your progress.

My customized idea was very wordy in the previous post. Let me summarize here:

* Slaves are normal Zoneminder installations.
* Master customized to only allowed to put monitors on monitor mode.
* Master adds slave monitors as remote monitors (using the url to the slave's zms stream url) for live streaming.
* Master mounts slave's monitor event folder to master's event folder (based on the master monitor ID mapped to slave monitor id) so that all the storage remains on the slave.
* Master syncs slave monitor's event data in the slave's database into the mater's data mapping (based on the master-monitor-id to slave-monitor-id mapping).

Posts: 69
Joined: Fri Jul 30, 2010 12:29 am

Post by Pada » Sat Oct 23, 2010 6:38 pm

Thanks for that summary. Now I have a much better idea of what you were trying to do, and it now seems even less complicated to be honest.

Currently I'm sitting with 2 "slave" servers, that my lecturer set up, with 6 and 8 cameras respectively. Unfortunately for me, those 2 servers are already in use and they of ZM (1.22.3 & 1.23.3), and I'm not allowed to make any modifications to the servers that could affect their recording since they're already in use.

For now I have just added all the cameras of the slave servers onto the master server, by feeding it from the slave servers' nph-zms URL's which output jpeg streams.
It's actually quite astonishing to see how much more fluent the video streams are in the Montage view of my master server compared to the slave servers' Montage views, simply because my master server runs on 1.24.2 and uses mpeg streaming and not jpeg streaming like the slave servers.

For now I won't be able to try more than this zero configuration setup that you suggested, since I have to finish writing up my documentation which is due in less than 2 days. After that I might have time to fiddle with the ZM setups again.

Thank you again for helping me, I really appreciate all the help that I get, since I haven't had much help with regards to ffmpeg and ZoneMinder up till now.

Posts: 195
Joined: Mon Dec 10, 2007 5:53 pm
Location: San Jose, CA

Post by timcraig » Mon Oct 25, 2010 2:51 am

I just realized I overlooked something.

The eventId will be different in the master's database and on the mounted event folders pointing to the slave's event folders. There will be need for customizing the Zoneminder master to have another database table that maps the eventid's in the database and the event id's of the mount folders. And customize the master's event viewing to use the mapping table to get correct folder containing the event's images.

Post Reply

Who is online

Users browsing this forum: No registered users and 7 guests