在分布式web结构中,服务器间的文件同步是必不可缺的操作了。最经常用到的就是rsync命令和服务了。
首先需要安装rsync,然后进行配置
<pre class="brush:bash;"> cp /usr/share/doc/rsync/examples/rsyncd.conf /etc/
```
<h4>
修改默认配置文件</h4>
<pre class="brush:plain;"> # sample rsyncd.conf configuration file
# GLOBAL OPTIONS
#motd file=/etc/motd
#日志文件地址
log file=/var/log/rsyncd
# for pid file, do not use /var/run/rsync.pid if
# you are going to run rsync out of the init.d script.
pid file=/var/run/rsyncd.pid
#syslog facility=daemon
#socket options=
# MODULE OPTIONS
#同步标识
[rsync]
comment = public archive
path = /usr/local/www
use chroot = yes
# max connections=10
lock file = /var/lock/rsyncd
# the default for read only is yes...
#读写权限
read only = no
list = yes
#写入文件用户、用户组
uid = 0
gid = 0
# exclude =
# exclude from =
# include =
# include from =
#授权用户列表
auth users = 用户名
#授权用户信息文件
secrets file = /etc/rsyncd.pass
strict modes = yes
# hosts allow =
# hosts deny =
ignore errors = no
ignore nonreadable = yes
transfer logging = no
# log format = %t: host %h (%a) %o %f (%l bytes). Total %b bytes.
timeout = 600
refuse options = checksum dry-run
dont compress = *.gz *.tgz *.zip *.z *.rpm *.deb *.iso *.bz2 *.tbz
```
<h4>
创建用户授权文件</h4>
<pre class="brush:bash;"> vim rsyncd.pass
```
<p>
</p>
<h4>
修改用户授权文件</h4>
<pre class="brush:plain;"> 用户名:密码
```
<h4>
修改用户授权文件权限</h4>
<pre class="brush:bash;"> chmod 600 rsyncd.pass
```
Ubuntu 配置 rsync 同步 服务 分布 命令