centos文件同步rsync

我这里主要用途是备份

端口:873

下载地址:https://rsync.samba.org/ftp/rsync/src/

服务端和客户端要保持版本一致

网盘链接:https://pan.baidu.com/s/1wTsj0cCfXRcREnbzeIviuQ

服务端

1、安装:

...

2、设置密码文件

vim /etc/rsync.pas

cjh:123456  #格式 用户名:密码   这里的用户名和密码跟系统没有关系的

配置文件

vi /etc/rsyncd.conf  #文件不一定有,可以自己创建


# /etc/rsyncd: configuration file for rsync daemon mode

# 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

加上我的配置

uid = nobody
gid = nobody
use chroot = yes
max connections = 5
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
log file = /var/log/rsyncd.log
transfer logging = yes
log format = %t %a %m %f %b
timeout = 300
[test]
read only = yes
path = /root/test      #同步目录路径
comment = test       #可选,无太大作用
auth users =cjh        #用户名,注意跟系统的用户密码没关系
secrets file =/etc/rsync.pas #密码文件
hosts allow = ip1,ip2  #客户端ip

启动

which rsync
/xx/rsync

#后台启动
/xx/rsync --daemon

ps -ef | grep rsync #看看服务是否正常运行

客户端

1、安装rsync

2、一次性同步

rsync -av cjh@139.159.253.188::test /root/test2   --password-file=/etc/rsync.pas --bwlimit=100

test是客户端定义的模块,/root/test2 是客户端的目录,密码文件跟服务端不同的是只需要填密码,--bwlimit是网速的限制

实时同步

猜你喜欢

转载自www.cnblogs.com/cjh-notes/p/10802807.html