rsync配置
来源:互联网 发布:centos 7 32位下载 编辑:程序博客网 时间:2024/05/01 17:39
- 目录
- 背景
- rsync简介
- rsync服务器配置
- 必要软件安装
- 配置文件
- rsync客户端配置
- 客户端与服务器端同步命令
背景
项目组每个人需要从网上下载代码更新,效率低。mirror代码库文件数量很大,使用rsync可以保持文件时间属性,只同步更新的模块,搭建一台rsync服务器,每天定时同步代码,组员再与服务器同步mirror。
操作系统: ubuntu14.04
Rsync服务器:ubuntu14.04
Rsync客户端:ubuntu14.04
rsync简介
rsync,remote synchronize是一款实现远程同步功能的软件,它在同步文件的同时,可以保持原来文件的权限、时间、软硬链接等附加信息。 rsync是用 “rsync 算法”提供了一个客户机和远程文件服务器的文件同步的快速方法,来使本地和远程两个主机之间的文件达到同步,这个算法只传送两个文件的不同部分,而不是每次都整份传送,因此速度相当快。
rsync服务器配置
必要软件安装
$ sudo apt-get install rsync xinetd ssh
默认情况下ubuntu是已经安装了rsync的,rsync服务默认是没有启动的,修改一下配置文件:
$ sudo vi /etc/default/rsync
RSYNC_ENABLE=true #false改为true
配置文件
rsync主要有以下三个配置文件:
rsyncd.conf(主配置文件)
rsyncd.secrets(密码文件)
rsyncd.motd(rysnc服务器信息)
- rsyncd.conf(主配置文件)
该文件默认不存在,请创建它:
$ sudo vi /etc/rsyncd.conf
# Distributed under the terms of the GNU General Public License v2 # Minimal configuration file for rsync daemon # See rsync(1) and rsyncd.conf(5) man pages for help #This will log every file transferred - up to 85,000+ per user, per sync #transfer logging = yes # This line is required by the /etc/init.d/rsyncd script pid file = /var/run/rsyncd.pid //pid文件路径 #This will give you a separate log file log file = /var/log/rsync.log //指定lock文件 motd file = /etc/rsyncd.motd //指定欢迎消息文件 port = 873 #uid = nobody //rsync以什么用户身份启动 #gid = nobody //rsync以什么用户组身份启动 uid = root gid = root use chroot = no read only = yes //是否只读 #limit access to private LANs #hosts allow=192.168.1.2 //允许的IP段 #hosts deny=* max connections = 10 //最大连接数 secrets file = /etc/rsyncd.secrets //指定用户密码的文件 list = yes log format = %t %a %m %f %b syslog facility = local3 timeout = 300 [mirror] //模块名 path = /home/mirror //模块路径 list=yes //是否允许列表 auth users = zheng //认证的用户,服务器必须存在这个系统用户 comment = This is a mirror git //描述信息,可以任意填写 [cut_mirror] path = /home/mirror list = yes auth users = zheng comment = This is a cut_mirror git #exclude = exclude from = /home/exclude.txt //将不想同步的文件(相对路径)写到exclude.txt文件中,
- rsyncd.secrets(密码文件)
$ sudo vi /etc/rsyncd.secrets
服务器密码格式
hostname:password
例如服务器名为:zheng,输入以下内容并加权
zheng:123456
$ chmod 600 /etc/rsyncd.secrets
- rsyncd.motd(rysnc服务器信息)
$ sudo vi /etc/rsyncd.motd
++++++++++++++++++++++++++
Welcome
Mirror about 300GB
Cut_mirror about 100GB
++++++++++++++++++++++++++
- 启动rsync服务
$ services rsync start
rsync客户端配置
$ sudo vi /etc/rsyncd.pwd
只输入服务器端设置的密码: 123456
然后把rsyncd.pwd加权
$ sudo chown user:user /etc/rsyncd.pwd$ sudo chmod 600 /etc/rsyncd.pwd
客户端与服务器端同步命令
列出服务器可以同步的模块:$ rsync --list-only mirror@192.168.1.1::同步:$ rsync -azv --delete --progress --password-file=rsyncd.secrets mirror@192.168.1.1::test <your path>
- rsync 配置
- rsync 配置
- rsync配置
- rsync配置
- rsync 配置
- 配置rsync
- rsync 配置
- rsync 配置
- rsync配置
- rsync配置
- rsync配置
- rsync配置
- rsync配置
- rsync配置
- rsync+ssh配置详解
- RSync服务器配置
- rsync安装配置
- rsync安装配置
- 二叉树计算
- [AHK]石头剪刀布游戏
- 光环效应引发的认知误区
- 欧拉计划 16
- JS 调用后台变量的值
- rsync配置
- Spring Cache
- 两大数据库缓存系统实现对比
- Roman to Integer
- AJAX、XStream、JSON
- Java中为什么有的方法必须抛出异常,有的不用
- 404. Sum of Left Leaves*
- MongoDB 生态 - 客户端 Driver 支持
- lucene3.0 搜索结果排序+高亮展示