rsync部署及使用

来源:互联网 发布:人力资源师网络课程 编辑:程序博客网 时间:2024/06/05 06:51
一、服务端配置
vi /etc/rsyncd.conf
 uid = root                       
 gid = root
 use chroot = no
 max connections = 40
 lock file=/var/run/rsyncd.lock
 log file = /var/log/rsyncd.log      
#exclude = lost+found/
 transfer logging = yes
 timeout = 900
 ignore nonreadable = yes          
 dont compress   = *.gz *.tgz *.zip *.z *.Z *.rpm *.deb *.bz2


# [ftp]
#        path = /home/ftp
#        comment = ftp export area
[backup]
# destination directory for copy
path = /root/rsyncdir
# hosts you allow to access
hosts allow = *
hosts deny = *
list = true
auth users=rsync
secrets file=/etc/
uid = root
gid = root
read only = false
[sync1]
path = /etc
hosts allow = *
hosts deny = *
list = true
auth users=rsync
secrets file=/etc/rsyncd.passwd
uid = root
gid = root
read only = false

2.创建密钥文件
echo 'rsync:123456'>/etc/rsyncd.passwd   //文件用户名和路径为上面定义,别写错,密码自己定
chmod 600 /etc/rsyncd.passwd        //修改权限
3. 启动服务
systemctl start rsyncd
二、客户端配置
1.创建密码文件   
echo '123456' >>/etc/rsyncd.passwd     //注意这里只需要服务器rsyncd.passwd 中的密码
chmod 600 /etc/rsyncd.passwd
----将本地文件上传至服务端
rsync -avz --password-file=/etc/rsyncd.passwd --progress --delete /home/test/balance.log rsync@slave1::backup
----将服务端文件下载至客户端
rsync -avz --password-file=/etc/rsyncd.passwd --progress --delete rsync@slave1::backup /home/test
---同步指定文件 /etc/rc.local
/data/file.list 添加内容:
 rc.local
rsync -avz --password-file=/etc/rsyncd.passwd --progress --delete rsync@slave1::sync1 --files-from=/data/file.list /home/test

原创粉丝点击