文件同步

安装:yum -y install rsync

#检查是否已经成功启动
netstat -lnp|grep 873
否则开启873端口

配置文件:/etc/rsyncd.conf
rsyncd.conf:

# See rsyncd.conf man page for more options.

# configuration example:

# uid = nobody
# gid = nobody
# use chroot = yes
# max connections = 4
# pid file = /var/run/rsyncd.pid
# exclude = lost+found/
# transfer logging = yes
# timeout = 900
# ignore nonreadable = yes
# dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2

# [ftp]
# path = /home/ftp
# comment = ftp export area

pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log

[tslog]
path=/data/tslog
uid=haofei
gid=haofei
auth users=tslog
secrets file=/etc/rsyncd.password
read only = false
list = false


[gamelog]
path=/data/log
uid=haofei
gid=haofei
auth users=gamelog
secrets file=/etc/rsyncd.password
read only = false
list = false

密码文件:/etc/rsyncd.password 记录密码,需要赋予权限600:chmod 600 rsyncd.password

同步服务端:
#启动rsync服务
systemctl start rsyncd.service
systemctl enable rsyncd.service
防火墙 开端口
同步客户端:
创建同步的目录
创建密码文件,赋予权限600
如:rsync.pwd
使用脚本进行同步
如:
#!/bin/bash
rsync -avzP --no-owner --no-perms --password-file=rsync.pwd gamelog@172.18.133.137::gamelog /data/gamelog/QA/172.18.133.137
rsync -avzP --no-owner --no-perms --password-file=rsync.pwd gamelog@172.18.133.138::gamelog /data/gamelog/dev/172.18.133.138
定时执行脚本:在/var/spool/cron/路径下添加定时执行文件
如:root文件
*/5 * * * * cd /home/haofei/.rsync && ./rsync_tslog.sh >/dev/null 1>&1
*/5 * * * * cd /home/haofei/.rsync && ./rsync_gamelog.sh >/dev/null 2>&0

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值