Linux下rsync遠(yuǎn)程數(shù)據(jù)同步命令的詳細(xì)介紹
介紹
rsync命令是一個(gè)遠(yuǎn)程數(shù)據(jù)同步工具,可通過LAN/WAN快速同步多臺(tái)主機(jī)間的文件。rsync使用所謂的“rsync算法”來(lái)使本地和遠(yuǎn)程兩個(gè)主機(jī)之間的文件達(dá)到同步,這個(gè)算法只傳送兩個(gè)文件的不同部分,而不是每次都整份傳送,因此速度相當(dāng)快。 rsync是一個(gè)功能非常強(qiáng)大的工具,其命令也有很多功能特色選項(xiàng),我們下面就對(duì)它的選項(xiàng)一一進(jìn)行分析說(shuō)明。
常用場(chǎng)景
無(wú)密碼同步
服務(wù)端: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
客戶端
rsync -avz --progress root@192.168.1.98::share_data /home/hadoop/share_data
限制流量同步
rsync -avz --bwlimit=50 --progress root@192.168.1.98::share_data /home/hadoop/share_data
有密碼同步
服務(wù)端
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
客戶端
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
或者是
export RSYNC_PASSWORD="password123" rsync -avz --progress hadoop@192.168.1.98::auth_data /home/hadoop/auth_data
寫入同步
服務(wù)端
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
客戶端
echo "123" > /home/hadoop/write_file export RSYNC_PASSWORD="password123" rsync -avz --progress --delete /home/hadoop/write_file hadoop@192.168.1.98::write_data
限定IP或者網(wǎng)段
#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 hosts allow = 192.168.2.32 192.168.1.0/24
客戶端 https://download.samba.org/pub/rsync/rsync.html
服務(wù)端 https://download.samba.org/pub/rsync/rsyncd.conf.html
總結(jié)
以上就是這篇文章的全部?jī)?nèi)容了,希望本文的內(nèi)容對(duì)大家的學(xué)習(xí)或者工作能帶來(lái)一定的幫助,如果有疑問大家可以留言交流。謝謝大家對(duì)腳本之家的支持。
相關(guān)文章
linux下用time(NULL)函數(shù)和localtime()獲取當(dāng)前時(shí)間的方法
這篇文章主要介紹了linux下用time(NULL)函數(shù)和localtime()獲取當(dāng)前時(shí)間的方法,文中通過示例代碼介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價(jià)值,需要的朋友們下面隨著小編來(lái)一起學(xué)習(xí)學(xué)習(xí)吧2020-02-02Apache Shiro 使用手冊(cè)(五) Shiro 配置說(shuō)明
這篇文章主要為大家分享了Apache Shiro 配置說(shuō)明,需要的朋友可以參考下2014-06-06Linux系統(tǒng)中安裝gcc和kernel-devel的方法
下面小編就為大家?guī)?lái)一篇Linux系統(tǒng)中安裝gcc和kernel-devel的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來(lái)看看吧2016-12-12Linux信號(hào)機(jī)制之信號(hào)的保存與處理技巧分享
本文旨在為廣大Linux學(xué)習(xí)者提供一份詳盡而實(shí)用的指南,幫助他們深入理解Linux中的信號(hào)機(jī)制,掌握信號(hào)的保存與處理技巧,我們將從信號(hào)的基本概念出發(fā),逐步深入到信號(hào)的捕獲、保存、處理以及恢復(fù)等各個(gè)環(huán)節(jié),通過生動(dòng)的實(shí)例和詳細(xì)的解釋,讓讀者能夠輕松掌握2024-10-10