Centos6 使用rsync同步数据操作方法
服务端:
安装服务:
yum install xinetd rsync -y
vi /etc/xinetd.d/rsync # 编辑配置文件,将disable = yes 改成no
vi /etc/rsyncd.conf # 编辑rsync配置文件:
- uid = root
- gid = root
- address = 58.218.92.1 #监听IP地址,填写本机IP
- port = 873 #使用的端口号
- hosts allow = 222.187.224.27 #允许访问rsync服务的IP地址
- hosts deny= * #拒绝所有其他
- IP timeout = 300 #超时时间
- use chroot = yes #锁定允许访问的目录
- max connections = 5
- pid file = /var/run/rsyncd.pid
- lock file = /var/run/rsync.lock
- log file = /var/log/rsyncd.log #日志文件路径
- motd file = /etc/rsyncd.motd #欢迎文件路径
- [turbomail]
- path =/data/rsync
- comment = hello rsync
- red only = yes
- list = yes
- auth users = rsync
- secrets file =/etc/rsync.passwd
创建欢迎文件:
echo "welcome to rsync" > /etc/rsync.motd
创建密码文件:
vi /etc/rsync.passwd
- rsync:passwdopendoor
chmod 600 /etc/rsync.passwd
重启xinetd,并开机启动。
/etc/init.d/xinetd restart
chkconfig xinetd on
客户端:
echo "password123" > /root/rsync.passwd
chmod 600 /etc/rsync.passwd
rsync -avz rsync@58.218.92.1::rsync --password-file=/root/rsync.passwd /rsync
--bwlimit=300 #每秒传输k。
`date +"%Y%m%d"` #以日期为文件夹
如果您的问题仍未解决,还可以加入服务器在线技术交流QQ群:8017413寻求帮助。