rsync同步配制

一、下载安装rsynchtml

wget http://rsync.samba.org/ftp/rsync/rsync-3.1.2.tar.gz
tar zxvf rsync-3.1.2.tar.gz    
cd rsync-3.1.2   
./configure --prefix=/usr  ;make ;make install

   二、配制rsync.confnginx

# vim /etc/rsyncd/rsyncd.confvim

uid = nobody
gid = nobody
port = 873              # 指定运行端口,默认是873,您能够本身指定
hosts allow = 192.168.102.101     # 容许访问的客户机,多个以逗号隔开
#hosts deny = 0.0.0.0/32       #拒绝访问的
use chroot = no	
max connections = 10
timeout = 500000
pid file = /var/run/rsyncd.pid   ##pid文件的存放
lock file = /var/run/rsync.lock   ##锁文件的存放位置
log file = /var/log/rsyncd.log   ##日志记录文件的存放
#motd file = /etc/rsyncd.motd   #欢迎
secrets file = /etc/rsyncd/rsyncd.passwd       ## 指定认证文件
## 上面这段是全局配置,下面的模块能够有
[test]												 ## 模块名字,本身命名
path = /home/rsync/test   #指定文件目录所在位置,这是必须指定
comment = rsync files         ##注释
ignore errors                 ##忽略IO
read only = no
#list = no                   ## 是否把rsync 服务器上提供同步数据的目录显示
## 下面这一行,同步验证时用的帐号,若是没有这项就是匿名同步,client同步时不用用户名也能同步。
auth users = rsync

三、生成密码文件bash

#vim /etc/rsyncd/rsyncd.passwd服务器

rsync:123456@789

四、文件权限修改ui

chmod 644 /etc/rsyncd/rsyncd.conf
chmod 600 /etc/rsyncd/rsyncd.passwd

五、启动rsync日志

/usr/bin/rsync --daemon  --config=/etc/rsyncd/rsyncd.conf

也能够将上面的命令写到/etc/rc.local里,实现开机自启动rsync服务code

六、客户端配制htm

基本同服务器的配制.get

七、手动同步

rsync -avzP david@192.168.1.16::test  /tmp/david/

八、自动同步加入定时任务里

0 9 * * *       /usr/bin/rsync -vzrtopg --delete  --progress rsync@192.168.1.16::test /home/data/nginx/html/ --password-file=/etc/rsyncd/rsyncd.passwd
相关文章
相关标签/搜索