Sshd + rsync for Data Synchronization

Source: Internet
Author: User
Tags rsync

How sshd + rsync achieves data synchronization is simple

The client connects to the server through sshd, and the server synchronizes data to the client

First, check the kernel information of the server.

Server

[Root @ server ~] # Uname-
Linux server.test.com 2.6.18-194. el5 #1 SMP Tue Mar 16 21:52:43 EDT 2010 i686 i686 i386 GNU/Linux

Client

[Root @ client ~] # Uname-
Linux client.test.com 2.6.18-194. el5 #1 SMP Tue Mar 16 21:52:43 EDT 2010 i686 i686 i386 GNU/Linux


First, the client and the server both need to configure the yum source. Here I use the local yum Source

Install rsync and xinetd services

[Root @ server ~] # Yum install rsync xinetd-y

[Root @ client ~] # Yum install rsync xinetd-y

Modify/etc/xinetd/

[Root @ server ~] # Vi/etc/xinetd. d/rsync


Change disable = yes to disable = no

Restart the xinetd service.

[Root @ server ~] #/Etc/init. d/xinetd restart
Stopping xinetd: [OK]
Starting xinetd: [OK]

The client server performs the same operation.

Both client and server ssh services are enabled.

[Root @ server ~] #/Etc/init. d/sshd restart
Stopping sshd: [OK]
Starting sshd: [OK]


On server

[Root @ server/] # mkdir/data
[Root @ server/] # cd/data
[Root @ server data] # mkdir server
[Root @ server data] # cd server/
[Root @ server] # pwd
/Data/server

[Root @ server] # du-sh test.rar
249 M test.rar

Upload a file test.rar to the server.

Create a new file

[Root @ server] # touch tt
[Root @ server] # ls
Test.rar tt


Next, create the corresponding folder on the client.

[Root @ client ~] # Mkdir/data
[Root @ client ~] # Mkdir/data/backup


Check the data synchronization status on the client

[Root @ client/] # cd/data/backup/
[Root @ client backup] # ls
Test.rar tt
[Root @ client backup] # ll
Total 254452
-Rw-r -- 1 root 260296040 Jan 25 2014 test.rar
-Rw-r -- 1 root 0 Jan 25 09: 46 tt


The server deletes data and the client deletes data synchronously.



[Root @ client server] # rsync-av -- delete 192.168.1.110:/data/server/data/backup/
Root@192.168.1.110's password:
Processing ing file list... done
Deleting server/test.rar
Deleting server/
Deleting tt
./


Sent 26 bytes converted ed 76 bytes 22.67 bytes/sec
Total size is 260296040 speedup is 2551921.96

Server ssh service replaces other ports for Data Synchronization

[Root @ server ~] # Vim/etc/ssh/sshd_config


[Root @ server ~] # Service sshd restart
Stopping sshd: [OK]
Starting sshd: [OK]



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.