Rsync 搭建

介绍:rsync是linux服务器之前做数据同步用的一种工具;


RSYNC配置
系统环境:Centos6.6


IP host
192.168.56.21 server
192.168.56.22 client

配置rsync-server:


[root@salt1 etc] yum install -y rsync

[root@salt1 etc]touch rsyncd.conf

[root@salt1 etc]# vim /etc/rsyncd.conf

pid file = /var/run/rsyncd.pid
port = 873
uid = root
gid = root
usechroot = yes
read only = yes
hosts allow=*
hosts deny=*
max connections = 5
log format = %t %a %m %f %b
syslog facility = local3
timeout = 300

[test_rsync]
path = /tools/test
list=yes
read only = no
auth users = test1
secrets file = /etc/rsyncd.secrets
ignore errors


[update]
path = /tools/push_data_ftp/test
list=yes
read only = no
auth users = test1
secrets file = /etc/rsyncd.secrets
ignore errors

[root@salt1 etc]# touch /etc/rsyncd.secrets
[root@salt1 etc]# echo "test1:test123" > /etc/rsyncd.secrets
[root@salt1 etc]# chmod 600 /etc/rsyncd.secrets

启动服务:


[root@salt1 etc]# /usr/bin/rsync --daemon --config=/etc/rsyncd.conf
或service xinetd restart

[root@salt1 test]# lsof -i:873
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rsync 26835 root 4u IPv4 53430 0t0 TCP *:rsync (LISTEN)
rsync 26835 root 5u IPv6 53431 0t0 TCP *:rsync (LISTEN)


Rsync-client:


创建密码文件
[root@salt2 yum.repos.d]# touch /etc/rsyncd.secrets
[root@salt2 yum.repos.d]# echo "test123" > /etc/rsyncd.secrets
[root@salt2 etc]# chmod 600 /etc/rsyncd.secrets

环境测试

Rsync客户端测试:
[root@salt2 /]mkdir -p /zw/test/
[root@salt2 /]# mkdir -p /zw/test/
[root@salt2 /]# cd /zw/test/
[root@salt2 test]# touch aaa.txt
[root@salt2 test]# ls
aaa.txt

[root@salt2 /]rsync -av --password-file=/etc/rsyncd.secrets /zw/test/ test1@192.168.56.21::test_rsync
[root@salt2 /]rsync -av --password-file=/etc/rsyncd.secrets /zw/test/ test1@192.168.56.21::update

注释:使用 --password-file=/etc/rsyncd.secrets 密码验证,把/zw/test/ 目录下的文件同步到test1用户下的 192.168.56.21 这台主机的 ,test_rsync目录下

rsync服务端:完成后查看该路径下有没有文件同步过来,如果有,同步成功!
/tools/test
/tools/push_data_ftp/test

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值