一、rsync接收端安装240
1、查看rsync安装包
# rpm -qa rsync
2、安装rsync
# yum install rsync -y
3、添加rsync服务的用户,管理本地目录的
# useradd -s /sbin/nologin -M rsync
# id rsync
4、生成rsyncd.conf配置文件
# cat /etc/rsyncd.conf
[backup]
uid = root
gid = root
use chroot = no
max connections = 400
strict modes = yes
port = 873
commet = This is MySQL Backup Data
ignore errors
read only = no
list = no
auth users =root
secrets file = /etc/rsync.pas
hosts allow = 192.168.1.0/24
hosts deny =0.0.0.0/0
pid file = /var/run/rsyncd.pid
lock file =/var/run/rsync.lock
log file = /var/log/rsyncd.log
path = /data/backup
5、根据rsyncd.conf的auth users配置帐户,远程连接的,并根据secrets file 参数生成密码文件。
vim /etc/rsync.pas
6、为密码文件配置权限
# chmod 600 /etc/rsync.password
7、创建共享目录并授权rsync服务管理
# mkdir /data/backup -p
# chown -R rsync.rsync /data/backup
8、启动rsync服务并检查
# rsync --daemon
# ps -ef | grep rsync
# lsof -i:873
9、加入开机自启动
# echo "/usr/bin/rsync --daemon" >> /etc/rc.local
# tail -1 /etc/rc.local
二、rsync 发送端241
1、查看rsync安装包
# rpm -qa rsync
2、安装rsync
系统默认都会安装rsync软件包的,如果查看发现没有安装,执行yum安装即可
# yum install rsync -y
3、添加rsync服务的用户,管理本地目录的
# useradd -s /sbin/nologin -M rsync
# id rsync
4、生成连接服务器需要的密码文件
vim /etc/rsync.pas
5、为密码文件配置权限
# chmod 600 /etc/rsync.password
# ls -1 /etc/rsync.password
6、同步文件语法
基于rsync daemon同步语法:
拉取: rsync [OPTION...] [USER@]HOST::SRC... [DEST] rsync [OPTION...] rsync://[USER@]HOST[:PORT]/SRC... [DEST]
推送: rsync [OPTION...] SRC... [USER@]HOST::DEST rsync [OPTION...] SRC...
7、测试手动推送是否正常
rsync -avz /data/backup/ [email protected]::backup --password-file=/etc/rsync.pas