Debian 8 openSIPS starts before MySQL on boot end exits with MySQL error

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
0
down vote

favorite












I installed and configured openSIPS 2.3 with MySQL on a Debian 8.10 but on boot openSIPS wont start because it starts before MySQL and can't connect to the database. After the system booted up can start opensips without error.



I found what it looked like a solution on an openSIPS mailing list, but I still get the same error.



What I did so far is editing /etc/init.d/opensisp and cahanged init info to this



### BEGIN INIT INFO
# Provides: opensips
# Required-Start: $syslog $network $local_fs $time
# Required-Stop: $syslog $network $local_fs
# Should-Start: mysql #added this
# Should-Stop: mysql #and this
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the OpenSIPS SIP server
# Description: Start the OpenSIPS SIP server
### END INIT INFO


than I run insserv -v opensips and rebooted, but its the same opensisp fails with couldn't connect to db error



ERROR:db_mysql:db_mysql_connect: driver error(2002): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
ERROR:db_mysql:db_mysql_new_connection: initial connect failed


according to /ętc/rc?.d mysql should start before opensips but its not what happens or mysql isn't fully started when opensips starts.



here is a dump of rc for mysql and opensips



lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc0.d/K02mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc1.d/K02mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc2.d/S03mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc3.d/S03mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc4.d/S03mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc5.d/S03mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc6.d/K02mysql -> ../init.d/mysql

############

lrwxrwxrwx 1 root root 18 febr 25 01:17 /etc/rc0.d/K01opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 25 01:17 /etc/rc1.d/K01opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 27 10:40 /etc/rc2.d/S04opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 27 10:40 /etc/rc3.d/S04opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 27 10:40 /etc/rc4.d/S04opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 27 10:40 /etc/rc5.d/S04opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 25 01:17 /etc/rc6.d/K01opensips -> ../init.d/opensips


How can I force openSIPS to wait for mysql?







share|improve this question






















  • Debian 8 does not use sysvinit by default; it uses systemd. Have you configured it to use sysv?
    – Rui F Ribeiro
    Feb 27 at 11:05










  • No, I have not. But if I'm not mistaken insserv should have taken care of the order when I specified should-start in the LSB
    – Laci K
    Feb 27 at 11:16










  • Ok, have edited the sysV out from your question, it is misleading. You are using systemd then. I am not so used to systemd, we will wait someone else to answer you.
    – Rui F Ribeiro
    Feb 27 at 11:17











  • Ok thanks. I probably clicked on it by accident.
    – Laci K
    Feb 27 at 11:22










  • I'd guess mysql will listen last, once started. So what you can do is add somewhere (end of mysql or start of opensips) a loop that does fuser /var/run/mysqld/mysqld.sock . Once it gets a result (and thus a 0 exit status) that means mysql is listening and probably ready to serve requests. Don't make the loop infinite
    – A.B
    Feb 27 at 11:53















up vote
0
down vote

favorite












I installed and configured openSIPS 2.3 with MySQL on a Debian 8.10 but on boot openSIPS wont start because it starts before MySQL and can't connect to the database. After the system booted up can start opensips without error.



I found what it looked like a solution on an openSIPS mailing list, but I still get the same error.



What I did so far is editing /etc/init.d/opensisp and cahanged init info to this



### BEGIN INIT INFO
# Provides: opensips
# Required-Start: $syslog $network $local_fs $time
# Required-Stop: $syslog $network $local_fs
# Should-Start: mysql #added this
# Should-Stop: mysql #and this
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the OpenSIPS SIP server
# Description: Start the OpenSIPS SIP server
### END INIT INFO


than I run insserv -v opensips and rebooted, but its the same opensisp fails with couldn't connect to db error



ERROR:db_mysql:db_mysql_connect: driver error(2002): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
ERROR:db_mysql:db_mysql_new_connection: initial connect failed


according to /ętc/rc?.d mysql should start before opensips but its not what happens or mysql isn't fully started when opensips starts.



here is a dump of rc for mysql and opensips



lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc0.d/K02mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc1.d/K02mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc2.d/S03mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc3.d/S03mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc4.d/S03mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc5.d/S03mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc6.d/K02mysql -> ../init.d/mysql

############

lrwxrwxrwx 1 root root 18 febr 25 01:17 /etc/rc0.d/K01opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 25 01:17 /etc/rc1.d/K01opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 27 10:40 /etc/rc2.d/S04opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 27 10:40 /etc/rc3.d/S04opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 27 10:40 /etc/rc4.d/S04opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 27 10:40 /etc/rc5.d/S04opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 25 01:17 /etc/rc6.d/K01opensips -> ../init.d/opensips


How can I force openSIPS to wait for mysql?







share|improve this question






















  • Debian 8 does not use sysvinit by default; it uses systemd. Have you configured it to use sysv?
    – Rui F Ribeiro
    Feb 27 at 11:05










  • No, I have not. But if I'm not mistaken insserv should have taken care of the order when I specified should-start in the LSB
    – Laci K
    Feb 27 at 11:16










  • Ok, have edited the sysV out from your question, it is misleading. You are using systemd then. I am not so used to systemd, we will wait someone else to answer you.
    – Rui F Ribeiro
    Feb 27 at 11:17











  • Ok thanks. I probably clicked on it by accident.
    – Laci K
    Feb 27 at 11:22










  • I'd guess mysql will listen last, once started. So what you can do is add somewhere (end of mysql or start of opensips) a loop that does fuser /var/run/mysqld/mysqld.sock . Once it gets a result (and thus a 0 exit status) that means mysql is listening and probably ready to serve requests. Don't make the loop infinite
    – A.B
    Feb 27 at 11:53













up vote
0
down vote

favorite









up vote
0
down vote

favorite











I installed and configured openSIPS 2.3 with MySQL on a Debian 8.10 but on boot openSIPS wont start because it starts before MySQL and can't connect to the database. After the system booted up can start opensips without error.



I found what it looked like a solution on an openSIPS mailing list, but I still get the same error.



What I did so far is editing /etc/init.d/opensisp and cahanged init info to this



### BEGIN INIT INFO
# Provides: opensips
# Required-Start: $syslog $network $local_fs $time
# Required-Stop: $syslog $network $local_fs
# Should-Start: mysql #added this
# Should-Stop: mysql #and this
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the OpenSIPS SIP server
# Description: Start the OpenSIPS SIP server
### END INIT INFO


than I run insserv -v opensips and rebooted, but its the same opensisp fails with couldn't connect to db error



ERROR:db_mysql:db_mysql_connect: driver error(2002): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
ERROR:db_mysql:db_mysql_new_connection: initial connect failed


according to /ętc/rc?.d mysql should start before opensips but its not what happens or mysql isn't fully started when opensips starts.



here is a dump of rc for mysql and opensips



lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc0.d/K02mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc1.d/K02mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc2.d/S03mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc3.d/S03mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc4.d/S03mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc5.d/S03mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc6.d/K02mysql -> ../init.d/mysql

############

lrwxrwxrwx 1 root root 18 febr 25 01:17 /etc/rc0.d/K01opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 25 01:17 /etc/rc1.d/K01opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 27 10:40 /etc/rc2.d/S04opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 27 10:40 /etc/rc3.d/S04opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 27 10:40 /etc/rc4.d/S04opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 27 10:40 /etc/rc5.d/S04opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 25 01:17 /etc/rc6.d/K01opensips -> ../init.d/opensips


How can I force openSIPS to wait for mysql?







share|improve this question














I installed and configured openSIPS 2.3 with MySQL on a Debian 8.10 but on boot openSIPS wont start because it starts before MySQL and can't connect to the database. After the system booted up can start opensips without error.



I found what it looked like a solution on an openSIPS mailing list, but I still get the same error.



What I did so far is editing /etc/init.d/opensisp and cahanged init info to this



### BEGIN INIT INFO
# Provides: opensips
# Required-Start: $syslog $network $local_fs $time
# Required-Stop: $syslog $network $local_fs
# Should-Start: mysql #added this
# Should-Stop: mysql #and this
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start the OpenSIPS SIP server
# Description: Start the OpenSIPS SIP server
### END INIT INFO


than I run insserv -v opensips and rebooted, but its the same opensisp fails with couldn't connect to db error



ERROR:db_mysql:db_mysql_connect: driver error(2002): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)
ERROR:db_mysql:db_mysql_new_connection: initial connect failed


according to /ętc/rc?.d mysql should start before opensips but its not what happens or mysql isn't fully started when opensips starts.



here is a dump of rc for mysql and opensips



lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc0.d/K02mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc1.d/K02mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc2.d/S03mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc3.d/S03mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc4.d/S03mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc5.d/S03mysql -> ../init.d/mysql
lrwxrwxrwx 1 root root 15 febr 23 21:56 /etc/rc6.d/K02mysql -> ../init.d/mysql

############

lrwxrwxrwx 1 root root 18 febr 25 01:17 /etc/rc0.d/K01opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 25 01:17 /etc/rc1.d/K01opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 27 10:40 /etc/rc2.d/S04opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 27 10:40 /etc/rc3.d/S04opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 27 10:40 /etc/rc4.d/S04opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 27 10:40 /etc/rc5.d/S04opensips -> ../init.d/opensips
lrwxrwxrwx 1 root root 18 febr 25 01:17 /etc/rc6.d/K01opensips -> ../init.d/opensips


How can I force openSIPS to wait for mysql?









share|improve this question













share|improve this question




share|improve this question








edited Feb 27 at 11:16









Rui F Ribeiro

34.9k1269113




34.9k1269113










asked Feb 27 at 10:36









Laci K

1061




1061











  • Debian 8 does not use sysvinit by default; it uses systemd. Have you configured it to use sysv?
    – Rui F Ribeiro
    Feb 27 at 11:05










  • No, I have not. But if I'm not mistaken insserv should have taken care of the order when I specified should-start in the LSB
    – Laci K
    Feb 27 at 11:16










  • Ok, have edited the sysV out from your question, it is misleading. You are using systemd then. I am not so used to systemd, we will wait someone else to answer you.
    – Rui F Ribeiro
    Feb 27 at 11:17











  • Ok thanks. I probably clicked on it by accident.
    – Laci K
    Feb 27 at 11:22










  • I'd guess mysql will listen last, once started. So what you can do is add somewhere (end of mysql or start of opensips) a loop that does fuser /var/run/mysqld/mysqld.sock . Once it gets a result (and thus a 0 exit status) that means mysql is listening and probably ready to serve requests. Don't make the loop infinite
    – A.B
    Feb 27 at 11:53

















  • Debian 8 does not use sysvinit by default; it uses systemd. Have you configured it to use sysv?
    – Rui F Ribeiro
    Feb 27 at 11:05










  • No, I have not. But if I'm not mistaken insserv should have taken care of the order when I specified should-start in the LSB
    – Laci K
    Feb 27 at 11:16










  • Ok, have edited the sysV out from your question, it is misleading. You are using systemd then. I am not so used to systemd, we will wait someone else to answer you.
    – Rui F Ribeiro
    Feb 27 at 11:17











  • Ok thanks. I probably clicked on it by accident.
    – Laci K
    Feb 27 at 11:22










  • I'd guess mysql will listen last, once started. So what you can do is add somewhere (end of mysql or start of opensips) a loop that does fuser /var/run/mysqld/mysqld.sock . Once it gets a result (and thus a 0 exit status) that means mysql is listening and probably ready to serve requests. Don't make the loop infinite
    – A.B
    Feb 27 at 11:53
















Debian 8 does not use sysvinit by default; it uses systemd. Have you configured it to use sysv?
– Rui F Ribeiro
Feb 27 at 11:05




Debian 8 does not use sysvinit by default; it uses systemd. Have you configured it to use sysv?
– Rui F Ribeiro
Feb 27 at 11:05












No, I have not. But if I'm not mistaken insserv should have taken care of the order when I specified should-start in the LSB
– Laci K
Feb 27 at 11:16




No, I have not. But if I'm not mistaken insserv should have taken care of the order when I specified should-start in the LSB
– Laci K
Feb 27 at 11:16












Ok, have edited the sysV out from your question, it is misleading. You are using systemd then. I am not so used to systemd, we will wait someone else to answer you.
– Rui F Ribeiro
Feb 27 at 11:17





Ok, have edited the sysV out from your question, it is misleading. You are using systemd then. I am not so used to systemd, we will wait someone else to answer you.
– Rui F Ribeiro
Feb 27 at 11:17













Ok thanks. I probably clicked on it by accident.
– Laci K
Feb 27 at 11:22




Ok thanks. I probably clicked on it by accident.
– Laci K
Feb 27 at 11:22












I'd guess mysql will listen last, once started. So what you can do is add somewhere (end of mysql or start of opensips) a loop that does fuser /var/run/mysqld/mysqld.sock . Once it gets a result (and thus a 0 exit status) that means mysql is listening and probably ready to serve requests. Don't make the loop infinite
– A.B
Feb 27 at 11:53





I'd guess mysql will listen last, once started. So what you can do is add somewhere (end of mysql or start of opensips) a loop that does fuser /var/run/mysqld/mysqld.sock . Once it gets a result (and thus a 0 exit status) that means mysql is listening and probably ready to serve requests. Don't make the loop infinite
– A.B
Feb 27 at 11:53
















active

oldest

votes











Your Answer







StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "106"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
convertImagesToLinks: false,
noModals: false,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);








 

draft saved


draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f426903%2fdebian-8-opensips-starts-before-mysql-on-boot-end-exits-with-mysql-error%23new-answer', 'question_page');

);

Post as a guest



































active

oldest

votes













active

oldest

votes









active

oldest

votes






active

oldest

votes










 

draft saved


draft discarded


























 


draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f426903%2fdebian-8-opensips-starts-before-mysql-on-boot-end-exits-with-mysql-error%23new-answer', 'question_page');

);

Post as a guest













































































Popular posts from this blog

Peggy Mitchell

Palaiologos

The Forum (Inglewood, California)