RSYNCrsync部署

Posted flymaster_zw

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了RSYNCrsync部署相关的知识,希望对你有一定的参考价值。

rsync作用比较:
远程拷贝:scp
本地拷贝:cp
删除功能:rm

rsync可以是一个网络服务(port socket)
rsync命令是客服端命令:
第一种工作模式:local
rsync -avz /etc/hosts /tmp/ ===cp
rsync -avz --delete /null/ /tmp/ ===rm
第二种工作模式:remote shell
push:
rsync -avzP -e ‘ssh -p 22‘ /tmp/ [email protected]:/tmp
pull:
rsync -avzP -e ‘ssh -p 22‘ [email protected]:/tmp /tmp/


操作流程
1.yum install -y rsync
2.rsync --version
3.touch /etc/rsyncd.conf
4.vi /etc/rsyncd.conf
#Rsync server
#created by oldboy
##rsyncd.conf start##
uid = rsync
gid = rsync
use chroot =no
max connections =2000
timeout =600
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
ignore errors
read only = false
list = false
hosts allow = 192.168.70.0/24
hosts deny = 0.0.0.0/32
auth users = rsync_backup
secrets file = /etc/rsync.password
########################################
[backup]
comment = www by old0boy
path = /backup
############################################

[[email protected] etc]# ps -ef|grep rsync|grep -v grep
root 3854 1 0 15:17 ? 00:00:00
rsync --daemon(启动rsync服务。程序)
[[email protected] etc]# netstat -lntup|grep rsync
tcp 0 0 0.0.0.0:873 0.0.0.0:* LISTEN 3854/rsync
tcp 0 0 :::873 :::* LISTEN 3854/rsync
[[email protected] etc]# ss -lntup|grep rsync
tcp LISTEN 0 5 :::873 :::* users:(("rsync",3854,5))
tcp LISTEN 0 5 *:873 *:* users:(("rsync",3854,3))

[[email protected] etc]# lsof -i :873
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
rsync 3854 root 3u IPv4 15456 0t0 TCP *:rsync (LISTEN)
rsync 3854 root 5u IPv6 15457 0t0 TCP *:rsync (LISTEN)
[[email protected] etc]# useradd rsync -s /sbin/nologin -M
[[email protected] etc]# id rsync
uid=502(rsync) gid=502(rsync) 组=502(rsync)
[[email protected] /]# mkdir /backup
[[email protected] /]# chown -R rsync /backup/
[[email protected] /]# ls -ld /backup/
drwxr-xr-x. 2 rsync root 4096 9月 18 15:36 /backup/
echo "rsync_backup:oldboy" >/etc/rsync.password
[[email protected] etc]# cat /etc/rsync.password
rsync_backup:oldboy
chmod 600 /etc/rsync.password
[[email protected] etc]# ll /etc/rsync.password
-rw-------. 1 root root 20 9月 18 15:43 /etc/rsync.password

rsync server:配置步骤
1.vi /etc/rsyncd.conf
#Rsync server
#created by oldboy
##rsyncd.conf start##
uid = rsync
gid = rsync
use chroot =no
max connections =2000
timeout =600
pid file = /var/run/rsyncd.pid
lock file = /var/run/rsync.lock
log file = /var/log/rsyncd.log
ignore errors
read only = false
list = false
hosts allow = 192.168.70.0/24
hosts deny = 0.0.0.0/32
auth users = rsunc_backup
secrets file = /etc/rsync.password
########################################
[backup]
comment = www by old0boy
path = /backup
############################################


2.创建rsync用户、共享目录/backup
useradd rsync -s /sbin/nologin -M
id rsync

mkdir /backup
chown -R rsync /backup
ll-d /backup/

3.创建密码文件
echo "rsync_backup:oldboy" >/etc/rsync.password
chmod 600 /etc/rsync.password

4.rsync --daemon
netstat -lntup|grep rsync
ps -ef|grep rsync|grep -v grep

5.加入开机自启动
echo "rsync --daemon" >>/etc/ra.local
cat /etc/rc.local
rsync:客服端
1.创建密码文件
echo "oldboy" >/etc/rsync.password
chmod 600 /etc/rsync.password
ls -l /etc/rsync.password
2.rsync
push:
rsync[OPTION...] SRC...[[email protected]]HOST::DEST
rsync -avz /tmp/ [email protected]::backup - -password-file=/etc/rsync.password

rsync --daemon --address=192.168.70.105
killall(pkill)

 

 


以上是关于RSYNCrsync部署的主要内容,如果未能解决你的问题,请参考以下文章

rsync 服务部署详解

rsync

rsync提权

融合部署独立部署,两种方式的区别

Golang项目部署3,容器部署

SSIS2012 项目部署模型