Red Hat Bugzilla – Bug 842773
Zoneminder fails at startup
Last modified: 2014-11-20 19:41:09 EST
Description of problem:
Zoneminder fails to start due to the fact that mysql is not ready to accept connection. Looks they are started at the same time.
Jul 22 20:13:33 dvr mysqld_safe: 120722 20:13:33 mysqld_safe Logging to '/var/log/mysqld.log'.
Jul 22 20:13:33 dvr zoneminder: ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)
Jul 22 20:13:33 dvr mysqld_safe: 120722 20:13:33 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Jul 22 20:13:35 dvr zoneminder: Starting ZoneMinder: DBI connect('database=zm;host=localhost','zmuser',...) failed: Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) at /usr/share/perl5/vendor_perl/ZoneMinder/Config.pm line 89
Jul 22 20:13:35 dvr zoneminder: Can't call method "prepare_cached" on an undefined value at /usr/share/perl5/vendor_perl/ZoneMinder/Config.pm line 91.
Jul 22 20:13:35 dvr zoneminder: BEGIN failed--compilation aborted at /usr/share/perl5/vendor_perl/ZoneMinder/Config.pm line 100.
Jul 22 20:13:35 dvr zoneminder: Compilation failed in require at /usr/share/perl5/vendor_perl/ZoneMinder.pm line 33.
Jul 22 20:13:35 dvr zoneminder: BEGIN failed--compilation aborted at /usr/share/perl5/vendor_perl/ZoneMinder.pm line 33.
Jul 22 20:13:35 dvr zoneminder: Compilation failed in require at /usr/bin/zmpkg.pl line 46.
Jul 22 20:13:35 dvr zoneminder: BEGIN failed--compilation aborted at /usr/bin/zmpkg.pl line 46.
Jul 22 20:13:35 dvr zoneminder: [FAILED]
Jul 22 20:13:35 dvr systemd: zoneminder.service: control process exited, code=exited status=255
Jul 22 20:13:35 dvr systemd: Unit zoneminder.service entered failed state.
Try adding an After= ordering clause to the service file and see if it helps.
Zoneminder still uses init file located in /etc/inid.d/zoneminder.
Hm, indeed, it uses systemd in rawhide but not f17.
I am not sure there's anything that can be done here. When mysql was using initscripts the ordering was correct. With everything using systemd the ordering appears to be correct (or at least it worked OK in my testing, though I will double check). But I do not know if there is a way to enforce ordering between services using the old and new startup methods. At this point all I can really suggest is that you work around the issue by adding a sleep to the zoneminder initscript, though I'll be happy to look at any other options.
How about an updated packaged for fc17 to use systemd? or can I rebuild the src package from rawhide and use it on fc17?
Adding a sleep 10 to the init script gave mysql time to complete startup.
zmupdate || return $?
loadconf || return $?
#Make sure the directory for our PID folder exists or create one.
[ ! -d $pidfile ] \
&& mkdir -m 774 $pidfile \
&& chown $ZM_WEB_USER:$ZM_WEB_GROUP $pidfile
#Make sure the folder for the socks file exists or create one
GetPath="select Value from Config where Name='ZM_PATH_SOCKS'"
dbHost=`echo $ZM_DB_HOST | cut -d: -f1`
dbPort=`echo $ZM_DB_HOST | cut -d: -s -f2`
if [ "$dbPort" = "" ]
ZM_PATH_SOCK=`echo $GetPath | mysql -B -h$ZM_DB_HOST -u$ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
ZM_PATH_SOCK=`echo $GetPath | mysql -B -h$dbHost -P$dbPort -u$ZM_DB_USER -p$ZM_DB_PASS $ZM_DB_NAME | grep -v '^Value'`
[ ! -d $ZM_PATH_SOCK ] \
&& mkdir -m 774 $ZM_PATH_SOCK \
&& chown $ZM_WEB_USER:$ZM_WEB_GROUP $ZM_PATH_SOCK
echo -n $"Starting $prog: "
[ $RETVAL = 0 ] && success || failure
[ $RETVAL = 0 ] && touch $LOCKFILE
Updating a package from sysv to systemd is not permitted within a Fedora release. You are welcome to rebuild the F18 source package for F17 if you like. If I was at my dev station instead of on vacation here at one of the far ends of the Earth, I'd do a build for you.
This problem persists in F18 and I am struggling with it right now.
Since zm connects via unix sockets, is there a way to tell systemd to wait for the mysqld socket to exist before trying to start zm?
I guess mysql could use socket activation. I don't know; that's really something that should be taken up with the mysq1 maintainers. Dealing with this issue is supposed to be one of the reasons systemd was created, but I'm not really the person to ask about that.
The system.d startup profile for zm is part of the zm rpm. I really don't think the mysql guys have anything to do with this fix.
I'm glad that's what you think, but unfortunately you are not correct. If mysql wants to make use of the systemd socket activation feature, where clients can connect and systemd will simply hold their connections until mysql actually starts up, then the mysql maintainers are going to have to do that. It's nothing I can do in zoneminder.
After adding After and Requires entries to /etc/systemd/system/multi-user.target.wants/zoneminder.service, zm starts up properly.
Description=Video security and surveillance system
This is just an FYI.
I tried your fix on a fully patched F17 and it doesn't work for me.
There was no zoneminder.service file in multi-user.target.wants, so I just created it. Don't know enough about systemd to really know what I did.
When I execute a systemctl enable for this it still segways to chkconfig, so what I have is still not part of a REAL systemd setup.
This message is a reminder that Fedora 17 is nearing its end of life.
Approximately 4 (four) weeks from now Fedora will stop maintaining
and issuing updates for Fedora 17. It is Fedora's policy to close all
bug reports from releases that are no longer maintained. At that time
this bug will be closed as WONTFIX if it remains open with a Fedora
'version' of '17'.
Package Maintainer: If you wish for this bug to remain open because you
plan to fix it in a currently maintained version, simply change the 'version'
to a later Fedora version prior to Fedora 17's end of life.
Bug Reporter: Thank you for reporting this issue and we are sorry that
we may not be able to fix it before Fedora 17 is end of life. If you
would still like to see this bug fixed and are able to reproduce it
against a later version of Fedora, you are encouraged change the
'version' to a later Fedora version prior to Fedora 17's end of life.
Although we aim to fix as many bugs as possible during every release's
lifetime, sometimes those efforts are overtaken by events. Often a
more recent Fedora release includes newer upstream software that fixes
bugs or makes them obsolete.
Fedora 17 changed to end-of-life (EOL) status on 2013-07-30. Fedora 17 is
no longer maintained, which means that it will not receive any further
security or bug fix updates. As a result we are closing this bug.
If you can reproduce this bug against a currently maintained version of
Fedora please feel free to reopen this bug against that version.
Thank you for reporting this bug and we are sorry it could not be fixed.
I just installed zoneminder on a fully patched F19, and it still exhibits the failure as described above. However, the fix to add:
to /etc/systemd/system/multi-user.target.wants/zoneminder.service also as described above works.
I just wanted someone to know that adding those 2 lines to that file fixes the problem.
This was happening on 18, 19, 20.. Maybe it'll get a fix in 21?