sersyncサービス展開

rsyncを第一に、展開
#yumはrsyncのインストール-y
#サービスのユーザーを作成します。useraddのrsyncの-s / sbinに/ nologinに-M(ホームディレクトリを作成しないでください)
vimの/etc/rsyncd.conf:#コンフィギュレーションファイルを作成します。
ID = ルート
GID = ルート
利用のchroot = いいえ
最大接続数 = 2000 
タイムアウト = 600 
のpid ファイル =の/ var / /実行rsyncd.pid 
ロックファイル =の/ var / /実行rsyncd.lockの
ログファイル =は/ var / log / rsyncd.log 
エラーは無視
読み取り専用 = falseの
リストを = 
のホストが許可 = 192.1681.0 / 24 
ホストが拒否 = 0.00.0 / 32 
認証ユーザー = rsync_backupの
秘密ファイル =の/ etc / rsync.password 

[テスト] 
コメント = テスト
パス = /データ/ テスト

[データ] 
コメント = データ
パス = /データ
#パスワードファイルの同期にrsyncを作成し、設定された権限に600
[ルート@の122_server〜]#はエコー " oldboy " >の/ etc / rsync.password 
[ルート@ 122_server〜]#のの/ etc / rsync.password 
oldboy 
[ルート@ 122_server〜]#のchmodの 600の/ etc / rsync.password 
[ルート@ 122_server〜]#北韓の/ etc / rsync.password 
 -rw ------- 1つのルートルート20 9月23  0951 /etc/rsync.password
#思い出させる(特に初心者の巨大なピットがあり、私は初心者ですので、私は知っているか私に聞かないでください):sersyncサーバのパスワードファイルの書き込み専用パスワードを、ユーザーの名前を書いていません。
クライアントへのファイルで、モニターの変更を推進している#Sersyncは、他のは比較的にrsyncサーバーで、そうでない場合は報告されます「@ERRORは:認証モジュールのテストに失敗しました」
#sersync客户端文件中要写用户名和密码:“echo "rsync_backup:oldboy"> /etc/rsync.password
#rsync客户端只需要安装和创建密码文件即可,密码文件中不需要用户名;(客户端安装方式参考以上步骤,此处略)
#启动服务:rsync --daemon
#加入开机自启
vim /etc/rc.local
#在文件末尾插入:rsync --daemon
#master与slave端都创建rsync同步目录(这里只用test做测试)
mkdir /data/test -p
#手动同步文件
rsync -avzP /data/test/001.txt [email protected]::test/ --password-file=/etc/rsync.password
"""
sending incremental file list
001.txt

sent 68 bytes  received 27 bytes  17.27 bytes/sec
total size is 0  speedup is 0.00
"""
#此处容易报错“@ERROR: auth failed on module test”(下面有可能导致此问题的的解决方案)
二、部署sersync
1、下载安装包:
2,部署软件
tar zxvf sersync2.5.4_64bit_binary_stable_final.tar.gz
mkdir -p /usr/local/sersync-2.5.4/{bin,conf,log}
cp GNU-Linux-x86/confxml.xml /usr/local/sersync-2.5.4/conf/
cp GNU-Linux-x86/sersync2 /usr/local/sersync-2.5.4/bin/
ln -s /usr/local/sersync-2.5.4/ /usr/local/sersync
#配置sersync
vim conf/confxml.xml
<sersync>
    <localpath watch="/data/test"> # 定义本地要同步的目录
        <remote ip="192.168.1.115" name="test"/> # 同步到哪台机器上 /data/test模块rsync端模块名字
    </localpath>
    <rsync>
        <commonParams params="-aruz"/>
        <auth start="true" users="rsync_backup" passwordfile="/etc/rsync.password"/>
       # 修改内容为 rsync的密码文件以及 同步所使用的账号
        <userDefinedPort start="false" port="874"/><!-- port=874 -->
        <timeout start="false" time="100"/><!-- timeout=100 -->
        <ssh start="false"/>
    </rsync>
    <failLog path="/usr/local/sersync/logs/rsync_fail_log.sh" timeToExecute="60"/><!--default every 60mins execute once-->
   # 当同步失败后,日志记录到/usr/local/sersync/logs/rsync_fail_log.sh文件中,并且每60分钟对失败的log进行重新同步
    <crontab start="false" schedule="600"><!--600mins-->
        <crontabfilter start="false">
            <exclude expression="*.php"></exclude>
            <exclude expression="info/*"></exclude>
        </crontabfilter>
    </crontab>
    <plugin start="false" name="command"/>
</sersync>

#启动服务

/usr/local/sersync/bin/sersync2 -d -r -o /usr/local/sersync/conf/confxml.xml

"""
------------------------------------------
rsync the directory recursivly to the remote servers once
working please wait...
execute command: cd /data/test && rsync -aruz -R --delete ./ [email protected]::test --password-file=/etc/rsync.password >/dev/null 2>&1
run the sersync:
watch path is: /data/test
"""
 
#@ERROR: auth failed on module test
#rsync error: error starting client-server protocol (code 5) at main.c(1503) [sender=3.0.6]
关于这个auth失败的问题,有以下可能的情况:
1、密码输入错误: 请再次确认你登录用户的密码无误 2、secrets file格式错误: secrets file的文件格式是 rsync_backup:oldboy 表示rsync_backup用户的rsync密码是oldboy 3、配置文件写错: 最坑爹的一个,看看自己模块配置下面的auth users、secrets file有没写错 4、secrets file权限问题 服务端的secrets file权限必须是600, 可以使用chmod 600 /data/test


5、secrets file文件拥有者与rsync运行者 服务端rsync服务是以什么用户运行,则必须保证secrets file文件拥有者必须是同一个 假设root运行rsync --daemon,则secrets file的owner也必须是root 6、如果是以--password-file=file的方式附带密码 确保客户端密码文件格式无误,与服务端的密码文件不同, 客户端的不用加上用户名,即直接是 oldboy

 

 
* 参考oldboy视频整理

おすすめ

転載: www.cnblogs.com/sparkss/p/11570644.html