I have set up kamailio 3.1.2 on an install of Debian Squeeze, using the default config but with the following defines enabled: WITH_MYSQLWITH_AUTHWITH_USRLOCDBWITH_NAT Everything works as expected when starting Kamailio from a terminal, e.g.service kamailio start But after a reboot, the service fails to start and all SIP requests are dropped with a ICMP port unreachable error. The following is an extract of /var/log/syslog when this problem occurs. It looks like Kamailio is failing to access the mysql socket, as the mysql service has not yet started? Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: db_mysql [km_my_con.c:109]: driver error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: <core> [db.c:289]: could not add connection to the poolApr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: usrloc [dlist.c:486]: failed to open database connectionApr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: registrar [reg_mod.c:396]: failed to register domainApr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: <core> [route.c:1161]: fixing failed (code=-1) at cfg:/etc/kamailio/kamailio.cfg:569Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: <core> [route.c:1161]: fixing failed (code=-1) at cfg:/etc/kamailio/kamailio.cfg:572Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: <core> [route.c:1161]: fixing failed (code=-1) at cfg:/etc/kamailio/kamailio.cfg:574Apr 12 10:08:34 SIPServer mysqld_safe: Starting mysqld daemon with databases from /var/lib/mysqlApr 12 10:08:34 SIPServer mysqld: 110412 10:08:34 [Note] Plugin 'FEDERATED' is disabled.Apr 12 10:08:36 SIPServer mysqld: 110412 10:08:36 InnoDB: Started; log sequence number 0 44233Apr 12 10:08:36 SIPServer mysqld: 110412 10:08:36 [Note] Event Scheduler: Loaded 0 eventsApr 12 10:08:36 SIPServer mysqld: 110412 10:08:36 [Note] /usr/sbin/mysqld: ready for connections.Apr 12 10:08:36 SIPServer mysqld: Version: '5.1.49-3' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Debian) Both the Kamailio and mysql services start with priority 18 on run levels 2345. I tried adjusting the Kamailio service to priority 19, but the problem still occurs. I am relatively new to Kamailio and mysql as well as Linux / Debian administration, so I'm not really sure how to solve this problem. Any ideas would be greatly appreciated. Regards,Rick Aldred
Hello,
On 4/12/11 11:34 AM, Rick Aldred wrote:
I have set up kamailio 3.1.2 on an install of Debian Squeeze, using the default config but with the following defines enabled:
WITH_MYSQL WITH_AUTH WITH_USRLOCDB WITH_NAT
Everything works as expected when starting Kamailio from a terminal, e.g. service kamailio start
But after a reboot, the service fails to start and all SIP requests are dropped with a ICMP port unreachable error.
The following is an extract of /var/log/syslog when this problem occurs. It looks like Kamailio is failing to access the mysql socket, as the mysql service has not yet started?
Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: db_mysql [km_my_con.c:109]: driver error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: <core> [db.c:289]: could not add connection to the pool Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: usrloc [dlist.c:486]: failed to open database connection Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: registrar [reg_mod.c:396]: failed to register domain Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: <core> [route.c:1161]: fixing failed (code=-1) at cfg:/etc/kamailio/kamailio.cfg:569 Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: <core> [route.c:1161]: fixing failed (code=-1) at cfg:/etc/kamailio/kamailio.cfg:572 Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: <core> [route.c:1161]: fixing failed (code=-1) at cfg:/etc/kamailio/kamailio.cfg:574 Apr 12 10:08:34 SIPServer mysqld_safe: Starting mysqld daemon with databases from /var/lib/mysql Apr 12 10:08:34 SIPServer mysqld: 110412 10:08:34 [Note] Plugin 'FEDERATED' is disabled. Apr 12 10:08:36 SIPServer mysqld: 110412 10:08:36 InnoDB: Started; log sequence number 0 44233 Apr 12 10:08:36 SIPServer mysqld: 110412 10:08:36 [Note] Event Scheduler: Loaded 0 events Apr 12 10:08:36 SIPServer mysqld: 110412 10:08:36 [Note] /usr/sbin/mysqld: ready for connections. Apr 12 10:08:36 SIPServer mysqld: Version: '5.1.49-3' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Debian)
the logs shows that the mysql server is started after kamailio. Be sure you set the order at startup to run mysql first, maybe google helps to find the proper way.
Cheers, Daniel
Both the Kamailio and mysql services start with priority 18 on run levels 2345. I tried adjusting the Kamailio service to priority 19, but the problem still occurs.
I am relatively new to Kamailio and mysql as well as Linux / Debian administration, so I'm not really sure how to solve this problem. Any ideas would be greatly appreciated.
Regards, Rick Aldred
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users
the logs shows that the mysql server is started after kamailio. Be sure you set the order at startup to run mysql first, maybe google helps to find the proper way.
That's a bug in the init script of Kamailio:
IIRC:
/etc/init.d/kamailio (add mysql):
# Required-Start: $syslog $network $local_fs $time mysql # Required-Stop: $syslog $network $local_fs mysql
# re-create symlinks: update-rc.d kamailio defaults
Thanks Klaus (and Daniel).
That has solved my problem.
I had just discovered the LSB header configuration in the init.d script but was missing the update-rc.d call, so thank you!
Since I am using rtpproxy for NAT traversal, maybe I should also add this a required service, although it has worked without that so far.
Regards, Rick
________________________________ From: Klaus Darilion klaus.mailinglists@pernau.at To: miconda@gmail.com; SIP Router - Kamailio (OpenSER) and SIP Express Router (SER) - Users Mailing List sr-users@lists.sip-router.org Cc: Rick Aldred eazilyled@yahoo.co.uk Sent: Tue, 12 April, 2011 13:03:09 Subject: Re: [SR-Users] Kamailio service not starting on reboot when using mysql
database
the logs shows that the mysql server is started after kamailio. Be sure you set the order at startup to run mysql first, maybe google helps to find the proper way.
That's a bug in the init script of Kamailio:
IIRC:
/etc/init.d/kamailio (add mysql):
# Required-Start: $syslog $network $local_fs $time mysql # Required-Stop: $syslog $network $local_fs mysql
# re-create symlinks: update-rc.d kamailio defaults
On 12.04.2011 14:19, Rick Aldred wrote:
Thanks Klaus (and Daniel).
That has solved my problem.
I had just discovered the LSB header configuration in the init.d script but was missing the update-rc.d call, so thank you!
Since I am using rtpproxy for NAT traversal, maybe I should also add this a required service, although it has worked without that so far.
Yes. But it is not that urgent as Kamailio will start also without finding rtpproxy as it will retry some time later again.
regards klaus
Regards, Rick
From: Klaus Darilionklaus.mailinglists@pernau.at To: miconda@gmail.com; SIP Router - Kamailio (OpenSER) and SIP Express Router (SER) - Users Mailing Listsr-users@lists.sip-router.org Cc: Rick Aldredeazilyled@yahoo.co.uk Sent: Tue, 12 April, 2011 13:03:09 Subject: Re: [SR-Users] Kamailio service not starting on reboot when using mysql
database
the logs shows that the mysql server is started after kamailio. Be sure you set the order at startup to run mysql first, maybe google helps to find the proper way.
That's a bug in the init script of Kamailio:
IIRC:
/etc/init.d/kamailio (add mysql):
# Required-Start: $syslog $network $local_fs $time mysql # Required-Stop: $syslog $network $local_fs mysql
# re-create symlinks: update-rc.d kamailio defaults
On 4/13/11 10:31 AM, Klaus Darilion wrote:
On 12.04.2011 14:19, Rick Aldred wrote:
Thanks Klaus (and Daniel).
That has solved my problem.
I had just discovered the LSB header configuration in the init.d script but was missing the update-rc.d call, so thank you!
Since I am using rtpproxy for NAT traversal, maybe I should also add this a required service, although it has worked without that so far.
Yes. But it is not that urgent as Kamailio will start also without finding rtpproxy as it will retry some time later again.
Maybe someone that knows the right format can send a patch to get the init.d script to the proper LSB header - even better, commit the fix if someone with git write access knows the format.
Cheers, Daniel
On 13.04.2011 10:48, Daniel-Constantin Mierla wrote:
On 4/13/11 10:31 AM, Klaus Darilion wrote:
On 12.04.2011 14:19, Rick Aldred wrote:
Thanks Klaus (and Daniel).
That has solved my problem.
I had just discovered the LSB header configuration in the init.d script but was missing the update-rc.d call, so thank you!
Since I am using rtpproxy for NAT traversal, maybe I should also add this a required service, although it has worked without that so far.
Yes. But it is not that urgent as Kamailio will start also without finding rtpproxy as it will retry some time later again.
Maybe someone that knows the right format can send a patch to get the init.d script to the proper LSB header - even better, commit the fix if someone with git write access knows the format.
I think the problem is not the proper format, but when to add dependencies. For example just because mysql is installed does not mean that mysql is really used by Kamailio.
regards Klaus
On Wednesday 13 April 2011, Klaus Darilion wrote:
Maybe someone that knows the right format can send a patch to get the init.d script to the proper LSB header - even better, commit the fix if someone with git write access knows the format.
I think the problem is not the proper format, but when to add dependencies. For example just because mysql is installed does not mean that mysql is really used by Kamailio.
Hi Klaus,
yes - for example on a stateless loadbalancer. If we add this to the init script, we need to think about making mysql a runtime requirement also from the packaging level.
Cheers,
Henning
Hi all,
Maybe the fix would be to include mysql under 'Should-Start' (and 'Should-Stop') in the LSB
header. That way mysql will be started if it is present, but not prevent Kamailio from starting if it is not.
There is actually already a commented out Should-Start and Should-Stop in /etc/init.d/kamailio - it would just need uncommenting and moving up into the header.
I am sticking with Required-Start as I have defined WITH_MYSQL, WITH_AUTH, wtc in my config file.
I found these definitions of Should-Start and Should-Stop at http://wiki.debian.org/LSBInitScripts:
Should-Start: boot_facility_1 [boot_facility_2...] defines the facilities that if present should start before the service provided by the script. Nevertheless, the script can still start if the listed facilities
are missing. This allows for weak dependencies which do not cause the service to
fail if a facility is not available. Consider using virtual facility names as described below if adequate.
Should-Stop: boot_facility_1 [boot_facility_2...] defines the facilities that if present should be stopped after this service. Normally you would include here the same facilities as those used with the Should-Start keyword.
Regards, Rick
----- Original Message ---- From: Henning Westerholt henning.westerholt@1und1.de To: sr-users@lists.sip-router.org Cc: Klaus Darilion klaus.mailinglists@pernau.at; "miconda@gmail.com" miconda@gmail.com; Rick Aldred eazilyled@yahoo.co.uk Sent: Wed, 13 April, 2011 10:30:45 Subject: Re: [SR-Users] Kamailio service not starting on reboot when using mysql
database
On Wednesday 13 April 2011, Klaus Darilion wrote:
Maybe someone that knows the right format can send a patch to get the init.d script to the proper LSB header - even better, commit the fix if someone with git write access knows the format.
I think the problem is not the proper format, but when to add dependencies. For example just because mysql is installed does not mean that mysql is really used by Kamailio.
Hi Klaus,
yes - for example on a stateless loadbalancer. If we add this to the init script, we need to think about making mysql a runtime requirement also from the packaging level.
Cheers,
Henning
On Wednesday 13 April 2011, Rick Aldred wrote:
Maybe the fix would be to include mysql under 'Should-Start' (and 'Should-Stop') in the LSB
header. That way mysql will be started if it is present, but not prevent Kamailio from starting if it is not.
There is actually already a commented out Should-Start and Should-Stop in /etc/init.d/kamailio - it would just need uncommenting and moving up into the header.
Hi Rick,
ok, good idea. I've added suggestions like you proposed for mysql, postgres and (free)radius.
Best regards,
Henning
Hi, from the log you pasted is clear that the problem is that kamailio is starting before mysql. This because, as you said, they have the same priority and so, being the starting order alphabetical for the same priority, kamailio will start before mysql and cannot connect to mysql which is still not up. You told that changing kamailio priority didn't change the result. How did you change the priority? Did you use the update-rc.d command?
Regards,
Federico
2011/4/12 Rick Aldred eazilyled@yahoo.co.uk
I have set up kamailio 3.1.2 on an install of Debian Squeeze, using the default config but with the following defines enabled:
WITH_MYSQL WITH_AUTH WITH_USRLOCDB WITH_NAT
Everything works as expected when starting Kamailio from a terminal, e.g. service kamailio start
But after a reboot, the service fails to start and all SIP requests are dropped with a ICMP port unreachable error.
The following is an extract of /var/log/syslog when this problem occurs. It looks like Kamailio is failing to access the mysql socket, as the mysql service has not yet started?
Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: db_mysql [km_my_con.c:109]: driver error: Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2) Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: <core> [db.c:289]: could not add connection to the pool Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: usrloc [dlist.c:486]: failed to open database connection Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: registrar [reg_mod.c:396]: failed to register domain Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: <core> [route.c:1161]: fixing failed (code=-1) at cfg:/etc/kamailio/kamailio.cfg:569 Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: <core> [route.c:1161]: fixing failed (code=-1) at cfg:/etc/kamailio/kamailio.cfg:572 Apr 12 10:08:31 SIPServer /usr/sbin/kamailio[1347]: ERROR: <core> [route.c:1161]: fixing failed (code=-1) at cfg:/etc/kamailio/kamailio.cfg:574 Apr 12 10:08:34 SIPServer mysqld_safe: Starting mysqld daemon with databases from /var/lib/mysql Apr 12 10:08:34 SIPServer mysqld: 110412 10:08:34 [Note] Plugin 'FEDERATED' is disabled. Apr 12 10:08:36 SIPServer mysqld: 110412 10:08:36 InnoDB: Started; log sequence number 0 44233 Apr 12 10:08:36 SIPServer mysqld: 110412 10:08:36 [Note] Event Scheduler: Loaded 0 events Apr 12 10:08:36 SIPServer mysqld: 110412 10:08:36 [Note] /usr/sbin/mysqld: ready for connections. Apr 12 10:08:36 SIPServer mysqld: Version: '5.1.49-3' socket: '/var/run/mysqld/mysqld.sock' port: 3306 (Debian)
Both the Kamailio and mysql services start with priority 18 on run levels 2345. I tried adjusting the Kamailio service to priority 19, but the problem still occurs.
I am relatively new to Kamailio and mysql as well as Linux / Debian administration, so I'm not really sure how to solve this problem. Any ideas would be greatly appreciated.
Regards, Rick Aldred
SIP Express Router (SER) and Kamailio (OpenSER) - sr-users mailing list sr-users@lists.sip-router.org http://lists.sip-router.org/cgi-bin/mailman/listinfo/sr-users