Rsync守护进程方式远程部署
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了Rsync守护进程方式远程部署相关的知识,希望对你有一定的参考价值。
2、Rsync守护进程方式远程部署以守护进程(Socket)的方式传输数据
操作系统: [[email protected] ~]# cat /etc/redhat-release CentOS Linux release 7.3.1611 (Core) 内核版本: [[email protected] ~]# uname -r 3.10.0-514.el7.x86_64
主机网络参数设置:
Hostname | 网卡eth0 | 默认网关 | 用途 |
---|---|---|---|
node1 | 192.168.1.71 | 192.168.1.1 | rsync服务端 |
node2 | 192.168.1.72 | 192.168.1.1 | rsync客户端 |
node3 | 192.168.1.73 | 192.168.1.1 | rsync客户端 |
具体需求:
要求在node1上以rsync守护进程的方式部署rsync服务,使得所有rsync节点客户端主机,可以在rsync的server端拉去数据。 1、安装rsync [[email protected] ~]# yum install -y rsync [[email protected] ~]# rpm -q rsync rsync-3.0.9-17.el7.x86_64 2、配置rsync [[email protected] ~]# cat /etc/rsyncd.conf uid = rsync gid = rsync use chroot = no #囚牢 max connections = 200 timeout = 300 pid file = /var/run/rsyncd.pid lock file = /var/run/rsyncd.lock log file = /var/log/rsyncd.log [cce] path = /data/ ignore errors #遇到错误自动忽略 read only = false #可写 list = false #不允许列出 hosts allow = 192.168.1.0/24 #允许同步的网段 hosts deny = 0.0.0.0/32 #拒绝的网段 auth users = caichangen #虚拟用户 secrets file = /etc/rsync.passw #虚拟用户的密码据通过rsync的方式备份到数据备份服务器node1上。 3、配置rsync访问用户的账号密码 [[email protected] ~]# echo "caichangen:caichangen" > /etc/rsync.passwd [[email protected] ~]# chmod 600 /etc/rsync.passwd 4、创建专属用户、目录并授权、启动 [[email protected] ~]# useradd -r rsync [[email protected] ~]# mkdir /data [[email protected] ~]# chown rsync:rsync /data/ [[email protected] ~]# systemctl start rsyncd 5、客户端 [[email protected] ~]# yum install -y rsync 6、配置客户端在访问服务端需要用到的密码 [[email protected] ~]# echo "caichangen" > /etc/rsync.passwd [[email protected] ~]# chmod 600 /etc/rsync.passwd 7、测试拉取数据到rsync服务端 语法:rsync -avz [email protected]_IP::Rsync_object_name local_dir [[email protected] ~]# rsync -avz --password-file=/etc/rsync.passwd [email protected]::cce /tmp/ receiving incremental file list ./ fstab sent 81 bytes received 482 bytes 375.33 bytes/sec total size is 552 speedup is 0.98 [[email protected] ~]# ls -l /tmp/ total 4 -rw-r--r--. 1 997 995 552 May 13 15:47 fstab 8、测试推送数据到服务端 [[email protected] ~]# mkdir test [[email protected] ~]# touch test/{a..g} [[email protected] ~]# rsync -avz --password-file=/etc/rsync.passwd /root/test/ [email protected]::cce sending incremental file list ./ a b c d e f g sent 323 bytes received 144 bytes 934.00 bytes/sec total size is 0 speedup is 0.00 9、查看数据是否推送成功 [[email protected] ~]# ls /data/ a b c d e f fstab g rc.local 10、使用rsync协议来推送 [[email protected] ~]# rsync -avz --password-file=/etc/rsync.passwd rsync://[email protected]/cce /tmp/ receiving incremental file list ./ a b c d e f g sent 195 bytes received 451 bytes 1292.00 bytes/sec total size is 1025 speedup is 1.59 11、使用rsync协议来拉取数据 [[email protected] ~]# mkdir test [[email protected] ~]# touch test/{1..10} [[email protected] ~]# rsync -avz --password-file=/etc/rsync.passwd /root/test/ rsync://[email protected]/cce sending incremental file list ./ 1 10 2 3 4 5 6 7 8 9 sent 450 bytes received 201 bytes 434.00 bytes/sec total size is 0 speedup is 0.00
本文出自 “Char” 博客,请务必保留此出处http://charcce.blog.51cto.com/4255555/1926333
以上是关于Rsync守护进程方式远程部署的主要内容,如果未能解决你的问题,请参考以下文章