rsync 3.1.1源代码编译安装配置

本文详细介绍rsync服务的安装配置过程,包括卸载旧版本、编译安装新版本、配置server端及client端,同时提供了实用的示例,如定时同步任务设置等。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

http://rsync.samba.org/


rsync-3.1.1.tar.gz

---0.卸载rpm

# yum remove  rsync



-----1.安装:

tar -zxvf rsync-3.1.1.tar.gz

cd rsync-3.1.1


./configure --prefix=/usr/local/rsync --disable-ipv6

make

make install

ln -s /usr/local/rsync/bin/rsync /usr/local/bin/rsync


----2.server端配置

# vi /usr/local/rsync/rsyncd.conf

pid file = /var/run/rsyncd.pid
port = 873
pid = root
gid = root
use chroot = no
max connections = 200
timeout 600
lock file = /var/run/rsyncd.lock
log file = /var/run/rsyncd.log
secrets file = /usr/local/rsync/rsyncd.secrets 
motd file = /etc/rsyncd.motd

[test]
path = /test/
ignore errors
read only = true
list = false
hosts allow = *
#hosts deny = 0.0.0.0/32
auth users root  #该用户系统中存在且对后面指定的备份文件夹拥有权限
comment = ocpyang  test   
 


#vi /usr/local/rsync/rsyncd.motd

++++++++++++++++++++++++++++++++++++
Wlecome to ocpyang  rsync services       
++++++++++++++++++++++++++++++++++++


--指定rsync訪问的password,password不须要和系统账号password同样

# vi /usr/local/rsync/rsyncd.secrets  
root:snow01


ln -s /usr/local/rsync/rsyncd.conf /etc/rsyncd.conf
ln -s /usr/local/rsync/rsyncd.motd /etc/rsyncd.motd
ln -s /usr/local/rsync/rsyncd.secrets  /etc/rsyncd.secrets


chmod 600 /usr/local/rsync/rsyncd.secrets

chown root:root /usr/local/rsync/rsyncd.secrets



启动rsync

# /usr/bin/rsync --daemon --config=/etc/rsyncd.conf

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

# cat /etc/rc.d/rc.local 
#!/bin/sh
#
# This script will be executed *after* all the other init scripts.
# You can put your own initialization stuff in here if you don't
# want to do the full Sys V style init stuff.

touch /var/lock/subsys/local
/usr/bin/rsync --daemon


# netstat -lntp | grep 873
tcp        0      0 0.0.0.0:873                 0.0.0.0:*                   LISTEN      10689/rsync         
tcp        0      0 :::873                      :::*                        LISTEN      10689/rsync   

--新建測试文件
#dd if=/dev/zero of=/test/t01.file bs=1M count=50


#pkill rsync



----3.client服务器配置


(1).新建clientpassword文件(client不带username)

#vi /etc/rsyncd.secrets
snow01

#chmod 600 /etc/rsyncd.secrets

rsync -vzrtopg  --progress --delete  root@192.168.5.189::test /ocpyang/ 

rsync -vzrtopg --progress --delete  root@192.168.5.189::test /ocpyang/ --password-file=/etc/rsyncd.pwd



(3).新建同步脚本

# vi /rsync.sh
#!/bin/bash
  

rsync -vzrtopg  --progress --delete  root@192.168.5.189::test /testbak/ 

rsync -vzrtopg --progress --delete  root@192.168.5.189::test /testbak/ --password-file=/etc/rsyncd.pwd


(4).手动同步文件

#cd /
#./rsync.sh


(5).自己主动同步:每隔五分钟同步一次
# crontab -e
0,5 * * * * /rsync.sh

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值