博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
X Chen笔记----Centos6.9安装rsycn文件同步
阅读量:2395 次
发布时间:2019-05-10

本文共 2620 字,大约阅读时间需要 8 分钟。

参考:

           

 

一. 环境

Centos 6.9

server IP:192.168.1.100  client IP: 192.168.1.200

 

二.安装

yum install -y rsync xinetdsetenforce 0  或者  echo "SELINUX=disabled" >/etc/selinux/config (需要重启才能生效)

三.配置

vi /etc/rsyncd.conf

rsyncd.conf是一个空白文件,将以下内容复制进这个文件,并根据需要做相应修改。

uid=root                                    #以指定的 UID 传输文件gid=root                                    #以指定的 GID 传输文件#hosts allow=10.50.53.100                  #允许指定主机访问#hosts deny=0.0.0.0/32                      #阻止指定主机访问use chroot=yes                              max connections=10                          #允许的最大连接数pid file=/var/run/rsyncd.pid                #指定pid文件路径lock file=/var/run/rsync.lock              #指定进程锁文件log file=/var/log/rsyncd.log                #指定日志路径timeout=600                                #连接超时时间port=873                                    #指定tcp端口[backup]path=/datacomment=rsync filesread only=nolist=yesauth users=chicken00secrets file=/etc/.rsyncd.secrets

#设置server端的用户名和密码,用户跟配置文件指定相同(auth users)

$ echo "chicken00:chicken00" >/etc/.rsyncd.secrets

#设置client端的密码,密码需要和server设置的一样,client端不需要设置用户名,否则会报错。

echo "chicken00" >/etc/.rsyncd.secrets

#设定文件的权限为600

chmod 600 /etc/.rsyncd.secrets

 

 

三.启动

#设为开机启动

chkconfig rsync on

#查看开机启动

$ chkconfig --list rsync    rsync              on

#rsync 守护进程管理工具xinetd配置中的内容

$ cat /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    = noflags    = IPv6socket_type = streamwait = nouser = rootserver = /usr/bin/rsyncserver_args = --daemonlog_on_failure += USERID}

#启动服务

/etc/init.d/xinetd start

四. client端同步测试

#client端测试准备

echo "chicken00" >/etc/.rsyncd.secrets chmod 600 /etc/.rsyncd.secrets echo 'hello rsync!!' >hello.txt

#上传文件

rsync -vzrtopg --delete --progress hello.txt chicken00@192.168.19.100::backup --password-file=/etc/.rsyncd.secrets

#下载文件

将文件同步至指定文件夹

rsync -vzrtopg --delete --progress chicken00@10.7.31.254::backup $(pwd)/tftp --password-file=/etc/.rsyncd.secrets

  

将server端文件下载至一个以同步时间命名的文件夹

rsync -vzrtopg --delete --progress chicken00@192.168.19.128::backup $(pwd)/backup-$(date +%Y-%m-%d) --password-file=/etc/.rsyncd.secrets

五.疑难杂症各种报错

@ERROR: chdir failed 

rsync error: error starting client-server protocol (code 5) at main.c(1296) [receiver=2.6.8]
原因及解决办法:
SELinux;
setsebool -P rsync_disable_trans on
@ERROR: auth failed on module GacErrLog
rsync error: error starting client-server protocol (code 5) at main.c(1296) [sender=2.6.8]
原因:
rsynd里面配置passwd是
username:password 这样的格式
客户端使用的时候,不能用这种格式,文件里面只能有password
解决方法:
1. 文件内容修改
2. rsync -av --password-file <(echo PASSWORD) src dest

转载地址:http://phwob.baihongyu.com/

你可能感兴趣的文章
poj 2524 Ubiquitous Religions
查看>>
poj 1611 The Suspects
查看>>
poj 3331 The Idiot of the Year Contest!
查看>>
poj 3233 Matrix Power Series
查看>>
poj 3070 Fibonacci
查看>>
poj 1656 Counting Black
查看>>
BestCoder Round #28
查看>>
poj3299 Humidex
查看>>
poj2159 Ancient Cipher
查看>>
poj1083 Moving Tables
查看>>
poj2255 Tree Recovery
查看>>
zoj 1745 Are We There Yet?
查看>>
UVA100 The 3n + 1 problem
查看>>
hdu1754 I Hate It
查看>>
hdu 1166 敌兵布阵(求区间的和,单节点更新)
查看>>
hiho一下 第四十四周 题目1 : 博弈游戏·Nim游戏
查看>>
poj2299 Ultra-QuickSort(线段树计数问题)
查看>>
hdu4565 So Easy!(矩阵快速幂)
查看>>
poj2528 Mayor's posters(线段树,离散化)
查看>>
线段树多lazy-tag(两个)
查看>>