Pages

Thursday, December 12, 2013

Synchronize file dengan menggunakan rsync pada linux


Rsync ini melakukan transfer data dati satu server ke server lain dengan cukup menakjubkan,
anda dapat menggunakan aplikasi sync untuk keperluan backups server website , dan lebih daripada itu.
Aplikasi ini cepat dan tidak membutuhkan bandwidth yang tinggi hanya seperti  anda melakukan copy data secara normal .
saya pikir ini pilihan terbaik, Selamat datang pada dunia rsync yang luar biasa.

sebelumnya kita harus menyediakan 2 server linux, yang saya gunakan linux Centos 6.4 dan dengan linux ubuntu.
yang saya ininkan adalah data pada server centos di syngkronize dg server ubuntu.


Berikut ini Cata instalnya:

Settingan pada server linux tujian (centos):

install rsync :
# yum -y install rsync xinetd
# vi /etc/xinetd.d/rsync



Rubah datanya menjadi
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
#allows crc checksumming etc.

service rsync
{
disable= no  #rubah jadi no
flags= IPv6  #rubah jadi IPv6 atau IPv4
socket_type= stream
wait= no
user= root
server= /usr/bin/rsync
server_args= --daemon
log_on_failure+= USERID
}



start service :
# /etc/rc.d/init.d/xinetd start

set auto runing when booting linux :
# chkconfig xinetd on

Ckreate directory
# mkdir /home/kusdi/rsync

Edit rsync.conf
# vi /etc/rsyncd.conf

# any name you like
[site]
# destination directory
path = /home/kusdi/rsync
# Hosts you allow to copy (specify source Host)
hosts allow = 192.9.18.27
hosts deny = *
list = true
uid = root
gid = root
read only = false




Setingan server ubuntu :
Instal rsync:
$sudo apt-get install rsync

Start rsync :
$sudo /etc/init.d/rsync start

Lakukan sinkron data :
$sudo rsync -az --delete /home/kusdi/rsync/ 192.9.18.10:/home/kusdi/rsync


apabila sinkron data dilakukan di job
anda bisa menggunakan cron job:
$sudo crontab -e

tambahkan job dibawah ini dibagian bawahnya, sehingga menjadi seperti ini :

# Edit this file to introduce tasks to be run by cron.
#
# Each task to run has to be defined through a single line
# indicating with different fields when the task will be run
# and what command to run for the task
#
# To define the time you can provide concrete values for
# minute (m), hour (h), day of month (dom), month (mon),
# and day of week (dow) or use '*' in these fields (for 'any').#
# Notice that tasks will be started based on the cron's system
# daemon's notion of time and timezones.
#
# Output of the crontab jobs (including errors) is sent through
# email to the user the crontab file belongs to (unless redirected).
#
# For example, you can run a backup of all your user accounts
# at 5 a.m every week with:
# 0 5 * * 1 tar -zcf /var/backups/home.tgz /home/
#
# For more information see the manual pages of crontab(5) and cron(8)
#
# m h  dom mon dow   comman

0 * * * * rsync -az --delete /home/kusdi/rsync/ 192.9.18.10:/home/kusdi/rsync



simpan dengan menekan tombol Esc :wq

ket:
artinya setiap jam dilakukan sinkron data andara server centos dan ubuntu.







No comments:

Post a Comment