Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
MySQL Run Script Weirdness
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Networking & Security
View previous topic :: View next topic  
Author Message
rutski89
Guru
Guru


Joined: 14 Mar 2005
Posts: 468
Location: United States N.Y.

PostPosted: Sat Jul 23, 2005 12:01 am    Post subject: MySQL Run Script Weirdness Reply with quote

/etc/init.d/mysql is acting very strangely on a fresh mysql (4.0.25-r2). I've tried to install the stable version as well, but I get the same nonsense.

Floow along and you'll see what I mean.

No previous instances of mysql are running:
Code:

localhost mysql # ps -A | grep sql
localhost mysql #


When I run the mysql init script I get a failed symbol, with only a reference to /etc/mysql/my.cnf; this isn't very useful debugging info...
Code:

localhost mysql # /etc/init.d/mysql start
 * Caching service dependencies ...                                                                                              [ ok ]
 * Starting mysqld (/etc/mysql/my.cnf) ...                                                                                       [ !! ]
localhost mysql #


So, I go check out the logs; again, not very much useful debugging info.
Code:

localhost mysql # pwd
/var/log/mysql
localhost mysql # ls
mysql.err  mysqld.err
localhost mysql # cat mysql.err
050722 19:41:24  mysqld started
localhost mysql # cat mysqld.err
050722 19:41:24  InnoDB: Database was not shut down normally.
InnoDB: Starting recovery from log files...
InnoDB: Starting log scan based on checkpoint at
InnoDB: log sequence number 0 43892
InnoDB: Doing recovery: scanned up to log sequence number 0 43892
050722 19:41:24  InnoDB: Flushing modified pages from the buffer pool...
050722 19:41:24  InnoDB: Started
/usr/sbin/mysqld: ready for connections.
Version: '4.0.25'  socket: '/var/run/mysqld/mysqld.sock'  port: 3306  Gentoo Linux mysql-4.0.25-r2
localhost mysql #


There's probably no debugging useful debugging info because mysql started just fine :roll:

Code:

localhost mysql # ps -A | grep mysql
  909 ?        00:00:00 mysqld_safe
  948 ?        00:00:00 mysqld
localhost mysql #


I can connect to mysql without issue as well:
Code:

localhost mysql # mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 3 to server version: 4.0.25

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql> quit
Bye
localhost mysql #


I might be inclined to not care and just continue development; but....

Code:

localhost mysql # /etc/init.d/mysql stop
 * ERROR:  "mysql" has not yet been started.
localhost mysql #


The fact that I can't use the runscript to stop the proess gets to me... I'm itching to fix this.

Here is the /etc/mysql/my.cnf file with comments grep'd out:

Code:

localhost mysql # grep -v '^#' /etc/mysql/my.cnf

[client]
port            = 3306
socket          = /var/run/mysqld/mysqld.sock

[safe_mysqld]
err-log         = /var/log/mysql/mysql.err

[mysqld]
user            = mysql
pid-file        = /var/run/mysqld/mysqld.pid
socket          = /var/run/mysqld/mysqld.sock
log-error       = /var/log/mysql/mysqld.err
basedir         = /usr
datadir         = /var/lib/mysql
tmpdir          = /tmp
language        = /usr/share/mysql/english
skip-locking
set-variable    = key_buffer=16M
set-variable    = max_allowed_packet=1M
set-variable    = thread_stack=128K
bind-address    = 127.0.0.1
port            = 3306
set-variable = innodb_buffer_pool_size=32M
set-variable = innodb_additional_mem_pool_size=1M
innodb_data_home_dir = /var/lib/mysql/
innodb_log_arch_dir = /var/lib/mysql/
innodb_log_group_home_dir = /var/lib/mysql/
innodb_data_file_path = ibdata1:10M:autoextend:max:128M
set-variable = innodb_log_file_size=8M
set-variable = innodb_log_buffer_size=1M
set-variable = innodb_log_files_in_group=2
innodb_flush_log_at_trx_commit=1


[mysqldump]
quick
set-variable    = max_allowed_packet=1M

[mysql]

[isamchk]
set-variable    = key_buffer=16M
localhost mysql #   


Here is the run script in question. Also, before installing mysql, I made sure that there was no previous /etc/init.d/mysql file; so, this is surly the runscript created by the fresh mysql-4.0.25-r2 emerge.

Code:
localhost mysql # cat /etc/init.d/mysql
#!/sbin/runscript
# Copyright 1999-2004 Gentoo Foundation
# Distributed under the terms of the GNU General Public License v2
# $Header: /var/cvsroot/gentoo-x86/dev-db/mysql/files/mysql-4.0.24-r2.rc6,v 1.1 2005/05/17 09:08:46 robbat2 Exp $

depend() {
        use dns net
}

getconfig() {
        MY_CNF=${MY_CNF=/etc/mysql/my.cnf}
        if [ ! -f ${MY_CNF} ]; then
                eerror "No ${MY_CNF} file exists! Using automatic defaults!"
        fi

        #dir=`my_print_defaults mysqld | grep -- '^--datadir' | tail -n1 | sed -e 's|^--datadir=||'`
        #dir=`my_print_defaults mysqld | sed -ne '/datadir/s|^--datadir=||p' | tail -n1`
        local mysqld_cnf="`my_print_defaults --config-file=${MY_CNF} mysqld`"
        datadir=`echo "${mysqld_cnf}" | sed -ne '/datadir/s|^--datadir=||p' | tail -n1`
        pidfile=`echo "${mysqld_cnf}" | sed -ne '/pid-file/s|^--pid-file=||p' | tail -n1`
        basedir=`echo "${mysqld_cnf}" | sed -ne '/basedir/s|^--basedir=||p' | tail -n1`
        socket=`echo "${mysqld_cnf}" | sed -ne '/socket/s|^--socket=||p' | tail -n1`

        # push these out to the script
        export MY_CNF
        export pidfile
        export datadir
        export basedir
        export socket
}

checkconfig() {
        getconfig
        if [ -z "${datadir}" ]; then
                eerror "Your mysql doesn't have any datadir setting, default or specific"
                eerror "Please check your my.cnf : ${MY_CNF}"
                return 1
        fi

        if [ ! -d "$datadir/mysql" ]; then
                eerror "You don't appear to have the mysql database installed yet."
                eerror "Please run /usr/bin/mysql_install_db to have this done..."
                return 1
        fi
}

start() {
        local retstatus=1
        local maxtry=5
        getconfig
        checkconfig || return 1
        ebegin "Starting mysqld (${MY_CNF})"
        start-stop-daemon --start --quiet --background \
                --exec "${basedir}/bin/mysqld_safe" \
                -- --defaults-file=${MY_CNF} >/dev/null 2>&1
        retstatus=$?
        while ! [[ -S "${socket}" || "${maxtry}" -lt "1" || "${retstatus}" -gt "0" ]] ; do
                maxtry=$(($maxtry-1))
                echo -n "."
                sleep 1
        done
        ! [[ -S "${socket}" ]] && eerror "MySQL NOT started, proceding anyway"
        eend $retstatus
}

stop () {
        getconfig
        ebegin "Stopping mysqld (${MY_CNF})"
        start-stop-daemon --stop --retry 5 --quiet --pidfile=${pidfile}
        eend $?
}
localhost mysql #         


I really hope that someone can help me fix this.
_________________
<< ^ | ~ >>
Back to top
View user's profile Send private message
bju
n00b
n00b


Joined: 09 Oct 2004
Posts: 17
Location: Germany

PostPosted: Sat Jul 23, 2005 2:12 pm    Post subject: Reply with quote

Hi,

I had the same problem now I rebooted my pc :-(

The problem is the way start-stop-daemon (called from /etc/init.d/mysql) is working. This function starts the given program (/usr/bin/mysqld_safe). After this the existence of some process named /usr/bin/mysqld_safe is checked using /usr/bin/pidof.

And now the trouble goes on. mysqld_safe isn't a ELF binary but a bash script. This is started using "/bin/bash /usr/bin/mysqld_safe". To bring pidof to find mysqld_safe the command line switch -x is needed.

I've changed line 175 in /lib/rcscripts/sh/rc-daemon.sh:

Old:
Code:

eval /bin/pidof "${args}"


New:
Code:

eval /bin/pidof -x "${args}"


I don't know wheter baselayout or mysql changes are guilty ...

Have fun,
Bernd

Update: With the last version of baselayout the bug doesn't exist anymore :-)
_________________
The advertisement is the most truthful part of a newspaper.
-- Thomas Jefferson
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Networking & Security All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum