我们需要把其中一台 34.38 的的东西实时同步两份,一份到 30.18 的 glusterfs,一份到 34.41 的 /data
同时也要注意 30.18 的 GFS 中已经有两个虚机文件,32.6 和 34.38 的qcow2
所以 lsync 务必要小心,不能删除已有文件
172.18.34.38上面的 lsyncd.conf 如下,同步到两个目的地: 注意下面的参数:
- maxProcesses = 2 # 本机用于rsync的进程数
- delete = ‘running’ # 只删除lsync启动之后删除的文件,目的文件夹中原有的文件保存
- exclude = “upload” # 第二个同步中排除的目录,注意这里是匹配全路径中的部分字串,upload 可以匹配到 /data/new/chatmsg/upload/allajl.jpg,就upload目录下文件大,所以把它排除。**这里的规则是和rsync中exclude的写法不同的!!!**只取路径中的upload字串就可以排除。
---- -- User configuration file for lsyncd. -- -- Simple example for default rsync, but executing moves through on the target. -- -- For more examples, see /usr/share/doc/lsyncd*/examples/ -- -- sync{default.rsyncssh, source="/var/www/html", host="localhost", targetdir="/tmp/htmlcopy/"} settings { logfile = "/var/log/lsyncd/lsyncd.log", statusFile = "/var/log/lsyncd/lsyncd-status.log", statusInterval = 5, maxProcesses = 2 } sync { default.rsync, source = "/data/new", target = "172.18.30.18::new", delete = 'running', delay = 5, rsync = { binary = "/usr/bin/rsync", archive = true, compress = false, verbose = true } } sync { default.rsync, source = "/data", target = "172.18.34.41::new", delete = 'running', exclude = "upload", delay = 5, rsync = { binary = "/usr/bin/rsync", archive = true, compress = false, verbose = true } }
对端rsyncd的配置如下:
# cat /etc/rsyncd.conf # /etc/rsyncd: configuration file for rsync daemon mode # See rsyncd.conf man page for more options. # configuration example: # uid = nobody # gid = nobody # use chroot = yes # max connections = 4 # pid file = /var/run/rsyncd.pid # exclude = lost+found/ # transfer logging = yes # timeout = 900 # ignore nonreadable = yes # dont compress = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2 # [ftp] # path = /home/ftp # comment = ftp export area uid = root gid = root 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 [new] path = /root ignore errors read only = false list = false hosts allow = 172.18.34.38 hosts deny = 0.0.0.0/32
0 评论