linux 上本配置rsync

本文详细介绍rsync服务的配置步骤及客户端定时同步文件的方法。包括安装rsync、配置rsyncd.conf文件实现mysql数据库备份,并设置开机启动;客户端通过crontab定时任务实现远程同步。
yum install rsync

配置

#vi /etc/rsyncd.conf
# mkdir /etc/rsyncd
# touch /etc/rsyncd/rsyncd.conf
# ln -s /etc/rsyncd/rsyncd.conf /etc/rsyncd.conf
# Minimal configuration file for rsync daemon
# See rsync(1) and rsyncd.conf(5) man pages for help

# This line is required by the /etc/init.d/rsyncd script
# GLOBAL OPTIONS
uid = root
gid = root

use chroot = no

read only = yes

#limit access to private LANs
hosts allow=192.168.1.0/255.255.255.0 192.168.31.0/255.255.255.0
hosts deny=*
max connections = 5

pid file = /var/run/rsyncd.pid

secrets file = /etc/rsyncd/rsyncd.secrets
#lock file = /var/run/rsync.lock

motd file = /etc/rsyncd/rsyncd.motd

#This will give you a separate log file
log file = /var/log/rsync.log

#This will log every file transferred - up to 85,000+ per user, per sync
transfer logging = yes

log format = %t %a %m %f %b
syslog facility = local3
timeout = 300

# MODULE OPTIONS
[mysql_databack]
path = /opt/db-backup/
list=yes
ignore errors
auth users = mysql
comment = mysql_databack



欢迎信息

#/etc/rsyncd/rsyncd.motd
+++++++++++++++++++++++++++
+ mysql databackp +
+++++++++++++++++++++++++++


密码文件

#/etc/rsyncd/rsyncd.secrets
#用户名:密码
mysql:databackup


添加为开机启动
echo "rsync --daemon " >> /etc/rc.local


客户端配置

定时同步文件

vi /etc/crontab
10 2 * * * rsync rsync -avzP --delete --password-file=/home/rsync/rsync.password mysql@192.168.1.10::mysql_databack /opt/mysql


#/home/rsync/rsync.password
#只写密码
databackup
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值