問題描述
rsync服務端配置文件修改完成后。啟動服務返回報錯如下
[root@localhost init.d]# /usr/bin/rsync –daemon rsync: link_stat "/etc/rc.d/init.d/–daemon" failed: No such file or directory (2) rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2]
解決方案
先拋出解決方案,只要把命令中daemon前面的“-”換成“--”,啟動成功了。((┬_┬),加班加點排查了4個小時才解決)
[root@localhost etc]# /usr/bin/rsync --daemon [root@localhost etc]# ps -ef|grep rsync root 13470 1 0 10:51 ? 00:00:00 /usr/bin/rsync --daemon root 13545 7777 0 10:51 pts/0 00:00:00 grep --color=auto rsync
注意:如果手動輸入“--”不生效,可考慮 執行命令 /usr/bin/rsync ,從返回的幫助信息中copy一個“--”出來用,就成功了。至於為什么暫時不知道原因,歡迎找到原因的朋友留言。(明明一樣的嘛,太任性了)
[root@localhost etc]# /usr/bin/rsync –-daemon rsync: link_stat "/etc/–-daemon" failed: No such file or directory (2) rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1178) [sender=3.1.2] [root@localhost etc]# /usr/bin/rsync --daemon [root@localhost etc]# ps -ef|grep rsync root 13470 1 0 10:51 ? 00:00:00 /usr/bin/rsync --daemon root 13545 7777 0 10:51 pts/0 00:00:00 grep --color=auto rsync
排查思路
1.首先,各種網搜,搜索關鍵詞:rsync: link_stat "/etc/rc.d/init.d/–daemon" failed: No such file or directory (2)
但網上的資料各種互相copy,且都是針對同步過程出的錯。不符合當前情況。不得已自己根據報錯信息一步步排查。
2.自己分析報錯日志,提示很明確:/etc/rc.d/init.d/–daemon 文件或者目錄不存在。
1)ll查看 /etc/rc.d/init.d/–daemon,此文件確實不存在。(還專門去研究了下/etc/rc.d/init.d/目錄是干嘛的,貌似沒啥關系)
2)那為什么要執行這個文件吶,難道是rsync 命令調用執行的?但是rsync是無法打開查看內部執行邏輯的,網上搜無解。
3)最后求助同事,同事解釋說可能是系統不認識“/usr/bin/rsync –daemon”。誤解是一個文件“/etc/rc.d/init.d/–daemon”。(系統為啥這樣處理太深入了暫不研究)
4)到此,基本定位到是我輸入的命令錯誤,/usr/bin/rsync 這是rsync的執行命令,確保是沒問題的。那問題就出在參入部分“ –daemon”
5)參數問題可求助命令自身幫助。執行 /usr/bin/rsync 直接返回相關說明信息。說明信息的最后,明確提示daemon的使用格式是“ -- ”
Use "rsync --daemon --help" to see the daemon-mode command-line options.
6)重新輸入執行命令 ,daemon前輸入兩個中划線,還是報錯 。😭
/usr/bin/rsync –-daemon #手動輸入的
7)為避免輸入問題,從說明信息中直接復制粘貼“--daemon”,執行成功了。原因未知。。。。。。等我發現了再補充上
