# rpm -qa |grep rsync #检查系统是否安装了rsync软件包
rsync-2.6.8-3.1
#yum install rsync
服务器-----------------------------------------
1 配置rsync servervi /etc/xinetd.d/rsync
将disable=yes改为no
service rsync
{
disable = no
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
2 配置rsync自动启动
[[email protected] etc]# chkconfig rsync on
[[email protected] etc]# chkconfig rsync --list
rsync on
3 配置rsyncd.conf
rsyncd.conf
没有需要自己创建,最好所有文件放在一个目录下
mkdir /etc/rsyncd
touch rsyncd.conf
ln -s /etc/rsyncd/rsyncd.conf /etc/rsyncd.conf
[[email protected]
etc]# vim rsyncd.conf
uid=root
gid=root
use chroot=no
max connections=4
port=873
pid file=/var/run/rsyncd.pid
lock file=/var/run/rsync.lock
log file=/var/log/rsyncd.log
motd file=/etc/rsyncd.motd
hosts allow=127.0.0.1 10.47.122.0/255.255.255.0 10.24.234.0/255.255.255.0
[test]
path=/usr/local/src/test
comment=ServerTest
read only=on
list=yes
#auth users=test
#secrets file=/etc/rsyncd/rsyncd.pas
4
确保etc/services中rsync端口号正确
[[email protected] etc]# vim /etc/services
rsync 873/tcp # rsync
rsync 873/udp # rsync
5 配置rsync密码(在上边的配置文件中已经写好路径)/home/rsync.ps(名字随便写,只要和上边配置文件里的一致即可),格式(一行一个用户)
[[email protected] etc]# vi /etc/rsyncd/rsyncd.pas
test:test
6 配置rsync密码文件权限
[[email protected] home]# chown root.root rsyncd.pas
[[email protected] home]# chmod 600 rsyncd.pas
7
首次启动配置
rsync
–-daemon –-config=/etc/rsyncd.conf
failed to create pid file /var/run/rsyncd.pid: File exists
[[email protected] ~]# rm -rf /var/run/rsyncd.pid
[[email protected] ~]# rsync –daemon –config=/etc/rsyncd.conf
如果没有出现创建pid错误,就不需要删除pid文件再启动。
确认rsync是否启动了?
[[email protected] ~]# ps -ef | grep rsync
root 29768 1 0 15:19 ? 00:00:00 rsync –daemon –config=/etc/rsyncd.conf
root 29792 28996 0 15:21 pts/0 00:00:00 grep rsync
客户端配置
1 配置三个过程就可以了
1.1 设定密码文件
1.2 测试rsync执行指令
[[email protected]
home]# vi /etc/xinetd.d/rsync
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
# allows crc checksumming etc.
service rsync
{
disable = yes
socket_type = stream
wait = no
user = root
server = /usr/bin/rsync
server_args = --daemon
log_on_failure += USERID
}
1.1 配置密码文件 (注:为了安全,设定密码档案的属性为:600。rsync.ps的密码一定要和Rsync Server密码设定案里的密码一样)
[[email protected] home]# vi /etc/rsyncd/rsyncd.pas
sciooo
[[email protected] home]# chown root.root .rsyncd.pas # 注意必须给权限
[[email protected] home]# chmod 600 .rsyncd.pas # 必须修改权限
1.2 从服务器上下载文件
[[email protected] rsync-3.0.4]# rsync -avz --password-file=/etc/rsyncd/rsyncd.pas
[email protected]::test /home/
从本地上传到服务器上去
[[email protected] rsync-3.0.4]# rsync -avz --password-file=/etc/rsyncd/rsyncd.pas
/home/ [email protected]::test