cephFS客户端使用指南

简介: 关于如何手动和自动挂载cephFS客户端的详细指南,包括移除认证文件、创建用户、导出钥匙环和key文件、挂载cephFS、验证用户权限以及设置开机自动挂载的三种方法。

一.cephFS客户端手动挂载实战案例

1.客户端移除认证文件

[root@ceph144 ~]# rm -f  /etc/ceph/ceph.client.admin.keyring 
[root@ceph144 ~]# 
[root@ceph144 ~]# ll /etc/ceph/
total 8
-rw-r--r-- 1 root root 353 Feb  2 11:13 ceph.conf
-rw-r--r-- 1 root root  92 Jun 30  2021 rbdmap
-rw------- 1 root root   0 Feb  1 16:50 tmpEYwKWU
[root@ceph144 ~]# 
[root@ceph144 ~]# ceph -s
2024-02-02 15:01:34.969 7fd3b4f99700 -1 auth: unable to find a keyring on /etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin,: (2) No such file or directory
2024-02-02 15:01:34.969 7fd3b4f99700 -1 AuthRegistry(0x7fd3b00662b8) no keyring found at /etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin,, disabling cephx
2024-02-02 15:01:34.993 7fd3b4f99700 -1 auth: unable to find a keyring on /etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin,: (2) No such file or directory
2024-02-02 15:01:34.993 7fd3b4f99700 -1 AuthRegistry(0x7fd3b00c7e18) no keyring found at /etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin,, disabling cephx
2024-02-02 15:01:34.994 7fd3b4f99700 -1 auth: unable to find a keyring on /etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin,: (2) No such file or directory
2024-02-02 15:01:34.994 7fd3b4f99700 -1 AuthRegistry(0x7fd3b4f97e78) no keyring found at /etc/ceph/ceph.client.admin.keyring,/etc/ceph/ceph.keyring,/etc/ceph/keyring,/etc/ceph/keyring.bin,, disabling cephx
[errno 2] error connecting to the cluster
[root@ceph144 ~]#

2.管理节点创建用户并导出钥匙环和key文件

[root@ceph141 ~]# ceph auth add  client.yinzhengjiefs mon 'allow r' mds 'allow rw' osd 'allow rwx'
added key for client.yinzhengjiefs
[root@ceph141 ~]# 
[root@ceph141 ~]# ceph auth get client.yinzhengjiefs
[client.yinzhengjiefs]
    key = AQCqk7xl25FuIBAAgjIW2EGodfyFRLuifNoYSA==
    caps mds = "allow rw"
    caps mon = "allow r"
    caps osd = "allow rwx"
exported keyring for client.yinzhengjiefs
[root@ceph141 ~]# 
[root@ceph141 ~]# ceph auth get client.yinzhengjiefs > ceph.client.yinzhengjiefs.keyring 
exported keyring for client.yinzhengjiefs
[root@ceph141 ~]# 
[root@ceph141 ~]# cat ceph.client.yinzhengjiefs.keyring
[client.yinzhengjiefs]
    key = AQCqk7xl25FuIBAAgjIW2EGodfyFRLuifNoYSA==
    caps mds = "allow rw"
    caps mon = "allow r"
    caps osd = "allow rwx"
[root@ceph141 ~]# 
[root@ceph141 ~]# ceph auth  print-key client.yinzhengjiefs > yinzhengjiefs.key
[root@ceph141 ~]# 
[root@ceph141 ~]# more yinzhengjiefs.key 
AQCqk7xl25FuIBAAgjIW2EGodfyFRLuifNoYSA==
[root@ceph141 ~]#

3.将钥匙环和秘钥key拷贝到客户端指定目录

[root@ceph141 ~]# scp ceph.client.yinzhengjiefs.keyring yinzhengjiefs.key ceph144:/etc/ceph/
root@ceph144's password: 
ceph.client.yinzhengjiefs.keyring                                                                      100%  138   133.4KB/s   00:00    
yinzhengjiefs.key                                                                                      100%   40     3.6KB/s   00:00    
[root@ceph141 ~]#

4.客户端两种挂载cephFS

    1 配置ceph集群主机解析 
[root@ceph144 ~]# cat >> /etc/hosts <<EOF
10.0.0.141 ceph141
10.0.0.142 ceph142
10.0.0.143 ceph143
10.0.0.144 ceph144
EOF


    2 方式一: 基于key文件进行挂载
[root@ceph144 ~]# df -h | grep mnt
[root@ceph144 ~]# 
[root@ceph144 ~]# mount -t ceph ceph141:6789,ceph142:6789,ceph143:6789:/ /mnt -o name=yinzhengjiefs,secretfile=/etc/ceph/yinzhengjiefs.key
[root@ceph144 ~]# 
[root@ceph144 ~]# df -h | grep mnt
10.0.0.141:6789,10.0.0.142:6789,10.0.0.143:6789:/  630G     0  630G   0% /mnt
[root@ceph144 ~]# 
[root@ceph144 ~]# ll /mnt/
total 0
[root@ceph144 ~]# 
[root@ceph144 ~]# cp /etc/os-release /mnt/
[root@ceph144 ~]# 
[root@ceph144 ~]# ll /mnt/
total 1
-rw-r--r-- 1 root root 393 Feb  2 15:10 os-release
[root@ceph144 ~]# 
[root@ceph144 ~]# umount /mnt/
[root@ceph144 ~]# 
[root@ceph144 ~]# df -h | grep mnt
[root@ceph144 ~]# 


    3 方式二: 基于KEY进行挂载,无需拷贝秘钥文件!
[root@ceph144 ~]# more /etc/ceph/yinzhengjiefs.key
AQCqk7xl25FuIBAAgjIW2EGodfyFRLuifNoYSA==
[root@ceph144 ~]# 
[root@ceph144 ~]# mount -t ceph ceph141:6789,ceph142:6789,ceph143:6789:/ /mnt -o name=yinzhengjiefs,secret=AQCqk7xl25FuIBAAgjIW2EGodfyFRLuifNoYSA==
[root@ceph144 ~]# 
[root@ceph144 ~]# df -h | grep mnt
10.0.0.141:6789,10.0.0.142:6789,10.0.0.143:6789:/  630G     0  630G   0% /mnt
[root@ceph144 ~]# 
[root@ceph144 ~]# ll /mnt/
total 1
-rw-r--r-- 1 root root 393 Feb  2 15:10 os-release
[root@ceph144 ~]#  
[root@ceph144 ~]# umount /mnt
[root@ceph144 ~]# 
[root@ceph144 ~]# df -h | grep mnt
[root@ceph144 ~]#

5.验证yinzhengjiefs普通用户

[root@ceph144 ~]# ll /etc/ceph/ceph.client.yinzhengjiefs.keyring 
-rw-r--r-- 1 root root 138 Feb  2 15:07 /etc/ceph/ceph.client.yinzhengjiefs.keyring
[root@ceph144 ~]# 
[root@ceph144 ~]# cat /etc/ceph/ceph.client.yinzhengjiefs.keyring 
[client.yinzhengjiefs]
    key = AQCqk7xl25FuIBAAgjIW2EGodfyFRLuifNoYSA==
    caps mds = "allow rw"
    caps mon = "allow r"
    caps osd = "allow rwx"
[root@ceph144 ~]# 
[root@ceph144 ~]# ceph -s --user yinzhengjiefs 
  cluster:
    id:     5821e29c-326d-434d-a5b6-c492527eeaad
    health: HEALTH_OK

  services:
    mon: 3 daemons, quorum ceph141,ceph142,ceph143 (age 4h)
    mgr: ceph142(active, since 4h), standbys: ceph141, ceph143
    mds: yinzhengjie-linux-cephfs:2 {0=ceph143=up:active,1=ceph141=up:active} 1 up:standby
    osd: 7 osds: 7 up (since 4h), 7 in (since 22h)

  data:
    pools:   5 pools, 256 pgs
    objects: 102 objects, 100 MiB
    usage:   7.8 GiB used, 1.9 TiB / 2.0 TiB avail
    pgs:     256 active+clean

[root@ceph144 ~]#

6.后续使用直接用就可以了,和nfs几乎一样,只不过是高可用的NFS

[root@ceph143 ~]# df -h | grep mnt
[root@ceph143 ~]# 
[root@ceph143 ~]# mount -t ceph ceph141:6789,ceph142:6789,ceph143:6789:/ /mnt -o name=yinzhengjiefs,secret=AQCqk7xl25FuIBAAgjIW2EGodfyFRLuifNoYSA==
[root@ceph143 ~]# 
[root@ceph143 ~]# df -h | grep mnt
10.0.0.141:6789,10.0.0.142:6789,10.0.0.143:6789:/  630G     0  630G   0% /mnt
[root@ceph143 ~]# 
[root@ceph143 ~]# ll /mnt/
total 1
-rw-r--r-- 1 root root 393 Feb  2 15:10 os-release
[root@ceph143 ~]# 
[root@ceph143 ~]# cp /etc/sysconfig/network-scripts/ifcfg-ens33 /mnt/
[root@ceph143 ~]# 
[root@ceph143 ~]# ll /mnt/
total 1
-rw-r--r-- 1 root root 147 Feb  2 15:17 ifcfg-ens33
-rw-r--r-- 1 root root 393 Feb  2 15:10 os-release
[root@ceph143 ~]#

7.在另一个客户端挂载测试,值得注意是,基于key进行挂载,是不需要拷贝秘钥文件的

[root@ceph142 ~]# df -h | grep mnt
[root@ceph142 ~]# 
[root@ceph142 ~]# mount -t ceph ceph141:6789,ceph142:6789,ceph143:6789:/ /mnt -o name=yinzhengjiefs,secret=AQCqk7xl25FuIBAAgjIW2EGodfyFRLuifNoYSA==
[root@ceph142 ~]# 
[root@ceph142 ~]# df -h | grep mnt
10.0.0.141:6789,10.0.0.142:6789,10.0.0.143:6789:/  630G     0  630G   0% /mnt
[root@ceph142 ~]# 
[root@ceph142 ~]# ll /mnt/
total 1
-rw-r--r-- 1 root root 147 Feb  2 15:17 ifcfg-ens33
-rw-r--r-- 1 root root 393 Feb  2 15:10 os-release
[root@ceph142 ~]#

二.cephFS开机自动挂载的三种方式

1.方式一: 通过"/etc/rc.d/rc.local "文件实现开机自动挂载,(推荐: 就算执行失败,不影响开机)

[root@ceph144 ~]# vim /etc/rc.d/rc.local 
...

mount -t ceph ceph141:6789,ceph142:6789,ceph143:6789:/ /mnt -o name=yinzhengjiefs,secret=AQCqk7xl25FuIBAAgjIW2EGodfyFRLuifNoYSA==
[root@ceph144 ~]#
[root@ceph144 ~]# ll /etc/rc.d/rc.local
-rw-r--r-- 1 root root 602 Feb  2 15:19 /etc/rc.d/rc.local
[root@ceph144 ~]# 
[root@ceph144 ~]# chmod +x /etc/rc.d/rc.local
[root@ceph144 ~]# 
[root@ceph144 ~]# ll /etc/rc.d/rc.local
-rwxr-xr-x 1 root root 602 Feb  2 15:19 /etc/rc.d/rc.local
[root@ceph144 ~]# 
[root@ceph144 ~]# df -h | grep mnt
[root@ceph144 ~]# 
[root@ceph144 ~]# reboot
[root@ceph144 ~]# 
[root@ceph144 ~]# df -h | grep mnt
10.0.0.141:6789,10.0.0.142:6789,10.0.0.143:6789:/  630G     0  630G   0% /mnt
[root@ceph144 ~]#

2.方式二: 使用"/etc/fstab"进行开机挂载

[root@ceph144 ~]# grep yinzhengjie /etc/rc.d/rc.local 
mount -t ceph ceph141:6789,ceph142:6789,ceph143:6789:/ /mnt -o name=yinzhengjiefs,secret=AQCqk7xl25FuIBAAgjIW2EGodfyFRLuifNoYSA==
[root@ceph144 ~]# 
[root@ceph144 ~]# sed -i '/mount/s@^@#@' /etc/rc.d/rc.local 
[root@ceph144 ~]# 
[root@ceph144 ~]# grep yinzhengjie /etc/rc.d/rc.local 
#mount -t ceph ceph141:6789,ceph142:6789,ceph143:6789:/ /mnt -o name=yinzhengjiefs,secret=AQCqk7xl25FuIBAAgjIW2EGodfyFRLuifNoYSA==
[root@ceph144 ~]# 
[root@ceph144 ~]# reboot
[root@ceph144 ~]# 
[root@ceph144 ~]# df -h | grep mnt  # 发现并不会开机自动挂载,说明上面的配置生效了。
[root@ceph144 ~]# 
[root@ceph144 ~]# vim /etc/fstab 
[root@ceph144 ~]# 
[root@ceph144 ~]# grep yinzhengjie /etc/fstab 
ceph141:6789,ceph142:6789,ceph143:6789:/     /mnt/    ceph name=yinzhengjiefs,secretfile=/etc/ceph/yinzhengjiefs.key,noatime,_netdev    0       2
[root@ceph144 ~]# 
[root@ceph144 ~]# reboot 
[root@ceph144 ~]# 
[root@ceph144 ~]# df -h | grep mnt
10.0.0.141:6789,10.0.0.142:6789,10.0.0.143:6789:/  630G     0  630G   0% /mnt
[root@ceph144 ~]# 


温馨提示:
    不推荐使用,一定要谨慎修改,因为一旦修改失败,会导致服务器启动失败,在开机挂载时阻塞住,需要进单用户模式救援。

3.方式三: 使用"/etc/fstab"进行开机挂载

[root@ceph144 ~]# grep yinzhengjie /etc/fstab 
ceph141:6789,ceph142:6789,ceph143:6789:/     /mnt/    ceph name=yinzhengjiefs,secretfile=/etc/ceph/yinzhengjiefs.key,noatime,_netdev    0       2
[root@ceph144 ~]# 
[root@ceph144 ~]# sed -i '/ceph/s@^@#@' /etc/fstab 
[root@ceph144 ~]# 
[root@ceph144 ~]# grep yinzhengjie /etc/fstab 
#ceph141:6789,ceph142:6789,ceph143:6789:/     /mnt/    ceph name=yinzhengjiefs,secretfile=/etc/ceph/yinzhengjiefs.key,noatime,_netdev    0       2
[root@ceph144 ~]# 
[root@ceph144 ~]# vim /etc/fstab 
[root@ceph144 ~]# 
[root@ceph144 ~]# more /etc/ceph/yinzhengjiefs.key 
AQCqk7xl25FuIBAAgjIW2EGodfyFRLuifNoYSA==
[root@ceph144 ~]# 
[root@ceph144 ~]# 
[root@ceph144 ~]# grep yinzhengjie /etc/fstab 
#ceph141:6789,ceph142:6789,ceph143:6789:/     /mnt/    ceph name=yinzhengjiefs,secretfile=/etc/ceph/yinzhengjiefs.key,noatime,_netdev    0       2
ceph141:6789,ceph142:6789,ceph143:6789:/     /mnt/    ceph name=yinzhengjiefs,secret=AQCqk7xl25FuIBAAgjIW2EGodfyFRLuifNoYSA==,noatime,_netdev    0       2
[root@ceph144 ~]# 
[root@ceph144 ~]# reboot 
[root@ceph144 ~]# 
[root@ceph144 ~]# df -h | grep mnt
10.0.0.141:6789,10.0.0.142:6789,10.0.0.143:6789:/  630G     0  630G   0% /mnt
[root@ceph144 ~]# 
[root@ceph144 ~]# ll /mnt/
total 1
-rw-r--r-- 1 root root 147 Feb  2 15:17 ifcfg-ens33
-rw-r--r-- 1 root root 393 Feb  2 15:10 os-release
[root@ceph144 ~]#
目录
相关文章
|
存储 算法 关系型数据库
Ceph介绍及原理架构分享
Ceph介绍及原理架构分享
747 0
|
存储
Ceph Reef(18.2.X)的CephFS高可用集群实战案例
这篇文章是关于Ceph Reef(18.2.X)版本中CephFS高可用集群的实战案例,涵盖了CephFS的基础知识、一主一从架构的搭建、多主一从架构的配置、客户端挂载方式以及fuse方式访问CephFS的详细步骤和配置。
388 3
Ceph Reef(18.2.X)的CephFS高可用集群实战案例
|
存储
cephFS高可用分布式文件系统部署指南
关于如何部署高可用的cephFS分布式文件系统,包括集群的搭建、验证高可用性以及实现两主一从架构的详细指南。
1019 10
|
存储 关系型数据库 文件存储
Ubuntu22.04LTS基于cephadm快速部署Ceph Reef(18.2.X)集群
这篇文章是关于如何在Ubuntu 22.04LTS上使用cephadm工具快速部署Ceph Reef(18.2.X)存储集群的详细教程,包括ceph的基本概念、集群的搭建步骤、集群管理以及测试集群可用性等内容。
3659 8
Ubuntu22.04LTS基于cephadm快速部署Ceph Reef(18.2.X)集群
|
Shell 容器
Ceph Reef(18.2.X)访问ceph集群的方式及管理员节点配置案例
这篇文章是关于Ceph Reef(18.2.X)版本中访问ceph集群的方式和管理员节点配置的案例,介绍了使用cephadm shell的不同方式访问集群和如何配置管理节点以方便集群管理。
663 5
|
存储 对象存储 Swift
Ceph Reef(18.2.X)之对象访问策略配置
这篇文章讲述了对象存储的多种访问方式,包括HTTP、S3cmd、Swift和Python程序访问,并介绍了如何定制存储桶的访问策略和跨域规则。
278 8
Ceph Reef(18.2.X)之对象访问策略配置
|
存储 Kubernetes 数据安全/隐私保护
k8s对接ceph集群的分布式文件系统CephFS
文章介绍了如何在Kubernetes集群中使用CephFS作为持久化存储,包括通过secretFile和secretRef两种方式进行认证和配置。
604 5
|
网络安全
ceph的mgr组件模块dashboard图形化管理ceph集群
关于如何通过Ceph的mgr组件模块dashboard来图形化管理Ceph集群的教程,包括基于HTTP和HTTPS的配置步骤。
859 3
|
存储 块存储
Ceph Reef(18.2.X)集群的OSD管理基础及OSD节点扩缩容
这篇文章是关于Ceph Reef(18.2.X)集群的OSD管理基础及OSD节点扩缩容的详细教程,涵盖了OSD的基础操作、节点缩容的步骤和实战案例以及OSD节点扩容的基本流程和实战案例。
690 6
|
块存储
ceph-deploy部署ceph分部署集群
这篇博客详细介绍了如何使用ceph-deploy工具部署Ceph集群,包括环境准备、配置hosts、免密登录、时间同步、添加块设备、部署mon、mgr组件以及初始化OSD节点的步骤,并提供了在部署过程中可能遇到的问题和解决方案。
1188 4