Skip to content

Commit

Permalink
BUG#19930744 MYSQL /ETC/INIT.D/MYSQLD INIT FILE CHANGES CAUSE BREAKAGES
Browse files Browse the repository at this point in the history
Add support for passing extra options to mysqld during startup by
initscript.

On systemd enabled systems users should set $MYSQLD_OPTS like this:

 systemctl set-environment MYSQLD_OPTS="--foo --bar"

before starting service to pass options to mysqld.

To reset to default, use:

 systemctl unset-environment MYSQLD_OPTS

and restart service.

See #74648 for background.

Patch also switches systemd pre system to use mysqld initialize option.

Signed-off-by: Terje Røsten <terje.rosten@oracle.com>
  • Loading branch information
trosten authored and bkandasa committed Feb 16, 2015
1 parent a5fb74a commit 8be8362
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 7 deletions.
7 changes: 5 additions & 2 deletions packaging/rpm-oel/mysql.init
Expand Up @@ -27,6 +27,9 @@ STOPTIMEOUT=60

lockfile=/var/lock/subsys/$prog

# Support for extra options passed to mysqld
command=$1 && shift
extra_opts="$@"

# extract value of a MySQL option from config files
# Usage: get_mysql_option SECTION VARNAME DEFAULT
Expand Down Expand Up @@ -107,7 +110,7 @@ start(){
# alarms, per bug #547485
$exec --datadir="$datadir" --socket="$socketfile" \
--pid-file="$mypidfile" \
--basedir=/usr --user=mysql >/dev/null 2>&1 &
--basedir=/usr --user=mysql $extra_opts >/dev/null 2>&1 &
safe_pid=$!
# Spin for a maximum of N seconds waiting for the server to come up;
# exit the loop immediately if mysqld_safe process disappears.
Expand Down Expand Up @@ -196,7 +199,7 @@ condrestart(){


# See how we were called.
case "$1" in
case "$command" in
start)
start
;;
Expand Down
8 changes: 6 additions & 2 deletions packaging/rpm-sles/mysql.init
Expand Up @@ -52,6 +52,10 @@ PROG=/usr/bin/mysqld_safe
# Lock directory
lockfile=/var/lock/subsys/mysql

# Support for extra options passed to mysqld
command=$1 && shift
extra_opts="$@"

get_option () {
local section=$1
local option=$2
Expand Down Expand Up @@ -152,7 +156,7 @@ start () {
rc_failed 6 ; rc_status -v ; rc_exit
fi

$PROG --basedir=/usr --datadir="$datadir" --pid-file="$pidfile" >/dev/null 2>&1 &
$PROG --basedir=/usr --datadir="$datadir" --pid-file="$pidfile" $extra_opts >/dev/null 2>&1 &
if pinger $! ; then
echo -n "Starting service MySQL:"
touch $lockfile
Expand Down Expand Up @@ -232,7 +236,7 @@ status () {
rc_status -v
}

case "$1" in
case "$command" in
start ) start ;;
stop ) stop ;;
restart) restart ;;
Expand Down
2 changes: 1 addition & 1 deletion scripts/systemd/mysqld.service.in
Expand Up @@ -39,7 +39,7 @@ PermissionsStartOnly=true
ExecStartPre=@bindir@/mysqld_pre_systemd

# Start main service
ExecStart=@libexecdir@/mysqld --daemonize
ExecStart=@libexecdir@/mysqld --daemonize $MYSQLD_OPTS

# Use this to switch malloc implementation
EnvironmentFile=-/etc/sysconfig/mysql
Expand Down
4 changes: 2 additions & 2 deletions scripts/systemd/mysqld_pre_systemd.in
Expand Up @@ -34,7 +34,7 @@ install_db () {

# Restore log, dir, perms and SELinux contexts

[ -d "$datadir" ] || install -d -m 0755 -o@MYSQLD_USER@ -g@MYSQLD_USER@ "$datadir" || exit 1
[ -d "$datadir" ] || install -d -m 0750 -o@MYSQLD_USER@ -g@MYSQLD_USER@ "$datadir" || exit 1

[ -e $log ] || touch $log
chmod 0640 $log
Expand All @@ -49,7 +49,7 @@ install_db () {
[ -d "$datadir/mysql" ] && exit 0

# Create initial db
@bindir@/mysql_install_db --datadir="$datadir" --user=@MYSQLD_USER@
@libexecdir@/mysqld --initialize --datadir="$datadir" --user=@MYSQLD_USER@
exit 0
}
install_db
Expand Down

0 comments on commit 8be8362

Please sign in to comment.