Bologna Mirroring of Catania Production Status: R. Barbera, M.L. Luvisetto, F. Pierella July 25, 2001
Bologna Mirroring of Catania Production Status: R. Barbera, M.L. Luvisetto, F. Pierella July 25, 2001
1
Chapter 1
db name.contents.gz.
2
1.3 Step 2: Dumping all log files via ftp
In order to dump automatically all log files via ftp we created for our example
the following csh script:
#!/bin/csh
echo "open aliserv2.ct.infn.it \\
user username password \\
bin \\
lcd /home/pierella/public_html/TOFWEB/DBMIRRORING/pprlog \\
cd /home/log \\
mget * \\
quit" | ftp -n -i -v > ftpbarbera.log
3
$myurl="http://aliserv2.ct.infn.it/pprlog/";
into
$myurl="http://bogrid1.bo.infn.it/~pierella/TOFWEB/DBMIRRORING/pprlog/";
• first create the shell script - in our case named mirroring.sh and stored
in /home/pierella/public html/TOFWEB/DBMIRRORING- as reported
below
#!/bin/sh
# go to the working dir
cd /home/pierella/public_html/TOFWEB/DBMIRRORING
# copy the previous version of the database into a save copy named ppr.prev.gz
cp -p ppr.contents.gz ppr.prev.gz
# dumping of the remote DB
mysqldump --host=alipc1.ct.infn.it --user=username \
--password=password ppr | gzip > ppr.contents.gz
# delete the previous outdated DB
mysqladmin drop -f ppr
# recreate another one containing no tables
mysqladmin create ppr
# fill the new DB with the tables of the dumping
gunzip < ppr.contents.gz | mysql ppr
# it is all for database updating, now we transfer the log files
# via ftp and we produce a log file
/home/pierella/private/ftplogsmirror.csh > \
/home/pierella/private/ftplogsmirror.log
• the user must create a crontab entry as follows - in our case it run every
2 hours -
0 0,2,4,6,8,10,12,14,16,18,20,22 * * *
/home/pierella/public_html/newtofwww/DBMIRRORING/mirroring.sh
If more than one site performs the mirroring task, sites may agree on the starting
minute, so that the first field of crontab line may have the following values
4
0 , 30 , 60 , 90
and if 4 sites are mirroring with such different minute values then mirroring is
performed every 30 minutes.