首页 > Linux操作系统 > Linux操作系统 > 使用rsync同步数据
Rsync(Remote Synchronize)是一个远程资料同步工具,可通过LAN/WAN快速同步多台主机,Rsync使用所为的“Rsync演算法”来使本地主机和远程主机之间达到同步,这个演算法并不是每次都整份传送,它只传送两台计算机之间所备份的资料不同的部分,因此速度相当快。
Rsync的优点如下:
rsync官方网站:https://rsync.samba.org 。
yum安装方式: shell> yum install rsync 源码安装方式: shell> tar zxvf rsync-3.1.2.tar.gz shell> cd rsync-3.1.2 shell> ./configure --prefix=/usr shell> make -j4 && make install
rsync的主要有以下三个配置文件:
shell> touch /etc/rsyncd.conf shell> touch /etc/rsyncd.secrets shell> chmod 600 /etc/rsyncd.secrets shell> touch /etc/rsyncd.motd shell> more /etc/rsyncd.conf # This line is required by the /etc/init.d/rsyncd script pid file = /var/run/rsyncd.pid port = 873 address = 10.106.58.172 # 指定同步用户 uid = root gid = root use chroot = yes read only = yes #limit access to private LANs hosts allow=10.106.58.0/255.255.255.0 hosts deny=* max connections = 5 motd file = /etc/rsyncd.motd #This will give you a separate log file log file = /var/log/rsync.log #This will log every file transferred - up to 85,000+ per user, per sync #transfer logging = yes log format = %t %a %m %f %b syslog facility = local3 timeout = 300 # 指定同步模块信息 [test] path = /test list=yes ignore errors auth users = root secrets file = /etc/rsyncd.secrets comment = Test Rsync exclude = data/ rsync密码文件用户名和密码可以随便定义,最好不要和系统帐户一致,同时要把密码文件权限设置为600。 shell> more /etc/rsyncd.secrets root:root123 设定rsync登陆显示信息,可以不设置 shell> more /etc/rsyncd.motd ++++++++++++++++++++++++++++++++++++++++++++++ Welcome to use the rsync services! ++++++++++++++++++++++++++++++++++++++++++++++
A、使用--daemon参数方式启动
shell> /usr/bin/rsync --daemon --config=/etc/rsyncd.conf
B、使用xinetd方式启动
shell> more /etc/xinetd.d/rsync
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = no
flags = IPv6
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
重启xinetd服务
shell> /etc/init.d/xinetd restart
rsync使用测试
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29733787/viewspace-2059495/ ,如需转载,请注明出处,否则将追究法律责任。