Running MySQL in a chroot environment causes problems with the default mysql.server start-up/shut-do

Running MySQL in a chroot environment causes problems with the default mysql.server start-up/shut-do

am 12.04.2003 18:14:17 von David Fletcher

Running MySQL in a chroot environment causes problems with the default
mysql.server start-up/shut-down script.

File layout:

/chroot/mysql contains libraries required for mysqld, basic passwd
files etc, with the databases themselves in
/chroot/mysql/usr/local/mysql/var/

/usr/local/mysql contains the usual install of mysql produced by a
source install under the /usr/local/mysql prefix.

Problem:

my.cnf contains (relevant lines only shown)

[client]
port = 3306
socket = /chroot/mysql/tmp/mysql.sock

[mysqld]
port = 3306
socket = /tmp/mysql.sock
chroot = /chroot/mysql

When mysql.server is used to start mysqld a process id file is
generated by the server INSIDE the chroot environment. When
mysql.server is used to stop the server it looks for the pid file
OUTSIDE the chroot environment, and can't find it because it currently
doesn't know anything about chroot. Therefore, the server cannot be
shut down cleanly.

Resolution:

Add two lines to mysql.server so that the "stop" section is aware of
the change in pid file location. See the patch below. For none chroot
cases the line
chroot=/
could be used, and the script will work as normal.

This really needs to be done within mysql.server.sh, rather than in the
output file of this script.

Patch (for version 4.0.12):

*** mysql.server Wed Apr 9 22:33:51 2003
--- /etc/init.d/mysql Sat Apr 12 16:40:43 2003
***************
*** 46,51 ****
--- 46,52 ----
# Set some defaults
datadir=/usr/local/mysql/var
pid_file=
+ chroot=/chroot/mysql
if test -z "$basedir"
then
basedir=/usr/local/mysql
***************
*** 145,150 ****
--- 146,153 ----
'stop')
# Stop daemon. We use a signal here to avoid having to know the
# root password.
+ pid_file="$chroot$pid_file"
+
if test -s "$pid_file"
then
mysqld_pid=`cat $pid_file`

-----------------------------------------------------

Best wishes,

David Fletcher

david@megapico.co.uk

--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org

Re: Running MySQL in a chroot environment causes problems with the default mysql.server start-up/shu

am 22.04.2003 11:10:00 von Sergei Golubchik

Hi!

On Apr 12, David Fletcher wrote:
> Running MySQL in a chroot environment causes problems with the default
> mysql.server start-up/shut-down script.
>
> Problem:
>
> When mysql.server is used to start mysqld a process id file is
> generated by the server INSIDE the chroot environment. When
> mysql.server is used to stop the server it looks for the pid file
> OUTSIDE the chroot environment, and can't find it because it currently
> doesn't know anything about chroot. Therefore, the server cannot be
> shut down cleanly.

Thanks for catching this.
Will be fixed ASAP.

Regards,
Sergei

--
MySQL Development Team
__ ___ ___ ____ __
/ |/ /_ __/ __/ __ \/ / Sergei Golubchik
/ /|_/ / // /\ \/ /_/ / /__ MySQL AB, http://www.mysql.com/
/_/ /_/\_, /___/\___\_\___/ Osnabrueck, Germany
<___/



--
MySQL Bugs Mailing List
For list archives: http://lists.mysql.com/bugs
To unsubscribe: http://lists.mysql.com/bugs?unsub=gcdmb-bugs@m.gmane.org