1.安装rsync和xinetd
yum install rsync xinetd
2.配置xinetd:
vi /etc/xinetd.d/rsync
#disable = yes修改为
disable = no
3.启动xinetd服务:
service xinetd start
4,编辑rsyncd.conf配置文件:
[root@dx-it-twebs01 wuxiaoyu]# cat /etc/rsyncd.conf
#motd file = /etc/rsyncd.motd
use chroot = yes
uid=root
gid=root
max connections = 2000
timeout = 600
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
log file = /var/log/rsync.log
ignore errors
read only = false
list = false
hosts allow =
192.168.0.0/24
hosts deny = *
[wikidata]
comment = wikidata
path = /data/store/
auth users = test
secrets file = /etc/rsync/test_rsyncd.secrets
[root@dx-it-twebs01 wuxiaoyu]#
5,配置服务端秘钥
mkdir /etc/rsync
touch /etc/rsync/test_rsyncd.secrets ##密码为test:123456789
chmod 600 /etc/rsync/test_rsyncd.secrets
6,配置客户端服务秘钥
touch secrets.txt
chown test.test secrets.txt
chmod 600 secrets.txt
7,测试传输wuxiaoyu这个目录到rsync的服务端
rsync -varz mfs/wuxiaoyu test@dx-it-twebs01.dx.test.com::wikidata --password-file secrets.txt
网上有很多教程使用xinet.d来启动rsync服务端。
不过也使用rsync自带的来启动服务端
如:rsync --daemon --config=/home/leyewen/etc/rsync/rsyncd.conf
这种方式是以守护进程的方式启动服务,但是守护进程方式启动的进程不能被
daemontools
管理,
daemontools 管理nginx的时候,
nginx.conf 必须关闭daemon, daemon off;
http://kavy.iteye.com/blog/2119978
如果
daemontools想管理rsync,则需要再run脚本中以如下方式启动(
--no-detach 这个参数
)
exec rsync --daemon
--no-detach
--config=/etc/rsyncd.conf >> /var/log/rsync.log 2>&1
同时此脚本要有执行权限,chmod +x run
#!/bin/bash
NUM=`ps -ef |grep -v grep | grep -c "rsync --daemon"`
if [ $NUM -lt 1 ]
cd /opt/apps/rsync
#ulimit -c unlimited
exec rsync --daemon --no-detach --config=/etc/rsyncd.conf >> /var/log/rsync.log 2>&1
#exec setuidgid test /opt/apps/xxx_agent/xxx_agent > /dev/null 2>&1
fi
--no-detach 含义
When running as a daemon, this option instructs rsync to not detach itself and become a background process. This option is required when running as a service on Cygwin, and may also be useful when rsync is supervised by a program such as
daemontools
or AIX's
System Resource Controller
.
--no-detach
is also recommended when rsync is run under a debugger. This option has no effect if rsync is run from inetd or sshd.
原文:https://download.samba.org/pub/rsync/rsync.html
rsync 参数配置
http://tenderrain.blog.51cto.com/9202912/1874449
https://download.samba.org/pub/rsync/rsync.html