<pre name="code" class="sql">rsync 服务器部署在192.168.32.119
rsync client 在192.168.32.117
1.
v-lhb-db03:/etc# cat rsyncd.conf
#[global]
uid = root
gid = root
use chroot = no
max connections = 4
port = 873
pidfile = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
logfile = /var/log/rsync/rsyncd.log
#[modules]
[news]
###服务器需要同步的目录
path = /var/www/zjzc-web-frontEnd/news
auth users = root
read only = no
hosts allow = *
secrets file = /etc/rsyncd.secrets
#[modules]
[contract]
###服务器需要同步的目录
path = /var/www/zjzc-web-frontEnd/products/contract
auth users = root
read only = no
hosts allow = *
secrets file = /etc/rsyncd.secrets
#[modules]
[index]
###服务器需要同步的目录
path = /var/www/zjzc-web-frontEnd
auth users = root
read only = no
hosts allow = *
secrets file = /etc/rsyncd.secrets
2.在服务器上创建下面的目录:
mkdir -p /var/www/zjzc-web-frontEnd/news
mkdir -p /var/www/zjzc-web-frontEnd/products/contract
mkdir -p /var/www/zjzc-web-frontEnd
3. 服务端设置用户密码:
jrhwpt02:/etc/scripts/nmon# cat /etc/rsyncd.secrets
root:xxxx
chmod 600 /etc/rsyncd.secrets
4.启动服务端 /usr/local/rsync/bin/rsync --daemon --config=/etc/rsyncd.conf
5.查看服务器配置:
v-lhb-db03:/etc# rsync rsync://192.168.32.119
news
contract
index
-------------------------------------------------------------------------------------------
客户端配置:
1.客户端同步(也要先取得rsync执行程序,注意密码文件/etc/rsyncd.secrets 应chmod 600 /etc/rsyncd.secrets,里面只写密码)
jrhnpt01:/nfs01/appdata_backup# ls -ltr /etc/rsyncd.secrets
-rw------- 1 root root 11 Mar 23 09:34 /etc/rsyncd.secrets
jrhnpt01:/nfs01/appdata_backup# cat /etc/rsyncd.secrets
xxxx
客户机发起同步:
$RSYNC -avz --password-file=/etc/rsyncd.secrets $SRC_FS1 ${DES_USER}@${DES_HOST1}::${DES_MODULE1}
v-lhb-db01:/etc# /usr/bin/rsync -avz --password-file=/etc/rsyncd.secrets /var/www/zjzc-web-frontEnd/index/ root@192.168.32.119::index
@ERROR: auth failed on module index
rsync error: error starting client-server protocol (code 5) at main.c(1503) [sender=3.0.6]
服务器权限问题:
v-lhb-db03:/usr/local/rsync# ls -ltr /etc/rsyncd.secrets
-rw-r--r-- 1 root root 16 May 11 15:36 /etc/rsyncd.secrets
v-lhb-db03:/usr/local/rsync# chmod 600 /etc/rsyncd.secrets
同步方向:
客户端发起,从客户机同步到服务器
rsync -avz --password-file=/etc/rsyncd.secrets /var/www/zjzc-web-frontEnd/news/ root@192.168.32.119::news
从客户机发起,客户机同步到rsync服务器192.168.32.119
客户端发起,从服务器同步到客户机
rsync -avz --password-file=/etc/rsyncd.secrets root@192.168.32.119::news /var/www/zjzc-web-frontEnd/news/
从客户机发起,从rsync服务器192.168.32.119同步到客户端