rsync新增模組和推送

2021-09-02 09:21:22 字數 2359 閱讀 7499

rsync在linux中是用來傳輸檔案(遠端同步)的工具。

[b]rsync連線有兩種服務實現方式:[/b]

第一,基於遠端shell的程式,比如ssh 這也是很早的ssh傳輸記錄預設埠好像是22,好長時間不用了忘記了。

第二,其程式自身的「daemon」伺服器模式,這種方式在公司比較常用,安全。

1.使用基於openssh的服務方式是,遠端主機(伺服器端)不需要設定rsync,

只需要安裝openssh-server,啟動服務即可。特點:可以直接使用linux系統使用者進行驗證,很方便靈活。

2.基於rsync的daemon模式

使用rsync程式的伺服器模式時,要設定rsync程式配置檔案,rsyncd.conf。特點:可以使用匿名的方式或者是基本基於文字檔案的使用者資料庫進行驗證。

[b]*接下來說說推送[/b]

我使用的是daemon這種方式,新建立乙個模組。

在推送接收伺服器上建立,read only引數比較關鍵推送時設定為no。

[housenum]

uid = 使用者名稱

gid = 使用者組

path = /path

comment = 備註

ignore errors = yes

read only = no 本模組的目前是否為唯讀,直接影響是否能成功推送。

list = no

transfer logging = yes

[b]*啟動rsync服務。[/b]

指定配置模組檔案

/usr/bin/rsync --daemon --port=埠號 --config=/etc/rsyncd.conf

不指定配置模組檔案 預設為 /etc/rsyncd.conf

/usr/bin/rsync --port=埠號 --daemon

[b]*重啟rsync服務[/b]

一般伺服器都設定為開機自動載入rsync服務。

如果需重啟rsync服務,首先檢視一下本機是否正在執行rsyn服務,檢視命令

ps -u root | grep rsync (一般都是以root使用者啟動的)

如果有記錄pid 然後kill 掉就可以了,kill後再啟動rsync服務。

對了修改rsyncd.conf配置後不需要重新啟動rsync服務。

同步時客戶端連線出錯的問題處理:

解決rsync failed connection refused 111 iptables rsync linux

rsync同步時客戶端連線出錯的問題。rsync: failed to connect to ip: connection refused (111) 和 rsync error: error in socket io (code 10) at clientserver.c(124) [receiver=3.0.6]的問題。

在客戶端執行rsync時,出現以下問題:

/usr/bin/rsync -vzrtopg –progress –delete –password-file=/etc/password.rsync rsync: /var/html/lixiphp

rsync: failed to connect to 192.168.1.2: connection refused (111)

rsync error: error in socket io (code 10) at clientserver.c(124) [receiver=3.0.6]

出現這個錯誤的原因是因為服務端的服務沒開起來,或者埠的問題。

解決方法

如果伺服器端,沒有開啟rsync,當然客戶端連線時會出現連線錯誤,也就是connection refused (111) 錯誤。

在服務端執行:

# rsync –daemon –config=/etc/rsyncd.conf

failed to create pid file /var/run/rsyncd.pid: file exists

# rm -rf /var/run/rsyncd.pid

# rsync –daemon –config=/etc/rsyncd.conf

如果沒有出現建立pid錯誤,就不需要刪除pid檔案再啟動。

確認rsync是否啟動了?

# ps -ef | grep rsync

root 29768 1 0 15:19 ? 00:00:00 rsync –daemon –config=/etc/rsyncd.conf

root 29792 28996 0 15:21 pts/0 00:00:00 grep rsync

如果程序啟動了,如果客戶端仍然無法同步的話,那就是伺服器端的埠的問題。

排查埠問題:

檢視埠

netstat -ntpl

新增Linux模組

有了系統呼叫的經驗,新增模組還是很順利的。實驗環境 fedora,核心2.6.21.6 實驗步驟 1.cd root homework module 2.vi process.c 3.加入如下 4.vi makefile 5.加入如下 obj m process.o all make c lib m...

python 模組新增

python包含子目錄中的模組方法比較簡單,關鍵是能夠在sys.path裡面找到通向模組檔案的路徑。下面將具體介紹幾種常用情況 如下面程式結構 src mod1.py test1.py 若在程式test1.py中匯入模組mod1,則直接使用import mod1或from mod1 import 如...

nginx 新增 模組

title nginx 新增 模組 date 2019 10 31 11 21 46 categories tags config nginx 說明 已經安裝好的nginx,需要新增乙個未被編譯安裝的模組 以nginx rtmp module模組為例 則需要重新編譯nginx,而不是像apache一...