部署lsyncd实时同步

1.安装lsyncd

[root@nfs-31 ~]# yum install lsyncd -y

2.编辑lsyncd的配置文件

[root@nfs-31 ~]# 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    = "/nfs-nginx-data",
    target    = "rsync_backup@192.168.186.41::backup",
    delete= true,
    exclude = {".*"},
    delay=1,
    rsync     = {
        binary    = "/usr/bin/rsync",
        archive   = true,
        compress  = true,
        verbose   = true,
        password_file="/etc/rsync.passwd",
        _extra={"--bwlimit=200"}
        }
    }

3.生成密码文件,用于校验密码

[root@nfs-31 ~]# echo '123456' > /etc/rsync.passwd

4.修改密码文件权限为600

[root@nfs-31 ~]# chmod 600 /etc/rsync.passwd 

5.启动lsyncd服务

[root@nfs-31 ~]# systemctl start lsyncd

6.查看lsyncd服务状态

[root@nfs-31 ~]# systemctl status lsyncd
● lsyncd.service - Live Syncing (Mirror) Daemon
   Loaded: loaded (/usr/lib/systemd/system/lsyncd.service; disabled; vendor preset: disabled)
   Active: active (running) since Thu 2024-08-08 18:36:37 CST; 9s ago
 Main PID: 2051 (lsyncd)
   CGroup: /system.slice/lsyncd.service
           └─2051 /usr/bin/lsyncd -nodaemon /etc/lsyncd.conf

7.在lsyncd实时同步服务器上创建文件查看rsync备份服务器是否进行同步

#lsyncd服务器创建50个txt文本文件
[root@nfs-31 /nfs-nginx-data]# touch {1..50}.txt



#rsync服务器上查看实时同步数据
[root@rsync-41 /backup]# ls
10.txt  13.txt  16.txt  19.txt  21.txt  24.txt  27.txt  2.txt   32.txt  35.txt  38.txt  40.txt  43.txt  46.txt  49.txt  5.txt  8.txt
11.txt  14.txt  17.txt  1.txt   22.txt  25.txt  28.txt  30.txt  33.txt  36.txt  39.txt  41.txt  44.txt  47.txt  4.txt   6.txt  9.txt
12.txt  15.txt  18.txt  20.txt  23.txt  26.txt  29.txt  31.txt  34.txt  37.txt  3.txt   42.txt  45.txt  48.txt  50.txt  7.txt

  • 11
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值