Linux rsync目录同步功能实现
实现目标:
?
?A 服务器上 /opt/web 目录,与B服务器上 /opt/web目录实现同步。即:B主动与A进行同步。(A的文件会同步到B机器上)
?
OS: Reaht AS4
?
A Server? 192.168.1.2 /opt/web
B Server? 192.168.1.3 /opt/web
?
一. A Server config
?
1.rsync 系统自带, 需要使用 --deamon 方式进行启动,服务端口是 TCP 873
?
2. vi /etc/xinetd.d/rsync? 修改 disable =yes 为 disable =no ,修改后的文件如下
?
# default: off
# description: The rsync server is a good addition to an ftp server, as it \
#?????? allows crc checksumming etc.
service rsync
{
??????? disable = no
??????? socket_type???? = stream
??????? wait??????????? = no
??????? user??????????? = root
??????? server????????? = /usr/bin/rsync
??????? server_args???? = --daemon
??????? log_on_failure? += USERID
}
?
3. service?? xinetd?? restart,重启 xinted 服务
?
4. 编辑主要配置文件 /etc/rsyncd.conf (不存在则自己创建)
?
vi /etc/rsyncd.conf
?
uid = nobody
gid = nobody
use chroot = no
max connections = 4
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsyncd.lock
log file = /var/log/rsyncd.log
?
[web]
path = /opt/web
ignore errors