0

I used this guide to get started and this wiki page as a reference for the upstart script.

My problem is that when I do a service mysql start I get six processes instead of two, as if upstart ran three times. Here are the processes copied from ps:

/usr/sbin/mysqld --user=root --pid-file=/var/run/mysqld/mysqld1.pid --socket=/var/run/mysqld/mysqld1.sock --port=3301 --basedir=/usr --datadir=/var/lib/mysql1 --tmpdir=/tmp --lc-messages-dir=/usr/share/mysql --skip-external-locking --key_buffer=16M --max_allowed_packet=16M --thread_stack=192K --thread_cache_size=8 --myisam-recover=BACKUP --query_cache_limit=1M --query_cache_size=16M --general_log_file=/var/log/mysql/mysql1-general.log --log_error=/var/log/mysql/error.log --server-id=201 --log_bin=/var/log/mysql/mysql1-bin.log --expire_logs_days=10 --max_binlog_size=100M
/usr/sbin/mysqld --user=root --pid-file=/var/run/mysqld/mysqld2.pid --socket=/var/run/mysqld/mysqld2.sock --port=3302 --basedir=/usr --datadir=/var/lib/mysql2 --tmpdir=/tmp --lc-messages-dir=/usr/share/mysql --skip-external-locking --key_buffer=16M --max_allowed_packet=16M --thread_stack=192K --thread_cache_size=8 --myisam-recover=BACKUP --query_cache_limit=1M --query_cache_size=16M --general_log_file=/var/log/mysql/mysql2-general.log --log_error=/var/log/mysql/error.log --server-id=202 --log_bin=/var/log/mysql/mysql2-bin.log --expire_logs_days=10 --max_binlog_size=100M --innodb_file_per_table --innodb_flush_method=O_DIRECT --innodb_log_file_size=1G --innodb_buffer_pool_size=4G
/usr/sbin/mysqld --user=root --pid-file=/var/run/mysqld/mysqld1.pid --socket=/var/run/mysqld/mysqld1.sock --port=3301 --basedir=/usr --datadir=/var/lib/mysql1 --tmpdir=/tmp --lc-messages-dir=/usr/share/mysql --skip-external-locking --key_buffer=16M --max_allowed_packet=16M --thread_stack=192K --thread_cache_size=8 --myisam-recover=BACKUP --query_cache_limit=1M --query_cache_size=16M --general_log_file=/var/log/mysql/mysql1-general.log --log_error=/var/log/mysql/error.log --server-id=201 --log_bin=/var/log/mysql/mysql1-bin.log --expire_logs_days=10 --max_binlog_size=100M
/usr/sbin/mysqld --user=root --pid-file=/var/run/mysqld/mysqld2.pid --socket=/var/run/mysqld/mysqld2.sock --port=3302 --basedir=/usr --datadir=/var/lib/mysql2 --tmpdir=/tmp --lc-messages-dir=/usr/share/mysql --skip-external-locking --key_buffer=16M --max_allowed_packet=16M --thread_stack=192K --thread_cache_size=8 --myisam-recover=BACKUP --query_cache_limit=1M --query_cache_size=16M --general_log_file=/var/log/mysql/mysql2-general.log --log_error=/var/log/mysql/error.log --server-id=202 --log_bin=/var/log/mysql/mysql2-bin.log --expire_logs_days=10 --max_binlog_size=100M --innodb_file_per_table --innodb_flush_method=O_DIRECT --innodb_log_file_size=1G --innodb_buffer_pool_size=4G
/usr/sbin/mysqld --user=root --pid-file=/var/run/mysqld/mysqld1.pid --socket=/var/run/mysqld/mysqld1.sock --port=3301 --basedir=/usr --datadir=/var/lib/mysql1 --tmpdir=/tmp --lc-messages-dir=/usr/share/mysql --skip-external-locking --key_buffer=16M --max_allowed_packet=16M --thread_stack=192K --thread_cache_size=8 --myisam-recover=BACKUP --query_cache_limit=1M --query_cache_size=16M --general_log_file=/var/log/mysql/mysql1-general.log --log_error=/var/log/mysql/error.log --server-id=201 --log_bin=/var/log/mysql/mysql1-bin.log --expire_logs_days=10 --max_binlog_size=100M
/usr/sbin/mysqld --user=root --pid-file=/var/run/mysqld/mysqld2.pid --socket=/var/run/mysqld/mysqld2.sock --port=3302 --basedir=/usr --datadir=/var/lib/mysql2 --tmpdir=/tmp --lc-messages-dir=/usr/share/mysql --skip-external-locking --key_buffer=16M --max_allowed_packet=16M --thread_stack=192K --thread_cache_size=8 --myisam-recover=BACKUP --query_cache_limit=1M --query_cache_size=16M --general_log_file=/var/log/mysql/mysql2-general.log --log_error=/var/log/mysql/error.log --server-id=202 --log_bin=/var/log/mysql/mysql2-bin.log --expire_logs_days=10 --max_binlog_size=100M --innodb_file_per_table --innodb_flush_method=O_DIRECT --innodb_log_file_size=1G --innodb_buffer_pool_size=4G

This causes the following lines to appear in MySQL's error.log:

InnoDB: Unable to lock ./ibdata1, error: 11

It behaves this way even on reboot. My upstart script for MySQL is standard (as described in the wiki page linked above) except for the "script...end script" section:

script
exec /etc/init.d/mysql start
end script

I have modified the apparmor profile for MySQL and running /etc/init.d/mysql start works correctly.

How can I get upstart to run it's mysql.conf script only once?

2
  • Trying expect fork or expect daemon (as suggested here) causes the service mysql start to hang and the error lines still appear in MySQL's error.log file.
    – jason
    Mar 19, 2013 at 15:12
  • Removing the "post-start script...end script" section of the upstart script causes 11 pairs of mysqld instances to be started.
    – jason
    Mar 19, 2013 at 19:35

1 Answer 1

0

Note: This answer assumes you have read the guide I used to setup mysqld_multi

The answer is to remove the upstart script (/etc/init/mysql.conf in my case). This will allow service mysql [start|stop] to function properly.

You will encounter a problem on reboot, however. When I rebooted the machine Ubuntu was removing the directory where my .sock files were placed (/var/run/mysqld/). Adding the following line to the /etc/init.d/mysql script solved the problem.

[ -d /var/run/mysqld ] || install -m 755 -o mysql -g root -d /var/run/mysqld

I placed the above line between the if..else and the case statements.

Despite adding this line the removal of the upstart script will cause MySQL to not even attempt to start on boot anymore. MySQL must be started manually by issuing the following command once the system is up:

$ sudo service mysql start

However, that seems like a separate question as the above information was able to get mysqld_multi to start two MySQL processes using the service command.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .