源碼編譯安裝 ganesha
簡介
- 系統環境:CentOS 7.5
- ceph:luminous
- nfs-ganesha:v2.6 stable
安裝步驟
安裝依賴
1 |
yum install gcc git cmake autoconf libtool bison flex doxygen openssl-devel gcc-c++ krb5-libs krb5-devel libuuid-devel nfs-utils -y |
如果是使用 Ubuntu 系統,主要有以下幾個包不同
gcc-c++
-> g++
libuuid-devel
-> uuid-dev
nfs-utils
-> nfs-kernel-server
- 如果要生成
FSAL_RGW
模塊,需要安裝 librgw2-devel
1 |
yum install librgw2-devel -y |
- 如果要生成
FSAL_CEPH
模塊,需要安裝 libcephfs1-devel
1 |
yum install libcephfs-devel -y |
源碼下載
克隆源碼到本地
1 |
git clone -b V2.6-stable https://github.com/nfs-ganesha/nfs-ganesha.git --recursive |
編譯
-
cmake
nfs-ganesha
源碼
- 如果需要生成
FSAL_RGW
模塊,則在編譯選項中添加: -DUSE_FSAL_RGW=ON
- 如果需要生成
FSAL_CEPH
模塊,則在編譯選項中添加: -DUSE_FSAL_CEPH=ON
1 2 3 4 5 |
cd nfs-ganesha cd src/ mkdir build cd build/ cmake -DUSE_FSAL_RGW=ON -DUSE_FSAL_CEPH=ON ../ |
1 2 3 4 5 6 7 8 9 10 11 12 13 |
-- Looking for ceph_ll_lookup_root in cephfs - found -- Found cephfs libraries: /usr/lib64/libcephfs.so -- Found CEPHFS: /usr/include -- Looking for rgw_mount in rgw -- Looking for rgw_mount in rgw - found -- Found rgw libraries: /usr/lib64/librgw.so -- Found RGW: /usr (found suitable version "1.1", minimum required is "1.1") ... -- USE_FSAL_CEPH = ON -- USE_FSAL_CEPH_MKNOD = OFF -- USE_FSAL_CEPH_SETLK = OFF -- USE_FSAL_CEPH_LL_LOOKUP_ROOT = ON -- USE_FSAL_RGW = ON |
請確保 -- USE_FSAL_CEPH
為 ON
,以及 -- USE_FSAL_RGW
為 ON
PS: 在 make install
生成的輸出中,可以看到:
– Up-to-date: /usr/share/doc/ganesha/config_samples/rgw.conf … – Up-to-date: /usr/share/doc/ganesha/config_samples/ceph.conf
這兩個文件就是配置將RGW
和CephFS
配置為ganesha-nfs
的配置模板
配置 service
將 nfs-ganesha
源碼目錄下的 nfs-ganesha/src/scripts/systemd
目錄下的 service
文件復制到系統 /usr/lib/systemd/system/
目錄下,將 nfs-ganesha
配置為系統服務讓 systemd
接管,然后設置開機自啟
1 2 3 4 5 |
cd nfs-ganesha/src/scripts/systemd cp nfs-ganesha-config.service /usr/lib/systemd/system/nfs-ganesha-config.service cp nfs-ganesha.service.el7 /usr/lib/systemd/system/nfs-ganesha.service cp nfs-ganesha-lock.service.el7 /usr/lib/systemd/system/nfs-ganesha-lock.service systemctl enable nfs-ganesha |
The DBUS Interface
配置系統 DBUS 服務(編譯安裝需要手動執行這個過程)
- 將文件
src/scripts/ganeshactl/org.ganesha.nfsd.conf
復制到該目錄 /etc/dbus-1/system.d/
。需要重新啟動 DBus 服務(messagebus)才能加載此文件
1 2 |
cp src/scripts/ganeshactl/org.ganesha.nfsd.conf /etc/dbus-1/system.d/
systemctl restart messagebus |
- 重啟
nfs-ganesha
服務,因為與 DBus 服務器的連接只在服務初始化時執行,所以如果之前忘了復制 org.ganesha.nfsd.conf
文件就需要重啟 nfs-ganesha
服務
1 |
systemctl restart nfs-ganesha |
- 可查看
nfs-ganesha
日志觀察服務是否正常啟動運行,通常是/var/log/ganesha/ganesha.log
1 |
tail -f /var/log/ganesha/ganesha.log |
編輯配置文件
其實這一步可以略過的,只是為了后面 Check Export 能檢測到一個掛載點而已,如果這一步不配置,manila
也會通過 SSH 連接到主機對每個 share 進行單獨的配置文件的添加
編輯 /etc/ganesha/ganesha.conf
文件,寫入以下內容
1 2 3 4 5 6 7 8 9 10 11 12 |
EXPORT { Export_ID=1; Path = "/"; Pseudo = /; Access_Type = RW; NFS_Protocols = 4; Transport_Protocols = TCP; FSAL { Name = CEPH; } } |
啟動 nfs-ganesha
服務
- 編譯安裝有個坑,就是少了個
nfs-ganesha-ceph
包,導致 manila
傳遞過來的命令無法正常執行,需要單獨使用 yum
命令進行安裝(因為我沒找到源碼地址,也沒法自己編譯安裝了,所以編譯安裝 nfs-ganesha
還不如直接用添加源的方式進行安裝···)
經測試這步可以省略:
1 |
yum install nfs-ganesha-ceph |
1 |
systemctl restart nfs-ganesha |
- 使用以下命令查看
nfs-ganesha
服務是否正常運行
1 |
systemctl status nfs-ganesha |
Check Export
使用以下命令檢測掛載點
1 2 3 4 |
[root@c1 ~]# showmount -e Export list for c1: / (everyone) [root@c1 ~]# |
參考鏈接