CentOS 6 rsync 文件同步

生产机(192.168.1.101)rsync 安装

检查系统是否已经安装了rsync

rpm -qa|grep rsync

如果有并且版本比较老,把老的卸载掉

rpm -e rsync

下载新的rsync的rpm源(我的系统是32位)

wget http://pkgs.repoforge.org/rsync/rsync-3.1.1-1.el6.rfx.i686.rpm

cd到相应的目录安装rsync

rpm -ivh rsync-3.1.1-1.el6.rfx.i686.rpm

安装完成后设置rsync开机启动

chkconfig rsync on

在CentOS里面,rsync使用xinetd运行方式,重启xinetd

service xinetd restart

发现 xinetd: unrecognized service 则说明未安装xinetd服务,安装xinetd

yum install xinetd

安装之后启动 xinetd服务

service xinetd start

创建rsync服务配置文件目录

mkdir /etc/rsyncd

创建配置文件

touch /etc/rsyncd/rsyncd.conf

配置文件配置详情

uid = root
gid = root
use chroot = no
read only = yes

hosts allow=172.16.0.0/255.255.0.0 192.168.1.0/255.255.255.0
10.0.1.0/255.255.255.0
hosts deny=*
max connections = 5

pid file = /var/run/rsyncd.pid
secrets file =/etc/rsyncd/rsyncd.secrets
log file = /etc/rsyncd/rsyncd.log
transfer logging = yes
syslog facility = local3
timeout = 300

[host1]
path = /home/host1/
list=yes
ignore errors
auth users = test
comment = host1’s file
exclude = important/

[host2]
path = /home/host2/
list=no
ignore errors
auth users = test
comment = host2’s file

创建密码文件

touch /etc/rsyncd/rsyncd.secrets

在密码文件里写入账户密码

vi /etc/rsyncd/rsyncd.secrets
test:test

改变密码文件的权限为600

chmod 600 /etc/rsyncd/rsyncd.secrets

配置完成了,启动生产机的rsync

/usr/bin/rsync –daemon –config=/etc/rsyncd/rsyncd.conf

查看生产机873端口,若有,则启动成功

netstat -tunl

同步机(192.168.1.102)安装rsync

安装rsync

yum -y install rsync

使用命令同步生产机的文件

rsync -avzP test@192.168.1.101::host1 /host1temp
输入密码即可开始同步

  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值