WelcomeWelcome | FAQFAQ | DownloadsDownloads | WikiWiki

Author Topic: Some questions to mysql  (Read 2622 times)

Offline TaoTePuh

  • Full Member
  • ***
  • Posts: 172
Some questions to mysql
« on: August 15, 2010, 10:16:29 AM »
1.) mysqld starts automatically

Why does mysql start automatically after it is loaded? This happens while booting but before mydata.tgz is restored. This daemon is not useful in this form.

Okay, I can fix this in the bootlocal

Code: [Select]
mysqladmin --user=root shutdown
sudo /usr/local/bin/mysqld_multi start 1

but I wonder if I did not understand the trick? Presumably, it only makes sense if one has made /usr/local/var/mysql/ persistent.

2.) backup/shutdown strategy

I wonder how I can shut down the computer safely and without data loss in processes such as mysql, apache ...

An entry in the file /opt/bootlocal.sh like :

Code: [Select]
apachectl -k stop
mysqladmin --user=root --password=PASSWORD shutdown

does not make sense, since it is performed only after the backup.

Is there a script that runs before the backup and where can I stop processes like apache, mysql ... and sync the filesystem?

Tao

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 13848
Re: Some questions to mysql
« Reply #1 on: August 15, 2010, 10:58:52 AM »
mysqld starts automatically

I'm not at a tc machine at the moment, but this is probably due to a start-up script. Have a look in /usr/local/tc.installed/mysql to see if it is a script.

Offline TaoTePuh

  • Full Member
  • ***
  • Posts: 172
Re: Some questions to mysql
« Reply #2 on: August 15, 2010, 11:17:46 AM »
Yes, the script is there and it starts mysqld, but IMHO it starts mysqld too early (before mydata.tgz was restored).

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10666
Re: Some questions to mysql
« Reply #3 on: August 15, 2010, 11:34:05 AM »
/opt/shutdown.sh is for user commands on shutdown [ edit: when activated via the gui, or via exitcheck.sh from the cli ]. Syncing happens as a part of a normal shutdown.
The only barriers that can stop you are the ones you create yourself.

Offline TaoTePuh

  • Full Member
  • ***
  • Posts: 172
Re: Some questions to mysql
« Reply #4 on: August 15, 2010, 12:00:00 PM »
The script shutdown.sh will start after the backup :

sync / backup
exec /opt/shutdown.sh
shutdown system

If in the time between backup and shutdown are still open connections (mysql, apache), the data are gone.

The strategy should also be

stop processes (daemons)
sync / backup
exec /opt/shutdown.sh
shutdown

But how automate this? I have not found a script that runs before the backup.

Offline Juanito

  • Administrator
  • Hero Member
  • *****
  • Posts: 13848
Re: Some questions to mysql
« Reply #5 on: August 15, 2010, 12:17:14 PM »
Yes, the script is there and it starts mysqld, but IMHO it starts mysqld too early (before mydata.tgz was restored).

As a quick fix you could edit the extension and start the daemon via bootlocal.sh

Offline curaga

  • Administrator
  • Hero Member
  • *****
  • Posts: 10666
Re: Some questions to mysql
« Reply #6 on: August 15, 2010, 12:22:53 PM »
I assume you're shutting down from the gui? You could just remove the backup tick (edit .profile to make it persist), and have backup happen in shutdown.sh after your daemons have shut down.

Quote
#!/bin/sh
# put user shutdown commands here

apachectl -k stop
mysqladmin --user=root --password=PASSWORD shutdown

sync

filetool.sh backup noprompt

# If no backup of home was done then loop through valid users to clean up.
...


As a side note, it's an interesting choice to keep the web data and database in ram instead of storage. I suppose longer boot and shutdown, and the size limit are acceptable for the much better performance.
The only barriers that can stop you are the ones you create yourself.

Offline TaoTePuh

  • Full Member
  • ***
  • Posts: 172
Re: Some questions to mysql
« Reply #7 on: August 15, 2010, 01:34:16 PM »
@Juanito
Quote
As a quick fix you could edit the extension and start the daemon via bootlocal.sh

I have been thinking about it already. But then I did the following simple solution:

/opt/bootlocal.sh :
Code: [Select]
mysqladmin --user=root shutdown
sudo /usr/local/bin/mysqld_multi start 1

@curaga

Quote
You could just remove the backup tick (edit .profile to make it persist), and have backup happen in shutdown.sh after your daemons have shut down.

Chapeau!

A very smart idea ... und there is my tiny SysVinit 0/6 ...

Quote
As a side note, it's an interesting choice to keep the web data and database in ram instead of storage. I suppose longer boot and shutdown, and the size limit are acceptable for the much better performance.

I need apache and mysql really only for a mpd/ampache installation. It runs very well in RAM on a Pentium M 850MHz and the backup does not take long (ampache ~ 2MB).

But after I had 30.000+ files indexed ... oops ... /usr/local/var/mysql in now persistent ...