Ceph 檔案儲存
阿新 • • 發佈:2021-07-07
# 要執行檔案系統必須建立至少帶一個mds的Ceph儲存叢集 # 部署元資料伺服器 ceph-deploy mds create node01 node02 node03 # 檢視元資料伺服器狀態 ceph mds stat # 建立兩個儲存池,一個用於存放元資料,一個用於存放資料 # ceph osd pool create cephfs_data <pg_num> # ceph osd pool create cephfs_metadata <pg_num> ceph osd pool create cephfs_pool 128 ceph osd pool create cephfs_metadata 64 # 檢視儲存池 ceph osd pool ls # 檢視Ceph磁碟容量資訊 ceph df ceph -s # 建立CephFS檔案系統 # ceph fs new <fs_name> <metadata> <data> {--force} ceph fs new cephfs cephfs_metadata cephfs_pool # 檢視CephFS檔案系統 ceph fs ls # 使用ceph-authtool驗證工具生成密碼key檔案,複製key和keyring到客戶端 ceph-authtool -p /etc/ceph/ceph.client.admin.keyring > admin.key scp ./admin.key client:/root/ scp /etc/ceph/ceph.client.admin.keyring client:/root/ # 客戶端部署Ceph及其相關工具 yum install ceph-common -y yum install ceph ceph-radosgw -y yum install ceph-fuse # 把CephFS掛載為核心驅動 # 客戶端使用密碼key檔案掛載ceph檔案系統,掛載叢集任一節點均可 # mount -t ceph {ip-address-of-monitor}:6789:/ /mnt/ mount -t ceph node01:6789:/ /mnt -o name=admin,secretfile=/root/admin.key # 把CephFS掛載為使用者空間檔案系統(FUSE) # Ceph儲存叢集預設要求認證,需指定相應的金鑰環檔案,除非它在預設位置(即/etc/ceph) # ceph-fuse -m {ip-address-of-monitor}:6789 /mnt/ ceph-fuse -k /root/ceph.client.admin.keyring -m node01:6789 /mnt/ # admin使用者掛載(存在/etc/ceph/ceph.client.admin.keyring) ceph-fuse -n client.admin /mnt/ # 自定義使用者掛載 ceph fs authorize cephfs client.foo / rw | tee /etc/ceph/ceph.client.foo.keyring ceph-fuse -n client.foo /mnt/ # 開機自動掛載 cat /etc/fstab id=admin /mnt/ fuse.ceph defaults 0 0 mount -a # 檢視掛載狀態 df -h # 檢視儲存池使用統計資訊 rados df # 刪除檔案系統,需解除安裝並停止所有節點mds程序 umount /mnt/ systemctl stop ceph-mds.target # node01 systemctl stop ceph-mds.target # node02 systemctl stop ceph-mds.target # node03 ceph fs rm cephfs --yes-i-really-mean-it ceph fs ls # 刪除儲存池 # ceph osd pool delete {pool-name} [{pool-name} --yes-i-really-really-mean-it] ceph osd pool delete cephfs_metadata cephfs_metadata --yes-i-really-really-mean-it ceph osd pool delete cephfs_pool cephfs_pool --yes-i-really-really-mean-it # 重新啟動所有節點mds程序 systemctl start ceph-mds.target # node01 systemctl start ceph-mds.target # node02 systemctl start ceph-mds.target # node03