debian 安裝配置lsyncd

安裝lsyncd

root@mysql-2:~# apt-get  install -y lsyncd

整理須要同步的服務器

debian 安裝配置lsyncd

整理配置文件

root@mysql-2:/data/lsyncd# cat /etc/lsyncd.conf 
  settings {
      logfile ="/data/mysql/project_nginx.log",
      statusFile ="/data/lsyncd/lsyncd.status",
      inotifyMode = "CloseWrite",
      maxProcesses = 8,
      -- maxConnections = 4,
      -- delay = 10,
      -- excludeFrom = file,
      -- excludeFrom 排除選項
      }
  sync {
      default.rsyncssh,
      source    = "/data/docker-compose",
      host      = "192.168.1.23",
      targetdir = "/data/docker-compose",
      -- exclude = "/data/www/public_html/config.inc.php",  #排除此文件不一樣步
      -- maxDelays = 5,累計到多少所監控的事件激活一次同步,即便後面的delay延遲時間還未到
      -- delay = 2,
      -- init = false,這是一個優化選項,當init = false,只同步進程啓動之後發生改動事件的文件,原有的目錄即便有差別也不會同步。默認是true
      rsync    = {
          binary = "/usr/bin/rsync",
          archive = true,
          compress = true,
          verbose   = true,
          -- _extra = {"--bwlimit=2000"},
          },
      ssh  = {
          binary = "/usr/bin/ssh",
          port  =  22,
          }
      }
  sync {
      default.rsyncssh,
      source    = "/data/docker-compose",   #源目錄
      host      = "192.168.1.43",
      targetdir = "/data/docker-compose",   #目標目錄
      -- exclude = "/data/www/public_html/config.inc.php",
      -- maxDelays = 5,累計到多少所監控的事件激活一次同步,即便後面的delay延遲時間還未到
      -- delay = 2,
      -- init = false,這是一個優化選項,當init = false,只同步進程啓動之後發生改動事件的文件,原有的目錄即便有差別也不會同步。默認是true
      rsync    = {
          binary = "/usr/bin/rsync",
          archive = true,
          compress = true,
          verbose   = true,
          -- _extra = {"--bwlimit=2000"},
          },
      ssh  = {
          binary = "/usr/bin/ssh",
          port  =  22,
          }
      }

啓動測試

root@mysql-2:/data/lsyncd# lsyncd /etc/lsyncd.conf

測試

目錄裏面有問題或者新創建都會同步,注意沒有目錄會本身建立目錄同步
相關文章
相關標籤/搜索