Details of the Linux remote data synchronization command under Linux
- 2020-05-24 06:39:53
- OfStack
introduce
The rsync command is a remote data synchronization tool that can quickly synchronize files between multiple hosts via LAN/WAN. rsync USES the so-called "rsync algorithm" to synchronize files between local and remote hosts, which is quite fast because it only transmits different parts of two files, rather than the whole at a time. rsync is a very powerful tool, and its commands also have a lot of feature options. Let's analyze the options 11 below.
Common scenario
Password-less synchronization
Server: vim /etc/ rsyncd. conf
#This is the rsync daemon configuration
#global settings
pid file = /var/run/rsyncd.pid
port = 873
lock file = /var/run/rsyncd.lock
log file = /var/log/rsync.log
gid = root
uid = root
#module settings
[share_data]
path = /web/rsync/share_data
use chroot = no
max connections = 15
read only = yes
write only = no
list = no
ignore errors = yes
timeout = 120
/usr/bin/rsync --daemon
mkdir -p /web/rsync/share_data
The client
rsync -avz --progress root@192.168.1.98::share_data /home/hadoop/share_data
Restricted flow synchronization
rsync -avz --bwlimit=50 --progress root@192.168.1.98::share_data /home/hadoop/share_data
Password sync
The service side
vim /etc/rsyncd.conf
#This is the rsync daemon configuration
#global settings
pid file = /var/run/rsyncd.pid
port = 873
lock file = /var/run/rsyncd.lock
log file = /var/log/rsync.log
gid = root
uid = root
#module settings
[auth_data]
path = /web/rsync/auth_data
use chroot = no
max connections = 15
read only = yes
write only = no
list = no
ignore errors = yes
timeout = 120
auth users = hadoop
secrets file = /etc/rsyncd.passwd
echo "hadoop:password123" > /etc/rsyncd.passwd
chmod 600 /etc/rsyncd.passwd
mkdir -p /web/rsync/auth_data
The client
echo "password123" > /home/hadoop/rsyncd.passwd
chmod 600 /home/hadoop/rsyncd.passwd
rsync -avz --progress --password-file=/home/hadoop/rsyncd.passwd hadoop@192.168.1.98::auth_data /home/hadoop/auth_data
Or is it
export RSYNC_PASSWORD="password123"
rsync -avz --progress hadoop@192.168.1.98::auth_data /home/hadoop/auth_data
Write synchronization
The service side
vim /etc/rsyncd.conf
#global settings
pid file = /var/run/rsyncd.pid
port = 873
lock file = /var/run/rsyncd.lock
log file = /var/log/rsync.log
gid = root
uid = root
#module settings
[write_data]
path = /web/rsync/write_data
use chroot = no
max connections = 15
read only = no
list = no
ignore errors = yes
timeout = 120
auth users = hadoop
secrets file = /etc/rsyncd.passwd
mkdir -p /web/rsync/write_data
The client
/usr/bin/rsync --daemon
mkdir -p /web/rsync/share_data
0
Define IP or segment
/usr/bin/rsync --daemon
mkdir -p /web/rsync/share_data
1
More command references
Client https: / / download. samba. org pub/rsync/rsync html
Server-side https: / / download. samba. org pub/rsync/rsyncd conf. html
conclusion