Search the MySQL manual:

4.10 Replication in MySQL

This section describes the various replication features in MySQL. It serves as a reference to the options available with replication. You will be introduced to replication and learn how to implement it. Toward the end, there are some frequently asked questions and descriptions of problems and how to solve them.

We suggest that you visit our website at http://www.mysql.com/ often and read updates to this section. Replication is constantly being improved, and we update the manual frequently with the most current information.

Subsections

User Comments

Posted by [name withheld] on Wednesday December 18 2002, @5:27pm[Delete] [Edit]

Handy mysql log rotation script. For those not
using any chroot environements, comment out both
lines in #chroot section. Set MYSQL_HOME QUERYLOG
SLOWLOG ERRLOG appropiately.


#!/bin/sh
###############################################
# MySQL log rotation
# mjaw@ipartners.pl
###############################################

# chroot
VIRTUAL="/virtual"
VIRTUAL_HOME="${VIRTUAL}/mysql"

# mysql
MYSQL_HOME="${VIRTUAL_HOME}/usr/local/mysql"
DATADIR="${MYSQL_HOME}/var"
LOGDIR="${MYSQL_HOME}/log"
QUERYLOG="${LOGDIR}/querylog"
SLOWLOG="${LOGDIR}/slowlog"
ERRLOG="${LOGDIR}/errlog"

# most universal method for calculating
yesterday's date in YYYYMMDD format
DATE=`/usr/bin/perl -e
"@a=localtime(time-86400);printf('%02d%02d%02d',@a[5]+1900,@a[4]+1,@a[3])"`

PID_FILE=$DATADIR/`/bin/hostname`.pid

if ! [ -s ${PID_FILE} ]; then
echo " Error: pid file not found."
exit 1;
fi

PID=`cat $PID_FILE`

echo -n "Rotating logs: "

if [ -e ${QUERYLOG} ]; then
echo -n "querylog "
/bin/mv ${QUERYLOG} ${QUERYLOG}.${DATE}
fi
if [ -e ${SLOWLOG} ]; then
echo -n "slowlog "
/bin/mv ${SLOWLOG} ${SLOWLOG}.${DATE}
fi
if [ -e ${ERRLOG} ]; then
echo -n "errlog "
/bin/mv ${ERRLOG} ${ERRLOG}.${DATE}
fi

/bin/kill -1 $PID
</PRE>
Run from cron at midnight.

Posted by [name withheld] on Friday May 17 2002, @6:24am[Delete] [Edit]

There is additional information on replication
here:
http://www.phpbuilder.com/columns/tanoviceanu20000
912.php3

Overall the implementation was very easy and
rather smooth.

Posted by [name withheld] on Wednesday January 22 2003, @11:24am[Delete] [Edit]

There is a simple error in the perl date example. The year is not using 4 characters. The line should say
"@a=localtime(time-86400);printf('%04d%02d%02d',@a[5]+1900,@a[4]+1,@a[3])"`

Posted by [name withheld] on Sunday February 23 2003, @5:19am[Delete] [Edit]

there is no need in perl at all. just use 'date' command (man date). example:

DATE=`/bin/date -v -1d '+%Y%m%d'`

Posted by Andres Calderon on Friday March 28 2003, @6:52am[Delete] [Edit]

this is the very long and ugly way:
DATE=`/usr/bin/perl -e @a=localtime(time-86400);printf('%02d%02d%02d',@a[5]+1900,@a[4]+1,@a[3])"`

this is a better form:
DATE=`date --date='1 days ago' +%Y%m%d`

Posted by Kenneth NAvarro on Tuesday May 6 2003, @1:34pm[Delete] [Edit]

Does replication support parallel processing?

Add your own comment.