Sersync + rsyncはリアルタイムのファイル同期を実現します

1.はじめに
rsyncは、ローカルまたはリモートのデータミラーリングと同期バックアップを実現できる、オープンソースの高速で多機能な優れたツールです。複数のプラットフォームに適用可能で、完全バックアップと増分バックアップを実現できます。
sersyncは、inotify-toolsと同様に、inotifyに基づいて開発されています。変更された(追加、削除、変更を含む)特定のファイルまたはディレクトリの名前を監視対象ディレクトリに記録し、rsyncを使用して同期する場合、変更されたファイルまたはディレクトリのみが同期されます。
2、rsyncデプロイメント
1.環境の説明

オペレーティング・システム IPアドレス サービス
CentOS7 172.16.50.101 rsync-server
CentOS7 172.16.50.101 sersync-client

2.ソフトウェアパッケージ
yuminstall -yrsyncをインストール
します
。3 。構成vim / etc / rsyncd.confを変更します。

#指定启动进程的用户
uid = root
#指定启动进程的组
gid = root 
#指定端口,默认873
port=873
#安全相关
use chroot = no
#最大连接数,0表示不限制
max connections = 3
#是否监测密码文件的权限
strict modes = yes
#指定pid文件
pid file= /var/run/rsyncd.pid
#指定日志文件
log file= /var/log/rsyncd.log
#指定锁文件
lock file=/var/run/rsyncd.sock
#指定欢迎信息文件
motd file=/etc/rsyncd/rsyncd.motd
#权限为读写
read only=no
#允许访问网段
hosts allow=172.16.120.0/24
#拒绝所有
hosts deny=*
#定义共享模块
[www] 
#指定共享路径
path=/var/www/html
#忽略错误
ignore errors=yes
#允许别人看以
list=yes
#认证用户
auth users=backuper
#密码文件
secrets file= /etc/rsyncd.secrets

4.パスワードファイルを作成します
echo "backuper:123456"> /etc/rsyncd.secrets
chmod 600 /etc/rsyncd.secrets5
。サービスを開始します
rsync--daemon --config = / etc / rsyncd.conf
3.Sersyncのデプロイ
1.依存パッケージをインストール
yumをインストール-yのrsync
2.取得インストールパッケージ
のwget https://raw.githubusercontent.com/orangle/sersync/master/release/sersync2.5.4_64bit_binary_stable_final.tar.gz
3.解凍し
たtar FXZ sersync2.5.4_64bit_binary_stable_final。tar.gz-C/ usr / local /
ln -s / usr / local / GNU-Linux-x86 / / usr / local / sersync4
。構成
vim / usr / local / sersync / confxmlを変更します。 xml

<sersync>
#同步的路径,本地的目录
        <localpath watch="/var/www/html">
#rsync服务器的ip地址和rsync配置文件里面定义的模块
         <remote ip="172.16.120.101" name="www"/>
        </localpath>
        <rsync>
            <commonParams params="-artuz"/>
#rsync同步认证设置的内容,user指定用户名,password指定存放密码的文件路径
            <auth start="true" users="backuper" passwordfile="/etc/rsync.pw"/>
        </rsync>
</sersync>

5.パスワードファイルを作成します
echo "123456"> /etc/rsync.pw
chmod 600 /etc/rsync.pw6
。サービスを開始します
/ usr / local / sersync / sersync2 -d -r -o / usr / local / sersync / confxml .xml

おすすめ

転載: blog.51cto.com/7965676/2606826