| 关键词: nbsp 文件 192.168 rsync rsyncd data file password 密码 1.252 |
1 安装xinetd yum -y install xinetd 2 将rsync启动控制交给xinetd vi /etc/xinetd.d/rsync 将disable = yes 更改为 disable = no 3 创建rsync配置文件 vi /etc/rsyncd.conf 添加 uid = root gid = nobody use chroot = yes max connections = 4 pid file = /var/run/rsyncd.pid lock file = /var/run/rsyncd.lock log file = /var/log/rsyncd.log [upload] path = /data/upload comment = used for user upload data read only = no list = no hosts allow = 192.168.1.252 [download] path = /data/download comment = used for user download file read only = yes list = no hosts allow = 192.168.1.252 [password] path=/data/password comment = need password to access read only = yes list = no auth users = wang secrets file =/data/rsyncd.pass 4创建密码文件 touch /data/rsyncd.pass echo "wang:test">/data/rsyncd.pass chmod 400 /data/rsyncd.pass 5重新启动xinetd 让rsync配置生效 service xinetd restart 6 在192.168.1.252测试 在192.168.1.252 上传同步文件夹命令 rsync -a --progress --delete /data/upload 192.168.1.100::upload 在192.168.1.252 下载同步文件夹命令 rsync -a --progress --delete 192.168.1.100::download download/ 在192.168.1.252上同步需要密码验证的文件夹命令 touch pass echo "test">pass chmod 400 pass rsync -a --progress [email protected]::password /data/passwd --password-file=pass 7 说明: 1 rsync常用参数说明示例: [test] # 这里是认证的模块名,在client端需要指定 max connections = 4 #客户端最大连接数,默认0(没限制) uid = root #指定该模块传输文件时守护进程应该具有的uid gid = nobody #指定该模块传输文件时守护进程应该具有的gid path = /data/upload # 需要发布的数据文件目录 read only = no #no客户端可上传文件,yes只读 write only = no #no客户端可下载文件,yes不能下载 hosts allow = 192.168.0.101 #*允许任何主机连接 #hosts deny = 192.168.1.100 #禁止指定的主机连接 auth users = root #认证的用户名,如果没有这行,则表明是匿名 secrets file = /data/rsyncd.pass # 指定认证口令文件位置 #exclude = * #排除所有文件 #include = test.txt #包含test.txt文件 2上述rsync配置实现了 upload模块允许192.168.1.252 上传 download模块允许192.168.1.252 下载 password模块允许用户wang通过密码验证,如果想让多个账号通过密码验证,多个账号之间用逗号隔开。服务器端secret file的格式为 账号:密码 一行一个账号 客户端的secret file 中只需要填入密码即可。 3 参数说明: -a 参数设置复制文件及目录,并保持访问权限、修改时间等文件的元数据(metadata); --delete 参数让目标同源保持完全一致,在源目录被删除的文件,在目标目录也会被删除。如果不包含“--delete”选项,那么即使在源目录已经删除的文件,也会仍然保存在 目标目录中。 --progress 参数将显示复制详细的进度。 -a, --archive 归档模式,表示以递归方式传输文件,并保持所有文件属性,等于-rlptgoD -r, --recursive 对子目录以递归模式处理 -l, --links 保留软链结 -p, --perms 保持文件权限 -o, --owner 保持文件属主信息 -g, --group 保持文件属组信息 -D, --devices 保持设备文件信息 -t, --times 保持文件时间信息 -e, --rsh=COMMAND 指定使用rsh、ssh方式进行数据同步 --delete 删除那些DST中SRC没有的文件 -z, --compress 对备份的文件在传输时进行压缩处理 --password-file=FILE 从FILE中得到密码 -zrtopg 有些朋友喜欢用这些参数同步 4 如果想把rsync做成独立模式可以用下面的命令启动rsync,而不再用xinetd 也不必执行上面第1、2 、4步 /usr/bin/rsync --daemon --config=/etc/rsyncd.conf |
|
声明:文章版权归原作者所有 部分文章转自互联网 如有侵权请联系
[邮箱地址] 删除
|