標題: rsync配置详解 [打印本頁] 作者: perl0302 時間: 2014-11-15 20:40 標題: rsync配置详解 配置文件/etc/rsyncd.conf 由模块和参数组成.模块由包括在方括号中的模块名开始,直到下一模块的开始为结束.模块的参数格式为 " name = value "
在参数中,只有第一个等号是最主要的.
以#开头的行,被忽略掉.
daemon必需有root权限,绑定端口在1024以下(默认是873),或者配置文件权限.可以通过inetd,或stand-alone daemon,或才通过远程的rsync客户端对其执行 访问.
如果使其以stand-alone方式运行,运用命令:rsync --daemon
以inetd方式运行: 在/etc/services文件中添加以下一行:
rsync 873/tcp
在/etc/inetd.conf文件中添加以下一行:
rsync stream tcp nowait root /usr/bin/rsync rsyncd --daemon
--------------全局参数-----------------------------
motd file
定义当客户端访问时看到的信息.默认没有.
pid file
定义rsync daemon将其PID写入的文件,如果此文件存在,rsync daemon会终止,而不是覆盖
port
定义daemon监听的端口,(默认是873),如果daemon在被inetd启动时加上 --port参数时,会
忽略此参数.
address
覆盖daemon默认监听的IP地址.如果daemon是被inetd启动,并且有 --address参数时,会被
忽略
socket options
用来防止 被人不停的连接.可以配置为所有socket的端口的传输速度:faster or slower.
会被在命令行的--sockopts覆盖
--------------模块参数----------------------------
模块名无法包括斜钱和关上的方括号.
comment
当客户端取得可用模块列表时,在模块名后执行 显示的注示.默认没有.
path
在这个模块中,daemon可以运用的文件系统.必须配置.
use chroot
如果被设为"true",daemon会在给客户端传输文件前"chroot to the path".
numberic ids
对当前daemon模块,关上能过名字对users 和groups执行 识别.会阻止daemon试图load任何usr/group-related file or libraries.如同客户端运用了 --numeric-ids参数一样.默
认在chroot中启用,在non-chroot中关上 .
munge symlinks
使传进来的文件的链接失效,但是可以还原 .只有在use chroot中并且inside-chroot path
is "/"时,才会启动,其它时全部失效.
charset
配置模块的文件名的存储编码. 如果客户端运用 --icov参数,会被失效.
max connections
配置最大连接数.默认为0,意为无限定 .负值为关上这个模块.
log file
不设会运用 syslog
syslog facility
指定syslog 的名字来启示录rsync daemon.
max verbosity
控制信息的最大数量.默认为1,允许客户端请求 one level of verbosity
lock file
指定文件用来支撑 "max connections"参数. 默认为/var/run/rsyncd.lock
read only
指定客户端能无法 可以上传文件.默认对所有模块都为true
write only
不允许下载.
list
能无法 允许客户端可以查看可用模块列表.默认为可以.
uid
指定用户名或UID取代root.默认为-2,意为nobody
gid
同上
fake super
设为yes,使文件的权限不以root权限.
filter
指定filter chain,指定哪些文件可以让客户端进入.
exclude
include
会覆盖exclude
exclude from
include from
incoming chmod 指定传入文件的权限
outgoing chmod
auth users
指定以空格或,分隔的用户可以运用些模块.用户不一定要在本地系统中存在.默认所有用
户无密码的访问(anonymous rsync)
secrets file
指定用户名和密码.格式 用户名:密码
strict modes
指定 secrets file的权限能无法 被检查.true or false
hosts allow
指定可以联系的客户端用户名和IP.address/mask,a.b.c.d,hostname,hostname pattern using wildcards
hosts deny
默认没有.
ignore errors
忽略I/P不正确 .
ignore nonreadable
忽略对用户没有可读的文件.
transfer logging
log format
定义logging file transfers,当transfer logging启用时.
* %a the remote IP address
* %b the number of bytes actually transferred
* %B the permission bits of the file (e.g. rwxrwxrwt)
* %c the total size of the block checksums received for the basis file (only
when sending)
* %f the filename (long form on sender; no trailing "/")
* %G the gid of the file (decimal) or "DEFAULT"
* %h the remote host name
* %i an itemized list of what is being updated
* %l the length of the file in bytes
* %L the string " -> SYMLINK", " => HARDLINK", or "" (where SYMLINK or
HARDLINK is a filename)
* %m the module name
* %M the last-modified time of the file
* %n the filename (short form; trailing "/" on dir)
* %o the operation, which is "send", "recv", or "del." (the latter includes
the trailing period)
* %p the process ID of this rsync session
* %P the module path
* %t the current date time
* %u the authenticated username or an empty string
* %U the uid of the file (decimal)
timeout
默认为0,意no timeout,建议为600(10分钟)
refuse options
daemon拒绝的rsync command line参数
dont compress
指定文件不被压缩.压缩耗CPU
pre-xfer exec,post-xfer exec
在传输开始或结束运行的命令.下面是配置的环境变量:
* RSYNC_MODULE_NAME: The name of the module being accessed.
* RSYNC_MODULE_PATH: The path configured for the module.
* RSYNC_HOST_ADDR: The accessing host's IP address.
* RSYNC_HOST_NAME: The accessing host's name.
* RSYNC_USER_NAME: The accessing user's name (empty if no user).
* RSYNC_PID: A unique number for this transfer.
* RSYNC_REQUEST: (pre-xfer only) The module/path info specified by the user
(note that the user can specify multiple source files, so the request can be
something like "mod/path1 mod/path2", etc.).
* RSYNC_ARG#: (pre-xfer only) The pre-request arguments are set in these
numbered values. RSYNC_ARG0 is always "rsyncd", and the last value contains
a single period.
* RSYNC_EXIT_STATUS: (post-xfer only) the server side's exit value. This will
be 0 for a successful run, a positive value for an error that the server
generated, or a -1 if rsync failed to exit properly. Note that an error that
occurs on the client side does not currently get sent to the server side, so
this is not the final exit status for the whole transfer.
* RSYNC_RAW_STATUS: (post-xfer only) the raw exit value from waitpid() .