二、备份服务器(rsync)
1、准备工作
创建备份目录:
[root@backup ~]# mkdir /data/ftpdata
2、准备软件包
[root@backup ~]# wget
3、安装rsync(备份服务器只安装rsync)
[root@backup ~]# tar -zxvf rsync-3.0.9.tar.gz
[root@backup ~]# cd rsync-3.0.9
[root@backup rsync-3.0.9]# ./configure--prefix=/usr/local/rsync
[root@backup rsync-3.0.9]# make;make install
4、建立用户与密码认证文件
[root@backup ~]# echo "root:111111" >/etc/rsyncd.secrets
[root@backup ~]# less /etc/rsyncd.secrets
root:111111
注意:
请记住,在ftp端建立的密码文件,只有密码,没有用户名;而在备份服务端backup里建立的密码文件,用户名与密码都有。
权限:要将/etc/rsyncd.secrets设置为root拥有, 且权限为600。
[root@backup ~]#chmod 600 /etc/rsyncd.secrets
5、建立rsync配置文件
[root@backup ~]# vim /etc/rsyncd.conf
uid = root
gid = root
port = 873
use chroot = yes
read only = yes
hosts allow=192.168.1.0/255.255.255.0
hosts deny=*
max connections = 5
log file =/var/log/rsyncd.log
pid file =/var/run/rsyncd.pid
lock file =/var/run/rsyncd.lock
log format = %t %a %m %f%b
syslog facility = local3
timeout = 300
[ftpdata]
path = /data/ftpdata
list = no
read only = no
ignore errors
auth users = root
secrets file =/etc/rsyncd.secrets
:wq
启动rsync服务
[root@backup ~]# /usr/local/rsync/bin/rsync --daemon--config=/etc/rsyncd.conf
[root@backup ~]# ps -ef |grep rsync
Rsync服务加入开机启动项
[root@backup ~]# echo "/usr/local/rsync/bin/rsync--daemon --config=/etc/rsyncd.conf" >> /etc/rc.local
防火墙开启rsync端口:873
[root@backup ~]# vim /etc/sysconfig/iptables
添加:
-A INPUT -m state --state NEW -m tcp -p tcp --dport 873 -jACCEPT
重启:
[root@backup ~]# /etc/init.d/iptables restart
现在rsync与inotify在ftp端安装完成,rsync在备份服务器backup端也安装完成!
重启
[root@ftp ~]# reboot
[root@backup ~]# reboot