rsyncd的配置和使用

服务器端配置文件说明

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

# See rsyncd.conf man page for more options.

# configuration example:
motd file = /etc/rsyncd.motd
#设置服务器信息提示文件,在该文件中编写提示信息

log file = /var/log/rsyncd.log
#设置日志文件名,可通过log format参数设置日志格式

pid file = /var/run/rsyncd.pid
#设置rsync进程号保存文件名称

lock file = /var/run/rsync.lock
#设置锁文件名称

port = 873
#设置服务器监听的端口号,默认是873

read only = yes
#是否允许客户端上传数据,yes表示不允许

max connections =10
#设置并发连接数,0表示无限制

# 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


[fdsfast]
        #自定义模块名,rsync通过模块定义同步的目录,可定义多个

        comment = fdsfast_data
        #定义注释说明字串

        path = /data
        #同步目录的真是路径通过path指定

        ignore errors
        #忽略一些IO错误

        #exclude = test/    #exclude指定common目录下某个目录可以不同步数据

        auth users = user
        #设置允许连接服务器的账户,此账户可以是系统中不存在的用户

        secrets file = /etc/rsyncd.secrets
        #密码验证文件名,该文件权限要求为只读,建议为600,仅在设置auth users后有效

        hosts allow = 192.168.10.38/255.255.255.0
        #设置哪些主机可以同步数据,多ip和网段之间使用空格分隔

        #hosts allow = 172.16.10.0/255.255.255.0   #设置哪些主机可以同步数据,多ip和网段之间使用空格分隔
        hosts deny = *
        #除了hosts allow定义的主机外,拒绝其他所有

        list = false
        #客户端请求显示模块列表时,本模块名称是否显示,默认为true

 

客户端操作

rsync -vzrtopg --progress user@masterIP::fdsfast/fastdfs backup/fastdfs/  //注意区分模块名和目录名,::fdsfast是模块名

 

 参数说明

v:显示详细信息
z:传输过程中对数据进行压缩
r:递归
t:保留修改时间属性
o:保留文件所有者属性
p:保留文件权限属性
g:保留文件所属组属性
a:归档模式,主要保留文件属性,等同于-rlptgoD
--progress:显示数据传输的进度信息
--password-file=FILE:指定密码文件,将密码写入文件,实现非交互式数据同步,这个文件名也需要修改权限为600
--delete:删除那些仅在目标路径中存在的文件(源路径中不存在),在脚本中的数据同步经常加上此参数
--list-only:仅列出服务器模块列表,需要rsync服务器设置list=true

posted @ 2019-02-26 15:32  linyouyi  阅读(1743)  评论(0编辑  收藏  举报