[rsync] linux rsync 安装

Posted flymaster_zw

tags:

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

linux rsync 安装

 

作者:flymaster

qq:908601287

blog:http://www.cnblogs.com/flymaster500/

 

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/ root@10.0.0.8:/tmp
pull:
rsync -avzP -e \'ssh -p 22\' root@10.0.0.8:/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
############################################

[root@backup-105 etc]# ps -ef|grep rsync|grep -v grep
root 3854 1 0 15:17 ? 00:00:00
rsync --daemon(启动rsync服务。程序)
[root@backup-105 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
[root@backup-105 etc]# ss -lntup|grep rsync
tcp LISTEN 0 5 :::873 :::* users:(("rsync",3854,5))
tcp LISTEN 0 5 *:873 *:* users:(("rsync",3854,3))

[root@backup-105 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)
[root@backup-105 etc]# useradd rsync -s /sbin/nologin -M
[root@backup-105 etc]# id rsync
uid=502(rsync) gid=502(rsync) 组=502(rsync)
[root@backup-105 /]# mkdir /backup
[root@backup-105 /]# chown -R rsync /backup/
[root@backup-105 /]# ls -ld /backup/
drwxr-xr-x. 2 rsync root 4096 9月 18 15:36 /backup/
echo "rsync_backup:oldboy" >/etc/rsync.password
[root@backup-105 etc]# cat /etc/rsync.password
rsync_backup:oldboy
chmod 600 /etc/rsync.password
[root@backup-105 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/rc.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...[USER@]HOST::DEST
rsync -avz /tmp/ rsync_backup@192.168.70.105::backup --password-file=/etc/rsync.password

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

 

 


以上是关于[rsync] linux rsync 安装的主要内容,如果未能解决你的问题,请参考以下文章

Linux下rsync的安装及简单使用

linux 下安装rsync

linux安装 rsync 客户端和相关权限认证

linux下rsync安装与配置

Linux下rsync命令用法

rsync 安装步骤、服务端、客户端、同步文件