[Linux][lsyncd]CentOS7からUbunru16.04への同期

CentOS7 から Ubuntuにlsync

今回の環境

  • master 10.0.0.1
    — CentOS6
  • slave 10.0.0.2
    — Ubuntu 16.04

master

install

GITから持ってくるのがちょっと面倒だったので、RPMForgeを利用してパッケージのインストール
rpmforgeの最新版は適宜変わるので、最新版を持ってくること
http://repoforge.org/use/

[root@master ~]# yum install lsyncd --enablerepo=rpmforge
[root@master ~]# rpm -ivh http://repository.it4i.cz/mirrors/repoforge/redhat/el7/en/x86_64/rpmforge/RPMS/rpmforge-release-0.5.3-1.el7.rf.x86_64.rpm

コンフィグファイルの作成

[root@master ~]# vim /etc/lsyncd.conf
[root@master ~]# cat /etc/lsyncd.conf
----
-- User configuration file for lsyncd.
--
-- Simple example for default rsync.
--
settings {
        logfile    = "/var/log/lsyncd.log",
        statusFile = "/tmp/lsyncd.stat",
        statusInterval = 1,
        maxProcesses = 2,
        nodaemon     = false,
        insist       = 1,
}

sync{
        default.rsync,
        source="/home/bkup/",
        target="10.0.0.2:/home/bkup",
        rsync = {
          _extra = {  "-a" },
        }
}

Ubuntu1606の場合 (slave)

slave側は rsyncだけ入っていればOK

インストール

 root@slave:~# mkdir -p /home/bkup/
 root@slave:~# apt-get install rsync
 root@slave:~# vim /etc/rsyncd.conf
  uid = root
  gid = root
  read only = no
  log file = /var/log/rsyncd.log
  pid file = /var/run/rsyncd.pid 

  [test]
  path = /data/
  hosts allow = localhost 10.0.0.1/32
  hosts deny = *
  read only = false

起動&自動起動

root@slave:~# systemctl start rsync.service
root@slave:~# systemctl status rsync.service
● rsync.service - fast remote file copy program daemon
   Loaded: loaded (/lib/systemd/system/rsync.service; disabled; vendor preset: e
   Active: active (running) since Fri 2017-03-31 11:30:35 JST; 5s ago
 Main PID: 22906 (rsync)
   CGroup: /system.slice/rsync.service
           mq22906 /usr/bin/rsync --daemon --no-detach

Mar 31 11:30:35  systemd[1]: Started fast remote file copy pr
lines 1-8/8 (END)

動作確認

master側でlsyncdの起動

[root@www ~]# systemctl start lsyncd
[root@www ~]# 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 月 2018-03-26 21:45:45 JST; 2s ago
 Main PID: 30883 (lsyncd)
   CGroup: /system.slice/lsyncd.service
           └─30883 /usr/bin/lsyncd -nodaemon /etc/lsyncd.conf

 3月 26 21:45:45 www systemd[1]: Started Live Syncing (Mirror) Daemon.
 3月 26 21:45:45 www systemd[1]: Starting Live Syncing (Mirror) Daemon...
 3月 26 21:45:45 www lsyncd[30883]: @ERROR: chroot failed
 3月 26 21:45:45 www lsyncd[30883]: rsync error: error starting client-server prot....9]
Hint: Some lines were ellipsized, use -l to show in full.

ログの確認

[root@www ~]# tail -f /var/log/lsyncd.log 
Mon Oct  1 01:00:17 2018 Normal: Finished a list after exitcode: 0
Mon Oct  8 01:00:16 2018 Normal: Calling rsync with filter-list of new/modified files/dirs
/20181008/
/
/20181008/kusanagi_20181008.tar.gz
/20181008/kusanagi_20181008.sql
/20181008/bkup.log
Mon Oct  8 01:00:17 2018 Normal: Finished a list after exitcode: 0


Leave a Reply

Your email address will not be published. Required fields are marked *

備忘録の覚書 © 2017 Frontier Theme