LinuxQuestions.org
Go Job Hunting at the LQ Job Marketplace
Go Back   LinuxQuestions.org > Forums > Other *NIX Forums > *BSD
User Name
Password
*BSD This forum is for the discussion of all BSD variants.
FreeBSD, OpenBSD, NetBSD, etc.

Notices

Reply
 
Search this Thread
Old 07-09-2007, 12:08 PM   #1
lord-fu
Member
 
Registered: Apr 2005
Location: Ohio
Distribution: Slackware && freeBSD
Posts: 676

Rep: Reputation: 30
MySQL startup process and my.cnf


Hello and mtia.

6.2
mysql 5.1.19-beta

Could someone verify that I should see these two mysql processes show.

Code:
 ps -aux | grep mysql
mysql   700  0.0  0.3  1728  1316 con- I    12:49PM   0:00.04 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysql/my.cnf --user=mysql --da....
mysql   856  0.0  9.1 84772 35048 con- S    12:49PM   0:00.56 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --dat.......
The reason I ask is because this has been appearing in my logs, even immediately following a reboot.

Code:
070709 12:49:39 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
070709 12:49:39 [ERROR] Do you already have another mysqld server running on port: 3306 ?
070709 12:49:39 [ERROR] Aborting

070709 12:49:39 [Note] /usr/local/libexec/mysqld: ready for connections.
Version: '5.1.19-beta-log'  socket: '/tmp/mysql.sock'  port: 3306  FreeBSD port: mysql-server-5.1.19
070709 12:49:39  InnoDB: Starting shutdown...
070709 12:49:41  InnoDB: Shutdown completed; log sequence number 0 1869387
070709 12:49:41 [Note] /usr/local/libexec/mysqld: Shutdown complete

070709 12:49:41  mysqld ended
So just wondering if any one has come across this before. I don't know why two process would even be trying to start. I have enable in rc.conf.local and a startup script under /usr/local/etc/rc.d/mysql-server.sh, maybe thats wrong as I copied from the work dir in the ports tree.

Code:
#!/bin/sh
#
# $FreeBSD: ports/databases/mysql51-server/files/mysql-server.sh.in,v 1.4 2007/05/20 08:31:37 ale Exp $
#

# PROVIDE: mysql
# REQUIRE: LOGIN
# KEYWORD: shutdown

#
# Add the following line to /etc/rc.conf to enable mysql:
# mysql_enable (bool):  Set to "NO" by default.
#                       Set it to "YES" to enable MySQL.
# mysql_limits (bool):  Set to "NO" by default.
#                       Set it to yes to run `limits -e -U mysql`
#                       just before mysql starts.
# mysql_dbdir (str):    Default to "/var/db/mysql"
#                       Base database directory.
# mysql_args (str):     Custom additional arguments to be passed
#                       to mysqld_safe (default empty).
#

. /etc/rc.subr

name="mysql"
rcvar=`set_rcvar`

load_rc_config $name

: ${mysql_enable="NO"}
: ${mysql_limits="NO"}
: ${mysql_dbdir="/var/db/mysql"}
: ${mysql_args=""}

mysql_user="mysql"
mysql_limits_args="-e -U ${mysql_user}"
pidfile="${mysql_dbdir}/`/bin/hostname`.pid"
command="/usr/local/bin/mysqld_safe"
command_args="--defaults-extra-file=${mysql_dbdir}/my.cnf --user=${mysql_user} --datadir=${mysql_dbdir} --pid-file=${pidfile} ${mysql_args} > /dev/null &"
procname="/usr/local/libexec/mysqld"
start_precmd="${name}_prestart"
mysql_install_db="/usr/local/bin/mysql_install_db"
mysql_install_db_args="--ldata=${mysql_dbdir}"

mysql_create_auth_tables()
{
        eval $mysql_install_db $mysql_install_db_args >/dev/null 2>/dev/null
        [ $? -eq 0 ] && chown -R ${mysql_user}:${mysql_user} ${mysql_dbdir}
}

mysql_prestart()
{
        if [ ! -d "${mysql_dbdir}/mysql/." ]; then
                mysql_create_auth_tables || return 1
        fi
        if checkyesno mysql_limits; then
                eval `/usr/bin/limits ${mysql_limits_args}` 2>/dev/null
        else
                return 0
        fi
}

run_rc_command "$1"
To my semi-trained eyes that looks ok though.

Any help is greatly appreciated. mtia

[edit] sorry about the title did not mean to leave "and my.cnf" in there.
 
Old 07-09-2007, 02:58 PM   #2
da1
Member
 
Registered: May 2007
Distribution: FreeBSD
Posts: 110

Rep: Reputation: 16
first of all did you by any chance install mysql by hand and not through ports ? why don't you install the latest mysql server in ports?

check the firewall, it might block 3306. else use
Code:
lsof -i:3306
to see what is listening to 3306.

as for the startup script here is mine (mysql 5.0.41 installed from ports
Code:
#!/bin/sh
#
# $FreeBSD: ports/databases/mysql50-server/files/mysql-server.sh.in,v 1.3 2006/03/07 16:25:00 ale Exp $
#

# PROVIDE: mysql
# REQUIRE: LOGIN
# KEYWORD: shutdown

#
# Add the following line to /etc/rc.conf to enable mysql:
# mysql_enable (bool):  Set to "NO" by default.
#                       Set it to "YES" to enable MySQL.
# mysql_limits (bool):  Set to "NO" by default.
#                       Set it to yes to run `limits -e -U mysql`
#                       just before mysql starts.
# mysql_dbdir (str):    Default to "/var/db/mysql"
#                       Base database directory.
# mysql_args (str):     Custom additional arguments to be passed
#                       to mysqld_safe (default empty).
#

. /etc/rc.subr

name="mysql"
rcvar=`set_rcvar`

load_rc_config $name

: ${mysql_enable="NO"}
: ${mysql_limits="NO"}
: ${mysql_dbdir="/var/db/mysql"}
: ${mysql_args=""}

mysql_user="mysql"
mysql_limits_args="-e -U ${mysql_user}"
pidfile="${mysql_dbdir}/`/bin/hostname`.pid"
command="/usr/local/bin/mysqld_safe"
command_args="--defaults-extra-file=${mysql_dbdir}/my.cnf --user=${mysql_user} --datadir=${mysql_dbdir} --pid-file=${pidfile} ${mysql_args} > /dev/null &"
procname="/usr/local/libexec/mysqld"
start_precmd="${name}_prestart"
mysql_install_db="/usr/local/bin/mysql_install_db"
mysql_install_db_args="--ldata=${mysql_dbdir}"

mysql_create_auth_tables()
{
        eval $mysql_install_db $mysql_install_db_args >/dev/null
        [ $? -eq 0 ] && chown -R ${mysql_user}:${mysql_user} ${mysql_dbdir}
}

mysql_prestart()
{
        if [ ! -d "${mysql_dbdir}/mysql/." ]; then
                mysql_create_auth_tables || return 1
        fi
        if checkyesno mysql_limits; then
                eval `/usr/bin/limits ${mysql_limits_args}` 2>/dev/null
        else
                return 0
        fi
}

run_rc_command "$1"
don't worry about those 2 line from ps aux|grep mysql, it's normal
look at mine
Code:
root    47885  0.0  0.8  1916   992  p1  S+   10:58PM   0:00.01 grep mysql
root    58921  0.0  0.6  2044   756  p2  I    10:17AM   0:00.03 /bin/sh /usr/local/bin/mysqld_safe --user=mysql
mysql   58936  0.0  4.4 56532  5340  p2  S    10:17AM   2:36.59 /usr/local/libexec/mysqld --basedir=/usr/local --datadir=/var/db/my

Last edited by da1; 07-09-2007 at 03:00 PM.
 
Old 07-09-2007, 03:53 PM   #3
lord-fu
Member
 
Registered: Apr 2005
Location: Ohio
Distribution: Slackware && freeBSD
Posts: 676

Original Poster
Rep: Reputation: 30
Hello and thank you for your reply.

I think you misunderstood my post but more likely I was not verbose enough in my explanation.

I am asking why would mysql (most likely an error on my part) try to start two processes and how could I track them down. During boot up I even get two
starting mysql
messages scroll by, and if I look in my err log I see

Code:
070709 16:40:23 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
070709 16:40:23 [ERROR] Do you already have another mysqld server running on port: 3306 ?
070709 16:40:23 [ERROR] Aborting
However the first process is running and I can connect to it. As shown by ps, lsof, top etc.

Yes I did install from ports, and I may upgrade to the latest available but I would like to fix this first as I am sure it's something small that I did wrong on my end.


Thank you for confirming my ps output.

mtia
 
Old 07-09-2007, 04:00 PM   #4
lord-fu
Member
 
Registered: Apr 2005
Location: Ohio
Distribution: Slackware && freeBSD
Posts: 676

Original Poster
Rep: Reputation: 30
Just for giggles, I used the startup script da1 posted and am seeing the same thing.

Code:
070709 16:54:28  mysqld started
070709 16:54:28  mysqld started
<snip>
070709 16:54:31 [ERROR] Can't start server: Bind on TCP/IP port: Address already in use
070709 16:54:31 [ERROR] Do you already have another mysqld server running on port: 3306 ?
070709 16:54:31 [ERROR] Aborting

070709 16:54:31 [Note] /usr/local/libexec/mysqld: ready for connections.
Version: '5.1.19-beta-log'  socket: '/tmp/mysql.sock'  port: 3306  FreeBSD port: mysql-server-5.1.19
070709 16:54:31  InnoDB: Starting shutdown...
070709 16:54:33  InnoDB: Shutdown completed; log sequence number 0 1869387
070709 16:54:33 [Note] /usr/local/libexec/mysqld: Shutdown complete

070709 16:54:33  mysqld ended
Thanks for reading

[edit]
Ok, gets weirder

Code:
# /usr/local/etc/rc.d/mysql-server.sh stop
mysql not running? (check /var/db/mysql/HOST.DOMAIN.pid).
# ps aux | grep mysql
mysql   700  0.0  0.3  1728  1316 con- I     5:03PM   0:00.04 /bin/sh /usr/local/bin/mysqld_safe --defaults-extra-file=/var/db/mysql/my.cnf --user=mysql --da
mysql   858  0.0  9.2 85284 35416 con- S     5:03PM   0:01.17 /usr/local/libexec/mysqld --defaults-extra-file=/var/db/mysql/my.cnf --basedir=/usr/local --dat
I can connect fine; scratching head

Last edited by lord-fu; 07-09-2007 at 04:34 PM.
 
Old 07-11-2007, 07:44 AM   #5
lord-fu
Member
 
Registered: Apr 2005
Location: Ohio
Distribution: Slackware && freeBSD
Posts: 676

Original Poster
Rep: Reputation: 30
Hello again,

Yesterday I went ahead and recompiled mysql 5.1.20-beta from ports. This time I compiled with LINUX_THREADS and a few other optimizations. I have never compiled with linux threads before, always static. Anyways, I still have two processes trying to start, while the new compile options help me with some other performance issues, I still cannot figure out why 2 mysqld process try to start up.
I also noticed that the startup script that is installed is named mysql-server not mysql-server.sh. I diffed the two and I think I do remember differences being shown, it was late and I was extremely tired. I will do a better comparison later when I get home from work.

Any ideas?

mtia
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
mySQL my.cnf (moving default datadir) not working! madfitz Linux - Newbie 4 02-09-2006 07:15 PM
Setting up the my.cnf for MySQL Server wbuik Linux - Software 1 09-24-2005 04:33 PM
how to config the mysql my.cnf? treotan Linux - General 1 09-14-2005 11:05 AM
MySQL server & my.cnf hct224 Linux - Newbie 0 04-02-2004 01:03 PM
startup process thongor Slackware 2 03-21-2004 10:23 AM


All times are GMT -5. The time now is 12:20 PM.

Main Menu
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration