首先我的服務器端ip:192.168.122.129
客戶端IP: 192.168.122.111
1.先來配置服務器端:
確認是否安裝rsync
# rpm -qa |grep rsync
如果沒有安裝可以從光盤上安裝如下:
1. 掛載光盤:
Mkdir /mnt/cdrom
Mount /dev/hdc /mnt/cdrom
Cd Server
rpm -ivh rsync-2.5.6-20.i386.rpm
umount /mnt/cdrom
eject
2. 配置rsync在 /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
}3.配置rsync自啓動
[root@test etc]#chkconfig rsync on
4.自己配置rsyncd.conf
[root@test etc]# chkconfig rsync --list
rsync onuid= root
gid = root
use chroot = no
max connections = 4
strict modes = yes
port = 873hosts allow = 192.168.122.111
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
[backup] #你要備份的
path = /srv #實際目錄
comment = This is test
auth users = scihoo
uid = root
gid = root
secrets file = /home/rsync.ps
read only = no
list = no
5./etc/services 裏面添加873端口
rsync873/tcp # rsync
6.. 配置rsync密碼(在上邊的配置文件中已經寫好路徑)/home/rsync.ps(名字隨便寫,只要和上邊配置文件裏的一致即可),格式
rsync 873/udp # rsync
(一行一個用戶)
[root@test etc]# vi /home/rsync.ps
root:123456
7. 配置rsync密碼文件權限,進入home目錄
[root@test home]# chown root.root rsync.ps
[root@test home]# chmod 700 rsync.ps8 啓動
啓動rsync服務
[root@test home]# /usr/bin/rsync –daemon
9. 加入rc.local
在各種操作系統中,rc文件存放位置不盡相同,可以修改使系統啓動時把rsync --daemon加載進去。
[root@test home]# vi /etc/rc.local
/usr/local/rsync –daemon #加入一行9檢查rsync是否啓動
[root@test home]# lsof -i :873
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
xinetd 4396 root 5u IPv4 633387 TCP *:rsync(LISTEN)啓動成功 服務器端完成