Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

Has anyone got multiple MySQL instances running on Debian with mysqlmanager? Problem is, Debian doesn't ship with init.d script that takes mysqlmanager into account. Oh, and it doesn't work for me.

I'm trying to run 3 instances, here's what I get after starting mysqlmanager

# mysqlmanager --defaults-file=/etc/mysql/my.cnf
...
090614  0:42:10 starting instance 'mysqld2'...
090614  0:42:10 guardian: starting instance 'mysqld1'...
090614  0:42:10 starting instance 'mysqld1'...
090614  0:42:10 starting instance 'mysqld3'...
090614  0:42:10 guardian: starting instance 'mysqld3'...
090614  0:42:10 guardian: starting instance 'mysqld2'...
090614  0:42:10 starting instance 'mysqld2'...
090614  0:42:10 guardian: starting instance 'mysqld1'...
090614  0:42:10 starting instance 'mysqld1'...
...

It just keeps "starting" and "restarting", but no MySQL instance ever starts up.

share|improve this question

2 Answers 2

Maybe using mysqld_multi will be easier method? I have analyzed the service script in SLES and I see that if you set in:

/etc/sysconfig/mysql

option:

MYSQLD_MULTI="no"

to "yes" than the regular daemon isn't starting the server, but it is calling mysqld_multi daemon.

I regret because this method isn't implemented in Debian, but I am sure that if you modify mysql service script and add declaration for using mysqld_multi daemon, then you will have fully functional server with multiple instances.

Regards, Vlado

share|improve this answer
up vote 2 down vote accepted

Answering my own question:

mysqld was restarting because of permission issues, executing

# chmod -R mysql:root /var/lib/mysql

fixed that. Previously the dir was owned by mysql:mysql.

Regarding mysqlmanager startup script, I've managed to hack an ugly solution, works for me, feel free to edit and use if you need it too:

#!/bin/bash
#
set -e
set -u
${DEBIAN_SCRIPT_DEBUG:+ set -v -x}

test -x /usr/sbin/mysqld || exit 0

. /lib/lsb/init-functions

SELF=$(cd $(dirname $0); pwd -P)/$(basename $0)
USER=mysql
PID_FILE=/var/run/mysqld/manager.pid

mysqlmanager_get_pid(){
    FAIL_PID=-1

    if [ ! -f $PID_FILE ] ; then
        # Attempt to find it by process name
        PROCESS=`ps -ef | grep -v grep | grep mysqlmanager`
        if [ ! $PROCESS ] ; then
            return $FAIL_PID
        else
            return $PROCESS
        fi
    else
        PID=`cat $PID_FILE`
        PROCESS=`ps -ef | grep -v grep | grep -c $PID`
        if [ ! $PROCESS ] ; then
            return $FAIL_PID
        else
            return $PROCESS
        fi
    fi
}

case "${1:-''}" in
  'start')
        if ! mysqlmanager_get_pid; then
            /usr/sbin/mysqlmanager --defaults-file=/etc/mysql/my.cnf --run-as-service
        else
            echo "error: mysqlmanager already running"
        fi
        ;;

  'stop')
        # I'm too lazy to make this any more intelligent
        killall -1 mysqlmanager
        killall -1 mysqld
        ;;

  'restart')
        set +e; $SELF stop; set -e
        $SELF start
        ;;

  *)
        echo "Usage: $SELF start|stop|restart"
        exit 1
        ;;
esac

Just drop that into /etc/init.d/mysql (move the original mysql script out of there),

Make it executable

# chmod +x /etc/init.d/mysql

And it should work.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.