一直以爲rsync是個配置很簡單的服務軟件,今天須要搭建一個rsync服務出現了一些小問題,特地寫下接下來的內容
首先在服務器上搭建rsync
`#yum -y install rsync``
修改配置文件 /etc/rsyncd.conf 在尾部添加如下配置linux
[ftp] //這裏和大多數共享服務配置同樣須要定義一個用戶名,名字由本身取 path = /home/ftp //這裏是你須要共享出去的目錄 comment = ftp export area //這裏是共享描述 auth users = tom //這裏是你但願經過什麼用戶共享這個目錄和系統用戶無關 secrets file = /etc/rsyncd_users.db //這裏是指定共享的用戶名和密碼
重啓服務並設置開機啓動sql
#systemctl restart rsyncd #systemctl enable rsyncd
在客戶端訪問rsync共享發現 服務器
#rsync 192.168.2.100:: //這裏的ip是我共享服務器的ip ftp ftp export area
能夠看到個人共享了可是當我去訪問共享目錄的時候須要驗證我輸入密碼發現報錯誤ide
#rsync susers@192.168.2.100::ftp @ERROR: auth failed on module ftp rsync error: error starting client-server protocol (code 5) at main.c(1516) [Receiver=3.0.9]
大概意思是認證失敗在ftp這個模塊上這個錯誤主要緣由是沒有讀到用戶名密碼文件或者權限不足密碼文件須要的權限設爲600就行,我在這裏是文件名寫錯了改好後繼續訪問post
#rsync susers@192.168.2.100::ftp @ERROR: chroot failed rsync error: error starting client-server protocol (code 5) at main.c(1516) [Receiver=3.0.9]
這個錯誤主要是訪問不到共享的文件夾,有多是服務器文件夾不存在或者權限不夠,我在這裏是沒有建立文件夾
建立好文件夾再訪問rest
#rsync susers@192.168.2.100::ftp rsync: opendir "/." (in ftp) failed: Permission denied (13) drwxr-xr-x 14 2018/02/04 01:39:47 . rsync error: some files/attrs were not transferred (see previous errors) (code 23) at main.c(1518) [generator=3.0.9]
又報錯了個人心有點碎了訪問被拒絕,密碼也對了,權限也夠了問題出在哪裏,selinux問題想了半天才想到
查看如下selinux的bool值postgresql
#getsebool -a | grep rsync postgresql_can_rsync --> off rsync_anon_write --> off rsync_client --> off rsync_export_all_ro --> off rsync_full_access --> off 把 rsync_export_all_ro 只讀設置爲on 終於大功告成 rsync tom@192.168.2.100::ftp/ Password: drwx-wx--x 14 2018/02/04 01:39:47 . -rw-r--r-- 0 2018/02/04 01:39:47 a