How to start mysql at boot time? - BSD

This is a discussion on How to start mysql at boot time? - BSD ; I'm new to OpenBSD. I installed 3.7 on a small, embedded computer (a Soekris). I want to run a variety of things and figured this would be a good opportunity to learn more about OpenBSD. Anyway - how do I ...

+ Reply to Thread
Results 1 to 12 of 12

Thread: How to start mysql at boot time?

  1. How to start mysql at boot time?

    I'm new to OpenBSD. I installed 3.7 on a small, embedded computer (a
    Soekris). I want to run a variety of things and figured this would be
    a good opportunity to learn more about OpenBSD.

    Anyway - how do I configure mysql to start when I boot?

    I've read a bunch of messages on the topic but nothing seems definitive
    - and every post has a different way of doing it. (Though roughly the
    same concept.) What is the "official way" (if there is such a thing)
    for OpenBSD 3.7?


  2. Re: How to start mysql at boot time?

    blixel@gmail.com wrote:
    > I've read a bunch of messages on the topic but nothing seems
    > definitive - and every post has a different way of doing it. (Though
    > roughly the same concept.) What is the "official way" (if there is
    > such a thing) for OpenBSD 3.7?


    I don't know about "official" way, but my way is putting the following into
    /etc/rc.local:

    if [ X"${mysql}" != X"NO" -a -x /usr/local/share/mysql/mysql.server ] ; then
    echo -n " mysqld"; /usr/local/share/mysql/mysql.server start
    /bin/sleep 1
    fi

    Also, you will need to put a line with "mysql=YES" into /etc/rc.conf.local.


    I'm still at 3.6, though, so you _may_ need a few modifications to get it
    running under 3.7. But I doubt it.



  3. Re: How to start mysql at boot time?

    Thanks. That seems to work - though I don't entirely understand it.

    I understand that the first line is checking to make sure mysql.server
    is executable and checking to make sure that mysql=YES in
    /etc/rc.conf.local ... but how does it "know" what the value of mysql
    is? The /etc/rc.local script doesn't seem to import /etc/rc.conf.local
    .... I can only assume the values are read into memory during the boot
    process and are stored globally until the boot process is finished?

    The second line is also unfamiliar to me. It looks like it's running
    the script to start the mysql server and passing the user mysqld to the
    script so that the script will run as that user. However, I don't have
    a mysqld user in my /etc/passwd. There IS a _mysql user in
    /etc/passwd. And when I run "ps aux | grep mysql", I can see that the
    mysql server is running as _mysql (not as mysqld) - weird. I guess
    echo -n " mysqld" is a parameter other than the user to run as.


  4. Re: How to start mysql at boot time?

    On 2005-06-15, blixel@gmail.com wrote:
    > Thanks. That seems to work - though I don't entirely understand it.
    >
    > I understand that the first line is checking to make sure mysql.server
    > is executable and checking to make sure that mysql=YES in
    > /etc/rc.conf.local ... but how does it "know" what the value of mysql
    > is? The /etc/rc.local script doesn't seem to import /etc/rc.conf.local
    > ... I can only assume the values are read into memory during the boot
    > process and are stored globally until the boot process is finished?


    $ grep rc.conf.local /etc/*
    grep: /etc/bgpd.conf: Permission denied
    /etc/changelist:/etc/rc.conf.local
    grep: /etc/hosts.equiv: Permission denied
    grep: /etc/master.passwd: Permission denied
    grep: /etc/pf.conf: Permission denied
    /etc/rc.conf:local_rcconf="/etc/rc.conf.local"
    grep: /etc/spwd.db: Permission denied

    $ grep local_rcconf /etc/rc.conf
    local_rcconf="/etc/rc.conf.local"
    [ -f ${local_rcconf} ] && . ${local_rcconf} # Do not edit this line

    I'll leave it as an exercise for the reader to figure out which /etc
    scripts load rc.conf

    --
    ratfood@food.skaterat.net
    All foods should be removed to reply

  5. Re: How to start mysql at boot time?

    On 15 Jun 2005 07:10:52 -0700, blixel@gmail.com wrote:
    > Thanks. That seems to work - though I don't entirely understand it.
    >
    > I understand that the first line is checking to make sure mysql.server
    > is executable and checking to make sure that mysql=YES in
    > /etc/rc.conf.local ... but how does it "know" what the value of mysql
    > is? The /etc/rc.local script doesn't seem to import /etc/rc.conf.local
    > ... I can only assume the values are read into memory during the boot
    > process and are stored globally until the boot process is finished?


    /etc/rc reads /etc/rc.conf which then reads /etc.rc.conf.local. After
    finishing the default stuff, /etc/rc runs /etc/rc.local. Because rc runs
    rc.local, rc.local inherits the same values in rc.conf and rc.conf.local.
    That's how mysql=YES gets to rc.local.

    > The second line is also unfamiliar to me. It looks like it's running
    > the script to start the mysql server and passing the user mysqld to the
    > script so that the script will run as that user. However, I don't have
    > a mysqld user in my /etc/passwd. There IS a _mysql user in
    > /etc/passwd. And when I run "ps aux | grep mysql", I can see that the
    > mysql server is running as _mysql (not as mysqld) - weird. I guess
    > echo -n " mysqld" is a parameter other than the user to run as.


    The echo just prints " mysqld" to the console during bootup. Next time
    you boot, look for something like "starting local services: mysql." The
    echo -n is what puts the string "mysql" there. The echo and the
    mysql.server start are separated by a ';' which means they are two
    independent commands.



  6. Re: How to start mysql at boot time?

    On Tue, 14 Jun 2005 22:14:05 -0700, blixe wrote:

    > I'm new to OpenBSD. I installed 3.7 on a small, embedded computer (a
    > Soekris). I want to run a variety of things and figured this would be
    > a good opportunity to learn more about OpenBSD.
    >
    > Anyway - how do I configure mysql to start when I boot?


    If you installed mysql from an OpenBSD binary package the install scripts
    would have modified /etc/rc.local, /etc/rc.conf.local and
    /etc/rc.shutdown. You might make sure that /etc/rc.conf.local contains
    mysql=YES




  7. Re: How to start mysql at boot time?

    On Wed, 15 Jun 2005 11:53:16 -0500, Dave Uhring wrote:
    > On Tue, 14 Jun 2005 22:14:05 -0700, blixe wrote:
    >
    >> I'm new to OpenBSD. I installed 3.7 on a small, embedded computer (a
    >> Soekris). I want to run a variety of things and figured this would be
    >> a good opportunity to learn more about OpenBSD.
    >>
    >> Anyway - how do I configure mysql to start when I boot?

    >
    > If you installed mysql from an OpenBSD binary package the install scripts
    > would have modified /etc/rc.local, /etc/rc.conf.local and
    > /etc/rc.shutdown. You might make sure that /etc/rc.conf.local contains
    > mysql=YES


    The mysql-server package on 3.7 does not modify any of those files.

  8. Re: How to start mysql at boot time?

    On Wed, 15 Jun 2005 16:40:31 -0500, Shane Almeida wrote:

    > The mysql-server package on 3.7 does not modify any of those files.


    You are correct. My original installation was on 3.5 which was then
    updated to 3.6 then 3.7.

    The files which need to be modified are /etc/rc.local and
    /etc/rc.shutdown:

    For /etc/rc.local append the following line:

    echo -n " mysqld"; /usr/local/share/mysql/mysql.server start

    and for /etc/rc.shutdown append this:

    /usr/local/share/mysql/mysql.server stop


  9. Re: How to start mysql at boot time?

    > Anyway - how do I configure mysql to start when I boot?
    >
    > I've read a bunch of messages on the topic but nothing seems definitive
    > - and every post has a different way of doing it. (Though roughly the
    > same concept.) What is the "official way" (if there is such a thing)
    > for OpenBSD 3.7?


    $ ftp "ftp://ftp.openbsd.org/pub/OpenBSD/`uname -r`/packages/`uname -m`/"
    ftp> mget mysql-*
    $ sudo pkg_add mysql*
    $ sudo vi /etc/rc.local

    -- add this to /etc/rc.local --
    ### MySQL ###
    if [ -x /usr/local/share/mysql/mysql.server ]; then
    echo 'Starting MySQL'
    /usr/local/share/mysql/mysql.server start >/dev/null 2>&1
    fi
    -- add this to /etc/rc.local --

    Voila !
    If this is the official way ?
    It's my way, oh yes thats official around here )

    -Bas



  10. Re: How to start mysql at boot time?

    On Thu, 16 Jun 2005 20:05:03 +0200, Bas Keur wrote:

    > -- add this to /etc/rc.local --
    > ### MySQL ###
    > if [ -x /usr/local/share/mysql/mysql.server ]; then
    > echo 'Starting MySQL'
    > /usr/local/share/mysql/mysql.server start >/dev/null 2>&1
    > fi
    > -- add this to /etc/rc.local --
    >
    > Voila !
    > If this is the official way ?
    > It's my way, oh yes thats official around here )


    You also need a line in /etc/rc.shutdown to stop the mysql server cleanly.
    Unless you want to risk corruption of your databases.


  11. Re: How to start mysql at boot time?

    >> Voila !
    >> If this is the official way ?
    >> It's my way, oh yes thats official around here )

    >
    > You also need a line in /etc/rc.shutdown to stop the mysql server cleanly.
    > Unless you want to risk corruption of your databases.


    Now thats a very good point indeed.
    However, if for some reason (ex. power surge) the system is kicked
    down, i always have to do a `mysqlcheck -uxxx -pxxx -A` and pray
    i don't have to do a drop/create / mysql db < /backup/db.sql

    (note: cron backup 2 times a days keeps bad karma away)

    BUT..... when i do a `reboot` ... i never ever had any corruption...
    Which leaves me 2 options. Correct me if i'm wrong.

    1: If a deamon makes a pid file, it wil be stopped anyway..... ?
    2: The `reboot` sync's the fs, so i was lucky no corruption ever happend due
    reboot.

    Either way, i'll use the rc.shutdown also from now on

    -Bas



  12. Re: How to start mysql at boot time?

    On Thu, 16 Jun 2005 21:17:14 +0200, Bas Keur wrote:

    > Now thats a very good point indeed.
    > However, if for some reason (ex. power surge) the system is kicked
    > down, i always have to do a `mysqlcheck -uxxx -pxxx -A` and pray
    > i don't have to do a drop/create / mysql db < /backup/db.sql
    >
    > (note: cron backup 2 times a days keeps bad karma away)


    A UPS is a better solution :-)

    > BUT..... when i do a `reboot` ... i never ever had any corruption...
    > Which leaves me 2 options. Correct me if i'm wrong.
    >
    > 1: If a deamon makes a pid file, it wil be stopped anyway..... ?
    > 2: The `reboot` sync's the fs, so i was lucky no corruption ever happend due
    > reboot.


    Pending operations within the database may not have completed in the case
    of a reboot without having shut down the daemon. When you executed your
    reboots the daemon had probably been idle.

    Checking the mysql.server script it appears that a kill $mysqld_pid is
    executed then wait for the daemon to remove the PID.

    > Either way, i'll use the rc.shutdown also from now on


    Much safer, IMHO.


+ Reply to Thread