一、Ceph文件系统简介

CephFS提供兼容POSIX的文件系统,将其数据和与那数据作为对象那个存储在Ceph中

CephFS依靠MDS节点来协调RADOS集群的访问

元数据服务器

MDS管理元数据(文件的所有者、时间戳和模式等),也负责缓存元数据访问权限,管理客户端缓存来维护缓存一致性。

CephFS客户端首先联系MON,进行身份验证后,将查询活跃MDS的文件元数据,并通过直接与OSD通信来访问文件或目录的对象。

Ceph支持一个集群中有一个活跃的MDS,多个备用MDS。目前也支持同时多个活跃MDS,但该功能尚未GA

目前Ceph仅支持一个集群中有一个活跃的CephFS文件系统

目前CephFS的快照功能尚未GA

在ceph2部署mds

二、部署

2.1 安装mds包

[root@ceph2 ~]#  yum -y install ceph-mds

授权

[root@ceph2 ~]# ceph auth get-or-create mds.ceph2 mon 'allow profile mds' osd 'allow rwx' msd 'allow' -o /etc/ceph/ceph.mds.ceph2.keyring

[root@ceph2 ~]# systemctl restart ceph-mds@ceph2

[root@ceph2 ~]# mkdir /var/lib/ceph/mds/ceph-ceph2

[root@ceph2 ~]# mv /etc/ceph/ceph.mds.ceph2.keyring /var/lib/ceph/mds/ceph-ceph2/keyring

[root@ceph2 ~]# chown ceph.ceph /var/lib/ceph/mds/ceph-ceph2/keyring

[root@ceph2 ~]# /usr/bin/ceph-mds -f --cluster ceph --id ceph2  --setuser ceph --setgroup ceph

  1. starting mds.ceph2 at -

[root@ceph2 ~]# systemctl restart ceph-mds@ceph2

[root@ceph2 ~]# ps -ef |grep mds

  1. ceph : ? :: /usr/bin/ceph-mds -f --cluster ceph --id ceph2 --setuser ceph --setgroup ceph

2.2 创建Ceph文件系统

CephFS文件系统需要两个存储池,一个用于存储CephFS数据,一个用于存储CephFS元数据

  1. [root@ceph2 ~]# ceph osd pool create cephfs_metadata
  2. pool 'cephfs_metadata' created
  3. [root@ceph2 ~]# ceph osd pool create cephfs_data
  4. pool 'cephfs_data' created

创建一个名叫cephfs的文件系统

  1. [root@ceph2 ~]# ceph fs new cephfs cephfs_metadata cephfs_data
  2. new fs with metadata pool and data pool
  3. [root@ceph2 ~]# ceph -s
  4. cluster:
  5. id: 35a91e48--4e96-a7ee-980ab989d20d
  6. health: HEALTH_OK
  7.  
  8. services:
  9. mon: daemons, quorum ceph2,ceph3,ceph4
  10. mgr: ceph4(active), standbys: ceph2, ceph3
  11. mds: cephfs-// up {=ceph2=up:active}
  12. osd: osds: up, in
  13. rbd-mirror: daemon active
  14.  
  15. data:
  16. pools: pools, pgs
  17. objects: objects, MB
  18. usage: MB used, GB / GB avail
  19. pgs: active+clean
  20.  
  21. io:
  22. client: B/s rd, B/s wr, op/s rd, op/s wr

2.4 查看

[root@ceph2 ~]# ceph fs status

2.5 在ceoh3上安装MDS

  1. [root@ceph3 ~]# yum -y install ceph-mds
  2. [root@ceph3 ~]# mkdir /var/lib/ceph/mds/ceph-ceph3
  3. [root@ceph3 ~]# ceph auth get-or-create mds.ceph3 mon 'allow profile mds' osd 'allow rwx' mds 'allow' -o /var/lib/ceph/mds/ceph-ceph3/keyring
  4. [root@ceph3 ~]# chown ceph.ceph /var/lib/ceph/mds/ceph-ceph3/keyring
  5. [root@ceph3 ~]# systemctl restart ceph-mds@ceph3
  6. [root@ceph3 ~]# ps -ef|grep mds
  7. ceph : ? :: /usr/bin/ceph-mds -f --cluster ceph --id ceph3 --setuser ceph --setgroup ceph

[root@ceph3 ~]# ceph fs status

注:默认情况下,ceph只支持一个活跃的mds,其他的作为备用mds,但目前在实验性质下也可以同时开启多个活跃的mds,生产环境不保证数据的完整性

2.5 创建授权用户进行挂载操作

  1. [root@ceph2 ~]# ceph auth get-or-create client.cephfs mon 'allow r' osd 'allow rw pool=cephfs_metadata,allow rw pool=cephfs_data' -o /etc/ceph/ceph.client.cephfs.keyring
  2. [root@ceph2 ~]# ll /etc/ceph/ceph.client.cephfs.keyring
  3. -rw-r--r-- root root Mar : /etc/ceph/ceph.client.cephfs.keyring
  4. [root@ceph2 ~]# scp /etc/ceph/ceph.client.cephfs.keyring root@ceph1:/etc/ceph/
  5. root@ceph1's password:
  6. ceph.client.cephfs.keyring

2.6 在ceph1上测试秘钥环是否可用

  1. [root@ceph1 ~]# ceph -s --id cephfs
  2. cluster:
  3. id: 35a91e48--4e96-a7ee-980ab989d20d
  4. health: HEALTH_OK
  5.  
  6. services:
  7. mon: daemons, quorum ceph2,ceph3,ceph4
  8. mgr: ceph4(active), standbys: ceph2, ceph3
  9. mds: cephfs-// up {=ceph2=up:active}, up:standby #一个主,一个备
  10. osd: osds: up, in
  11. rbd-mirror: daemon active
  12.  
  13. data:
  14. pools: pools, pgs
  15. objects: objects, MB
  16. usage: MB used, GB / GB avail
  17. pgs: active+clean
  18.  
  19. io:
  20. client: B/s wr, op/s rd, op/s wr

2.7 使用cephfs挂载

挂载卡住,修改用户权限,再次尝试

  1. [root@ceph2 ~]# cd /etc/ceph/
  2. [root@ceph2 ceph]# rm -rf ceph.client.cephfs.keyring
  3. [root@ceph2 ceph]# ceph auth caps client.cephfs mon 'allow r' mds 'allow' osd 'allow rw pool=cephfs_metadata, allow rw pool=cephfs_data' -o /etc/ceph/ceph.client.cephfs.keyring
  4. updated caps for client.cephfs
  5. [root@ceph2 ceph]# ceph auth get-or-create client.cephfs -o /etc/ceph/ceph.client.cephfs.keyring
  6. [root@ceph2 ceph]# cat /etc/ceph/ceph.client.cephfs.keyring
  7. [client.cephfs]
  8. key = AQAl8Zlcdbt/DRAA3cHKjt2BFSCY7cmio6mrXw==
  9. [root@ceph2 ceph]# scp /etc/ceph/ceph.client.cephfs.keyring ceph1:/etc/ceph/
  10. root@ceph1's password:
  11. ceph.client.cephfs.keyring

2.8 挂载

  1. root@ceph1 ~]# ceph-fuse --keyring /etc/ceph/ceph.client.cephfs.keyring --name client.cephfs -m ceph2:,ceph3:,ceph4: /mnt/cephfs/
  2. ceph-fuse[]: starting ceph client
  3. -- ::26.351649 7f4a3242b040 - init, newargv = 0x55bc8e6bba40 newargc=
  4. ceph-fuse[]: starting fuse
  5. [root@ceph1 ~]# df -hT
  6. Filesystem Type Size Used Avail Use% Mounted on
  7. /dev/vda1 xfs 40G .7G 39G % /
  8. devtmpfs devtmpfs 893M 893M % /dev
  9. tmpfs tmpfs 920M 920M % /dev/shm
  10. tmpfs tmpfs 920M 25M 896M % /run
  11. tmpfs tmpfs 920M 920M % /sys/fs/cgroup
  12. /dev/rbd1 xfs .0G 33M .0G % /mnt/ceph2
  13. /dev/rbd0 xfs .0G 33M .0G % /mnt/ceph
  14. tmpfs tmpfs 184M 184M % /run/user/
  15. ceph-fuse fuse.ceph-fuse 43G 43G % /mnt/cephfs #挂载成功
  16. [root@ceph1 ~]# cd /mnt/cephfs/
  17. [root@ceph1 cephfs]# touch 111 #尝试写数据,正常
  18. [root@ceph1 cephfs]# echo sucessfull >>
  19. [root@ceph1 cephfs]# cat
  20. sucessfull

2.9 写进启动文件

  1. [root@ceph1 cephfs]# cd
  2. [root@ceph1 ~]# umount /mnt/cephfs
  3. [root@ceph1 ~]# echo "id=cephfs,keyring=/etc/ceph/ceph.client.cephfs.keyring /mnt/cephfs fuse.ceph defaults,_netdev 0 0 " >> /etc/fstab
  4. [root@ceph1 ~]# mount -a
  5. mount: special device /dev/rbd/rbd/testimg-copy does not exist
  6. ceph-fuse[]: starting ceph client
  7. -- ::57.070081 7f25f0c5c040 - init, newargv = 0x55aa8aab30a0 newargc=
  8. ceph-fuse[]: starting fuse
  9. [root@ceph1 ~]# df -hT
  10. Filesystem Type Size Used Avail Use% Mounted on
  11. /dev/vda1 xfs 40G .7G 39G % /
  12. devtmpfs devtmpfs 893M 893M % /dev
  13. tmpfs tmpfs 920M 920M % /dev/shm
  14. tmpfs tmpfs 920M 25M 896M % /run
  15. tmpfs tmpfs 920M 920M % /sys/fs/cgroup
  16. /dev/rbd1 xfs .0G 33M .0G % /mnt/ceph2
  17. /dev/rbd0 xfs .0G 33M .0G % /mnt/ceph
  18. tmpfs tmpfs 184M 184M % /run/user/
  19. ceph-fuse fuse.ceph-fuse 43G 43G % /mnt/cephfs #成功
  20. [root@ceph1 ~]# cd /mnt/cephfs/
  21. [root@ceph1 cephfs]# ll
  22. total
  23. -rw-r--r-- root root Mar :

2.10 使用内核挂载

  1. ceph auth get-key client.cephfs -o /etc/ceph/cephfskey
  2. [root@ceph2 ceph]# ll /etc/ceph/cephfskey
  3. -rw-r--r-- root root Mar : /etc/ceph/cephfskey
  4. [root@ceph2 ceph]# scp /etc/ceph/cephfskey ceph1:/etc/ceph/
  5. root@ceph1's password:
  6. cephfskey
  7. [root@ceph1 ~]# mount -t ceph ceph2:,ceph3:,ceph4::/ /mnt/cephfs -o name=cephfs,secretfile=/etc/ceph/cephfskey
  8. [root@ceph1 ~]# df -hT
  9. Filesystem Type Size Used Avail Use% Mounted on
  10. /dev/vda1 xfs 40G .7G 39G % /
  11. devtmpfs devtmpfs 893M 893M % /dev
  12. tmpfs tmpfs 920M 920M % /dev/shm
  13. tmpfs tmpfs 920M 25M 896M % /run
  14. tmpfs tmpfs 920M 920M % /sys/fs/cgroup
  15. /dev/rbd1 xfs .0G 33M .0G % /mnt/ceph2
  16. /dev/rbd0 xfs .0G 33M .0G % /mnt/ceph
  17. tmpfs tmpfs 184M 184M % /run/user/
  18. 172.25.250.11:,172.25.250.12:,172.25.250.13::/ ceph 135G .8G 134G % /mnt/cephfs
  19. [root@ceph1 ~]# echo "ceph2:6789,ceph3:6789,ceph4:6789:/ /mnt/cephfs ceph name=cephfs,secretfile=/etc/ceph/cephfskey,noatime,_netdev 0 0" >> /etc/fstab

注:

通过内核客户端挂载时,可能出现超时,解决办法:

ceph osd crush tunables hammer

ceph osd crush reweight-all

实验完成!!!


博主声明:本文的内容来源主要来自誉天教育晏威老师,由本人实验完成操作验证,需要的博友请联系誉天教育(http://www.yutianedu.com/),获得官方同意或者晏老师(https://www.cnblogs.com/breezey/)本人同意即可转载,谢谢!

013 CephFS文件系统的更多相关文章

  1. cephfs文件系统场景

    创建cephfs文件系统: [cephfsd@ceph-admin ceph]$ cd /etc/ceph [cephfsd@ceph-admin ceph]$ ceph fs ls No files ...

  2. ceph 008 ceph多区域网关(ceph对象容灾) cephfs文件系统

    clienta作为集群的管理人员.一部分.他是需要秘钥与配置文件的 但真正服务端只需要通过curl就好 ceph 多区域网关 对象存储容灾解决方案 zone与zone会做数据同步. 把会做同步的rgw ...

  3. 6.Ceph 基础篇 - CephFS 文件系统

    文章转载自:https://mp.weixin.qq.com/s?__biz=MzI1MDgwNzQ1MQ==&mid=2247485294&idx=1&sn=e9039504 ...

  4. Ceph 文件系统 CephFS 的实战配置,等你来学习 -- <4>

    Ceph 文件系统 CephFS 的介绍与配置 CephFs介绍 Ceph File System (CephFS) 是与 POSIX 标准兼容的文件系统, 能够提供对 Ceph 存储集群上的文件访问 ...

  5. Ceph RBD CephFS 存储

    Ceph RBD  CephFS 存储 环境准备: (这里只做基础测试, ceph-manager , ceph-mon, ceph-osd 一共三台) 10.6.0.140 = ceph-manag ...

  6. kubernetes多节点的pod挂载同一个cephfs目录

    一.安装cephfs 方法一: 直接进入deploy目录,执行: ceph-deploy --overwrite-conf mds create ceph01:mds-daemon- 上面的ceph0 ...

  7. Centos7部署CephFS

    标签(空格分隔): ceph环境,ceph,cephfs cephfs部署之前准备工作: 1. 一个 clean+active 的cluster cluster部署参考:centos7下搭建ceph ...

  8. IO解惑:cephfs、libaio与io瓶颈

    最近笔者在对kernel cephfs客户端进行fio direct随机大io读测试时发现,在numjobs不变的情况下,使用libaio作为ioengine,无论怎么调节iodepth,测试结果都变 ...

  9. Ubuntu 18.04.5 LTS Ceph集群之 cephx 认证及使用普通用户挂载RBD和CephFS

    1.cephx认证和授权 1.1 CephX认证机制 Ceph使用cephx协议对客户端进行身份认证: 1.每个MON都可以对客户端进行身份验正并分发密钥, 不存在单点故障和性能瓶颈 2. MON会返 ...

随机推荐

  1. C++四:继承与派生

    C++四:继承与派生 一.概念    继承就是从先辈处得到属性和行为特性.类的继承,是指新的类从已有类的那里得到的特性.类的派生,就是指已有类产生新类的过程. 二.应用 定义为 class 派生类名: ...

  2. 大侦探福老师——幽灵Crash谜踪案

    闲鱼Flutter技术的基础设施已基本趋于稳定,就在我们准备松口气的时候,一个Crash却异军突起冲击着我们的稳定性防线!闲鱼技术火速成立侦探小组执行嫌犯侦查行动,经理重重磨难终于在一个隐蔽的角落将其 ...

  3. 4、安装supervisor

    1.安装 sudo apt-get install supervisor 2.如果报phthond2.7错误,则执行 easy_install supervisor 3.配置文件位置和配置文件例子 配 ...

  4. Spark-shell批量命令执行脚本

    #!/bin/bash source /etc/profile exec $SPARK_HOME/bin/spark-shell --queue tv --name spark-sql-test -- ...

  5. Python 3.7.0 For Mac版软件安装教程附下载地址

    https://www.jianshu.com/p/f02d6f01eba7

  6. springboot2动态数据源的绑定

    由于springboot2更新了绑定参数的api,部分springboot1用于绑定的工具类如RelaxedPropertyResolver已经无法在新版本中使用.本文实现参考了https://blo ...

  7. HOSt ip is not allowed to connect to this MySql server, MYSQL添加远程用户或允许远程访问三种方法

    HOSt ip is not allowed to connect to this MySql server 报错:1130-host ... is not allowed to connect to ...

  8. PHP两个变量值互换(不用第三变量)

    <?php /**  * 双方变量为数字或者字符串时  * 使用list()和array()方法可以达到交换变量值得目的  */ $a = "This is A"; // a ...

  9. Python--day41--thread1.join()

    在 Python 的多线程编程中,在实例代码中经常有 thread1.join()这样的代码.那么今天咱们用实际代码来解释一下 join 函数的作用. join的原理就是依次检验线程池中的线程是否结束 ...

  10. LOGO的浮空显示-Verilog

    为了方便生成准确的mif数据,以实现特定的透明效果.使用Photoshop将网上下载的Logo修改颜色,保存大小为120*120像素,如图1所示. 图1 ps修改后的Logo 使用Pic2mif软件, ...