Data transfer in Rsync's daemon mode of operation

Source: Internet
Author: User

First, Introduction

rsync has three main ways of working:

1. Data transfer between a single host local (similar to the functions of the CP command)

2, the use of rcp,ssh and other channels to transfer data (similar to the function of the SCP command)

3. Transfer data in a daemon (socket) mode (the important function ofrsync itself)

This is described in the third mode of processing.

This example prepares two machines, the server-side 10.0.0.41-backup, and the client 10.0.0.100-oldboy.

second, start and check on the service side rsync Service

[[Email protected]]# rsync--deamon # start the service

[[Email protected]]# ps-ef|grep rsync|grep-v grep

Root 3648 1 0 19:10? 00:00:00 Rsync--daemon

[Email protected]]# netstat-lntup|grep rsync

TCP 0 00.0.0.0:873 0.0.0.0:* LISTEN 3648/rsync

TCP 0 0:::873:::* LISTEN 3648/rsync

[Email protected]]# ss-lntup|grep rsync

TCP LISTEN 0 5::: 873:::* Users: (("rsync", 3648,5)

TCP LISTEN 0 5 *:873 *:* Users: (("rsync", 3648,4)

[Email protected]]# lsof-i: 873 # Default Port

COMMAND piduser FD TYPE devicesize/off NODE NAME

rsync 3648root 4u IPv4 14421 0t0 TCP *:rsync (LISTEN)

rsync 3648root 5u IPv6 14422 0t0 TCP *:rsync (LISTEN)

Third, service-side configuration

[Email protected] ~]# cat/etc/rsyncd.conf

#rsync_config_______________start

# #rsyncd. conf start##

UID = rsync

GID = rsync

Use chroot = no

Max connections = 200

Timeout = 300

PID file =/var/run/rsyncd.pid

Lock file =/var/run/rsync.lock

Log file =/var/log/rsyncd.log

[Backup]

Path =/backup/

Ignore errors

Read Only = False

List = False

Hosts allow = 172.16.1.0/24

#hosts allow = 10.0.0.0/24

Hosts Deny = 0.0.0.0/32

Auth users = Rsync_backup

Secrets file =/etc/rsync.password

#rsync_config_______________end

# The above hosts allow IP does not distinguish between internal and external network, as long as the corresponding network segment can be.

# Restart rsync after setting up the above file

[Email protected] ~]# useradd rsync-s/sbin/nologin-m

[Email protected] ~]# tail-1/etc/passwd

Rsync:x:502:502::/home/rsync:/sbin/nologin

[[email protected] ~]# ID rsync

uid=502 (rsync) gid=502 (rsync) xé=502 (rsync)

[Email protected] ~]# Mkdir/backup

[Email protected] ~]# chown-r rsync.rsync/backup/

[email protected] ~]# ls-ld/backup/

Drwxr-xr-x 2 rsync rsync 4096 5 19:41/backup/

[[Email protected] ~] #echo "Rsync_backup:oldboy" >/etc/rsync.password

[email protected] ~]# Cat/etc/rsync.password

Rsync_backup:oldboy

#/etc/rsync.password [ Email protected] ~]# cat/etc/rsyncd.conf

Auth users = Rsync_backup

Secrets file =/etc/rsync.password

# Put the password in the/etc/rsync.password because you don't want to interact anymore.

# When others come, will even secrets file=/etc/rsync.password This file, will use Authusers = rsync_backup this user.

# The connection requires a password and is root, so it is unsafe for other users, so set.

# develop a good habit of setting up and viewing.

[Email protected] ~]# Ll/etc/rsync.password

-rw-r--r--1 root root 5 19:46/etc/rsync.password

[Email protected] ~]# chmod 600/etc/rsync.password

[Email protected] ~]# Ll/etc/rsync.password

-RW-------1 root root 5 19:46/etc/rsync.password

[Email protected] run]# vim/etc/rc.local

Touch/var/lock/subsys/local

>/etc/udev/rules.d/70-persistent-net.rules

rsync –daemon

Iv. Client Settings

[email protected] ~]# mkdir -p/backup

[Email protected] ~]# echo "Oldboy" >/etc/rsync.password

[Email protected] ~]# chmod 600/etc/rsync.password

[Email protected] ~]# Ll/etc/rsync.password

-RW-------1 root root 7 5? 20:45/etc/rsync.password

[Email protected] ~]# Cat/etc/rsync.password

Oldboy

V. Testing

# Push Test

#100 Client

[Email protected] ~]# ll-ltr/tmp/

Total 0

-RW-------1 root root 0 Mar 6 16:18 yum.log

-rw-r--r--1 root root 0 may 17:12 Stu9

[Email protected] ~]# Rsync-avz/tmp/[email protected]::backup--password-file=/etc/rsync.password

Sending incremental file list

./

Stu1

Stu10

Stu11

Stu12

Stu13

Sent 999 bytes received 414 bytes 2826.00bytes/sec

Total size was 0 Speedup is 0.00

[[email protected] ~]# echo $?

0

# Complete Step Execution echo$?, If the result is 0 , then the result is correct .

#41 Service Side

[Email protected] ~]# ll-ltr/backup/

Xüóá0

-RW-------1 rsync rsync 0 3 6 16:18 yum.log

-rw-r--r--1 rsync rsync 0 5 17:12 stu9

-rw-r--r--1 rsync rsync 0 5 17:12 stu8

。。。。。。。。。。。。。。。

# Pull Test

#100 Client Execution

[Email protected] ~]# rsync [email protected]::backup/tmp/--password-file=/etc/rsync.password

Receiving incremental file list

。。。。。。。。。。

Stu9

Yum.log

Sent 467 bytes received 1083 bytes 3100.00bytes/sec

Total size was 0 Speedup is 0.00

[[email protected] ~]# echo $?

0

# only the files that are pulled to the client are not present in the service-side directory .


This article is from the "You can choose Extraordinary" blog, please be sure to keep this source http://ylcodes01.blog.51cto.com/5607366/1787772

Data transfer in Rsync's daemon mode of operation

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.