Monday, August 21, 2006

I recommend putting this in your mysql init scripts


'stop')

echo -n 'Are you sure? (y|N)';
read SANITYCHECK;
if [ $SANITYCHECK != 'y' ]; then
echo "EXITING INPUT NOT y";
exit 1;
fi



Why? Well imagine you have 20 servers running mysql for the site. You spent 100K to get these servers redundant, automatically failover if a few go down-which gets the company a High Availability score of 99.999% in the database backend and then someone runs

dsh -N ALL_MY_DB_SERVERS /etc/init.d/mysql restart

when the intention was to restart another process like say the monitoring process.



DOH!!

4 comments:

Anonymous said...

Would not that break init scripts ?

But I see what you're saying :)

In general it is the hardest thing to protect - user error.

Dathan Pattishall said...

Yes it does break init scripts, so one can't just reboot a box without shutting down mysql 1st.

Also put the code in this block

# Stop daemon. We use a signal here to avoid having to know the
# root password.
if test -s "$pid_file"
then

Insert code here

##


It is a trade off maybe make another init script called system_mysql which will actually follow the init process.

It's a tough call but I can live without a proper shutdown command :)

Dathan Pattishall said...

It will stop me from restarting all the mysql servers at the same time when I ment to restart another service.

This is ment to be a funny insite into user error.

Anonymous said...

There isn't anything to check for a standard system shutdown.

...obviously, that is suboptimal, because init will wait a bit, then shut it down anyways, issuing kill commands. And if mysql can't dump its pending writes cache to disk fast enough, the processes are terminated anyways and the system is shut down...with potential table corruption, filesystem corruption and/or data loss.