当前位置: 首页 > 工具软件 > lsyncd > 使用案例 >

lsyncd

姚阳德
2023-12-01

lsyncd 实时同步

一、配置服务端

1.vim /etc/rsyncd.conf

uid = rsync
gid = rsync
port = 873
fake super = yes
use chroot = no
max connections = 200
timeout = 300
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
ignore errors
read only = false
list = false
hosts allow = 172.16.1.0/24
hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsync.password
[backup]
comment = "welcome to kk backup!"
path = /backup

[data]
comment = "welcome to kk backup!"
path = /data
#创建密码文件

2.echo "rsync_backup:1" > /etc/rsync.password

 创建虚拟rsync用户

3.useradd -M -s /sbin/nologin rsync

创建备份目录

4.mkdir /backup 

 给目录属主属组rsync权限

5.chown -R rsync.rsync /backup

#### 启动服务
6.sysetmcte start rsyncd 
7.sysetmcte enable rsyncd

服务端 lsyncd服务 实时同步

 1. yum install epel-release -y && yum install rsync lsyncd -y
 2. groupadd -g666 www && useradd -u666 -g666 www
 3. mkdir /{backup,data}
 4. chown -R www.www /{backup,data}
 5. vim /etc/lsyncd.conf
 settings {
 logfile = "/var/log/lsyncd/lsyncd.log",
 statusFile = "/var/log/lsyncd/lsyncd.status",
 inotifyMode = "CloseWrite",
 maxProcesses = 8,
}

sync {
 default.rsync,
 source = "/data",
 target = "rsync_backup@172.16.1.41::backup",
 delete= true,
 exclude = { ".*" },
 delay = 1,

rsync = {
    binary = "/usr/bin/rsync",
    archive = true,
    compress = true,
    verbose = true,
    password_file = "/etc/lsyncd.passwd",
    _extra = {"--bwlimit=200"}                          --限速选项,单位MB,非常重要
    }                                                   --不配置可能会让内网中其他服务器炸了
}

[root@nfs01 data]#   echo '1' > /etc/lsyncd.passwd
[root@nfs01 data]#   chmod 600 /etc/lsyncd.passwd
[root@nfs01 data]#   lsyncd -nodaemon /etc/lsyncd.conf
[root@nfs01 data]#   systemctl restart rsyncd lsyncd
[root@nfs01 data]#   systemctl enable rsyncd lsyncd
 类似资料:

相关阅读

相关文章

相关问答