Wednesday, November 11, 2009

Bus Routes To Stella Mary's College From Saidapet

Change the prompt command line under bash


It is sometimes found in the situation where you have a server that contains a certain amount of data which must be copied at regular intervals on servers "mirrors".
In these scenarios it may be interesting to configure how to use the rsync command (or even set up a rsync server). This utility
 samba project maintained by Wayne Davison is excellent for file transfers in incremental mode. 
There is excellent documentation and many
 examples on the project site 
http://www.samba.org/rsync/
.
If not already present on your box, it can be installed relatively easily on your Linux distribution with adapted tools package (yum install rsync

rpm under fedora & Co, and
apt-get install rsync
for debian, ubuntu and derivatives)
In my case I use it in scripts executed by crontab every night to sync daily over 80 GB of geodata on multiple servers to stop map (mapserver).
On the main server I installed and configured the daemon rsyncd Service (linux)
Here are the contents of my / etc / rsync.conf on the primary server:


///////////////////////// ////////////////////////////////////////////////// ////////////////////////////////////
# / etc / rsyncd.conf
Line Is required by the / etc / init.d / rsyncd script pid file = / var / run / rsyncd. uid = nobody pid

gid = nobody
 pid file = /var/run/rsyncd.pid 
use chroot = no
read only = yes
max connections = 15
log file = /var/log/rsync.log transfer logging = yes
log format = %t %a %o %m %f %b
syslog facility = local3
timeout = 300
dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz *.jpg *.tif
[dataweb]
         path = /data/dataweb 
comment = Calculator dataweb
hosts allow = 192.168.50.12,192.168.50.235,192.168.50.148
[geodata]
path = /data/geodata comment = Calculator geodata
hosts allow = 192.168.50.12,192.168.50.235,192.168.50.148
[goelanddocs]
path = /data/goelanddocs comment = Goeland Documents hosts allow = 192.168.50.12,192.168.50.235,192.168.50.148
[goelandlogs]
path = /backup/weblogs/goeland comment = Goeland Logs hosts allow = 192.168.50.12,192.168.50.235,192.168.50.11,192.168.50.148
 /////////////////////////////////////////////////////////////////////////////////////////////////////////////// 



Typically what is important is to shrink access to IP addresses of servers that must come to synchronize with hosts allow in each section
Another security that I took in my case is that the main server does not expose the writing function (user read only = yes)
 Basically the idea is that we have a section in the directory you want to synchronize with different rights 
From the moment the server running (/ etc / init.d / rsyncd start)
With
netstat-anp
we can verify that the daemon "listens" well on port 873 (usually that is the default)
 
0.0.0.0:873 tcp 0 0 0.0.0.0: * LISTEN 19138/rsync

 
can then go and try to sync from another bike with the rsync command. # / bin / bash RSYNC



= "/ usr / bin / rsync "
LOG =" / root/log/SyncCalculator4.log "


# - Implies-rlptgoD gold archive - recursive - links - perms - times - group - -owner - devices
 
OPTS



= "- verbose - archive - stats - partial - delete - timeout = 300"


SRC1



= "rsync: / / calculator4/dataweb "


DST1

=

"/new_data/calculator4/dataweb"


SRC2

=

"rsync://calculator4/geodata"


DST2

=

"/new_data/calculator4/geodata"



echo



"****Started update at"



`date`


>>
  
${LOG}


2

>&
1
echo "**re-rsyncing the calculator dataweb tree"
>> ${LOG}
2
>& 1 ${RSYNC}
${OPTS}
-- exclude 'phpTempSession/'
${SRC1}
${DST1} >>

${LOG} 2 >& 1 echo "**re-rsyncing the calculator geodata tree" >> ${LOG}
2 >& 1 ${RSYNC} ${OPTS} ${SRC2} ${DST2}
>> ${LOG} 2 >& 1 echo "**End: " `date` >> $ {LOG} 2> & 1
Rsync is a really great tool and that quickly becomes indispensable when one needs to sync large amounts of data and / or on large files. And it must be borne in mind that you can use it without having set up an rsync server on one side of the transfer. Thus, as explained in the rsync man with a simple rsync- avz server1: / data / foo / data / tmp We will recursively transfer all files in the directory / data / foo on server1 in the / data / tmp on the local machine or you execute the command. These files will be transferred in "archive" which ensures that symbolic links, attributes, permissions etc.. be preserved during the transfer. More with the "z" compression will be used to reduce the size of the transfer. But nothing replaces reading the man and to become aware of the many options available such as - exclude = PATTERN that can copy everything except some file types Finally here is the introduction, I hope this gives you want to know more, at least in my case this command is really necessary for me and is found in several of my scripts for data replication. Then "Good discovery!

0 comments:

Post a Comment