CentOS 服务器间文件同步

配置文件同步服务器,作为向其他服务器提供同步服务 

1、首先要安装xinetd 

     yum -y install xinetd 

2、 rsync一般默认是安装的 

3、vim /etc/xinetd.conf,将其中的disable = yes改成disable = no 

3、vim  /etc/rsyncd.conf (注意此文件原来没有,直接编写即可) 

#rsync 
uid=nobody 
gid=nobody 
max connections=4 
use chroot=no 
log file=/var/log/rsyncd.log 
pid file=/var/run/rsyncd.pid 
lock file=/var/run/rsyncd.lock 
#auth users=root 
hosts allow = 192.168.1.3/6 
#hosts deny = 192.168.100.0/24 
[default] 
path=/usr/tomcat6/webapps/tkpcms/published/default/ 
comment =deployment www 
ignore errors 
read only = yes 
list = no 
hosts allow = 192.168.1.3/6 
auth users = default 
secrets file=/etc/rsyncd.pwd 
其中的内容说明 
[模块名] 
path = 备份文件路径 
auth users = 授权帐号 
uid = 执行时的uid 
gid = 执行时的gid 
secrets file = 密码文件位置 
read only = 是否只读 
4、创建验证文件 
    echo default:xxx >>/etc/rsyncd.pwd 
    chmod 600 /etc/rsyncd.pwd 
5、启动服务 
   rsync –daemon 
6、echo “rsync –daemon” >> /etc/rc.d/rc.local #添加到自启动文件 
7、该服务默认为873端口,所以要在iptables增加开放此端口 
   vim /etc/sysconfig/iptables 
8、增加 
-A RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 873 -j ACCEPT 
9、service iptables restart 
10、检查是否已经监听 
    netstat -na | grep 873 
    输出为 
     tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 
     tcp 0 0 :::873 :::* LISTEN 
二、客户端配置 
    1、echo XXX >>/etc/rsyncd.pwd # rsync服务器postfix密码(注:只要密码) 
    2、rsync -avuz --delete default@192.168.1.4::default /data/www/ --password-file=/etc/rsyncd.pwd 
          测试通过,证明服务可用 
    3、crontab -e #增加定时同步任务即可 

转自:http://blackhost.iteye.com/blog/831893

posted on 2011-09-06 16:09  房客  阅读(466)  评论(0编辑  收藏  举报

导航