rsync服务搭建记录

官网可见:https://rsync.samba.org/

安装文档可见:https://download.samba.org/pub/rsync/INSTALL#The_basic_setup

依赖包获取执行:

sudo yum -y install epel-release
sudo yum -y install gcc g++ gawk autoconf automake python3-pip
sudo yum -y install acl libacl-devel
sudo yum -y install attr libattr-devel
sudo yum -y install xxhash-devel
sudo yum -y install libzstd-devel
sudo yum -y install lz4-devel
sudo yum -y install openssl-devel
python3 -mpip install --user commonmark

下载rsync的tar包文件:wget https://download.samba.org/pub/rsync/src/rsync-3.2.3.tar.gz

解压后,进行如下编译安装:

 ./configure --prefix=/usr/local/rsync
 make
 sudo make install

安装完成后,创建etc目录

sudo mkdir -p /usr/local/rsync/etc/

创建rsync的配置

[global]
use chroot = yes
max connections = 10
timeout = 1800
port = 873
auth users = rsy_backup
secrets file = /usr/local/rsync/etc/rsync.pwd
hosts allow = 172.21.51.0/24
read only = true
list = false

[common_backup]
comment = rsync backup module 
path = /tmp/backup/

创建密码文件

sudo vi /usr/local/rsync/etc/rsync.pwd,填写如下内容:

rsy_backup:密码 
#格式为用户名:密码,此处只设定一个用户:rsy_backup

设置配置文件和密码文件的权限为600

sudo chmod 600 /usr/local/rsync/etc/rsync.pwd /usr/local/rsync/etc/rsyncd.conf

手动启动rsync服务

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

至此rsync已启动,手动测试是否可以正常拉取到数据

rsync -v -a --delete --force --ignore-errors --port=873 --password-file=密码文件(里面只有密码且权限应为600) rsync://rsy_backup@服务器地址/common_backup /tmp/rsy_backup

你可能感兴趣的:(服务器,运维)