Chinaunix首页 | 论坛 | 博客
  • 博客访问: 176936
  • 博文数量: 9
  • 博客积分: 0
  • 博客等级: 民兵
  • 技术积分: 156
  • 用 户 组: 普通用户
  • 注册时间: 2014-01-10 16:33
个人简介

在IT路上努力奔跑的少年。

文章分类

全部博文(9)

文章存档

2015年(3)

2014年(6)

我的朋友

分类: 系统运维

2015-04-24 08:59:05

基础环境:
操作系统Red Hat 4.x
服务端:192.168.1.64
客户端:192.168.1.70

一、检查rsync是否安装

#rsync –aq |grep rsync

二、生成rsyncd.conf,启动进程

1)生成rsyncd.conf

#vi /etc/rsyncd.conf

#[global]

uid = root

gid = root

use chroot = no

max connections = 10

list = yes

pid file = /var/run/rsyncd.pid

lock file = /var/run/rsyncd.lock

log file = /var/log/rsyncd.log

hosts allow = 192.168.1.70               //允许访问的IP

[data]                                                    //指定发布名

path = /root/test                                //发布的路径

read only = no

ignore errors

auth users = root                                //认证用户为root

secrets file = /etc/sery.pass                    //密码文件

#wq

#rsync –daemon  --config=/etc/rsyncd.conf                //启动rsync服务端

2)生成客户端和服务端密码文件

客户端:

#vi /etc/sery_client.pass 

root123456

#chmod 600 /etc/sery_client.pass

服务端:
#vi /etc/sery.pass

123456

#chmod 600 /etc/sery.pass

3)启动rsync

rsync --daemon --config=/etc/rsyncd.conf

4)查看监听状态

#lsof i:873

三、将rsync写进服务端自启动

# echo "/usr/bin/rsync --daemon --config=/etc/rsyncd.conf" >>/etc/rc.local

四、测试同步

#rsync –avzP –-delete /root/test –-password-file=/etc/

Sery_client.pass

1.    –a 使用archive模式,保持原有的文件权限

2.    –v显示到屏幕上

3.    –z传输时压缩数据

4.    –P传输进度

5.    --delete是指如果服务器端删除了这一文件,那么客户端也相应把文件删除,保持真正的一致

6.    /root/test 客户端本地存放路径

7.    –password-file 指定密码文件

出现:
[root@stserzzptora-bak data]# rsync -avzP --delete root@192.168.1.64::data /root/test/data --password-file=/etc/sery_client.pass

receiving file list ...

7 files to consider

./ files...

6.txt

           0 100%    0.00kB/s 397113:04:51  (1, 100.0% of 7)

 

sent 124 bytes  received 240 bytes  728.00 bytes/sec

total size is 11  speedup is 0.03

说明客户端与服务端连接正常。

五、在客户端上写进crontab

#vi /root/rsyncd.sh

#!/bin/bash

 rsync –avzp –-delete /root/test/data –-password-file

=/etc/sery_client.pass

#wq

查看是否正常同步。


阅读(2281) | 评论(0) | 转发(0) |
0

上一篇:记一次编译过程中遇到的诡异事件

下一篇:没有了

给主人留下些什么吧!~~