• 高级运维学习(九)块存储、文件系统存储和对象存储的实现


    块存储基础

    • 块设备存取数据时,可以一次存取很多。字符设备只能是字符流
    1. [root@ceph1 ~]# ll /dev/sda
    2. brw-rw---- 1 root disk 8, 0 Dec 12 13:15 /dev/sda
    3. # b表示block,块设备
    4. [root@ceph1 ~]# ll /dev/tty
    5. crw-rw-rw- 1 root tty 5, 0 Dec 12 13:31 /dev/tty
    6. # c表示character,字符设备
    • 块存储,就是可以提供像硬盘一样的设备。使用块存储的节点,第一次连接块设备,需要对块设备进行分区、格式化,然后挂载使用。
    • ceph中的块设备叫做rbd,是rados block device的简写,表示ceph的块设备。rados是Reliable, Autonomic Distributed Object Store的简写,意思是“可靠、自主的分布式对象存储”。
    • Ceph块设备采用精简配置,可调整大小,并将数据存储在多个OSD上。
    • ceph提供存储时,需要使用存储池。为了给客户端提供存储资源,需要创建名为存储池的容器。存储池类似于逻辑卷管理中的卷组。卷组中包含很多硬盘和分区;存储池中包含各节点上的硬盘。
    • 查看基础存储池信息
    1. # 查看存储池。默认有一个名为.mgr的存储池,编号为1
    2. [ceph: root@ceph1 /]# ceph osd lspools
    3. 1 .mgr
    4. # 查看存储详细使用情况
    5. [ceph: root@ceph1 /]# ceph df
    6. --- RAW STORAGE ---
    7. CLASS SIZE AVAIL USED RAW USED %RAW USED
    8. hdd 180 GiB 180 GiB 187 MiB 187 MiB 0.10
    9. TOTAL 180 GiB 180 GiB 187 MiB 187 MiB 0.10
    10. --- POOLS ---
    11. POOL ID PGS STORED OBJECTS USED %USED MAX AVAIL
    12. .mgr 1 1 449 KiB 2 449 KiB 0 57 GiB
    13. # 查看.mgr存储池的副本数量
    14. [ceph: root@ceph1 /]# ceph osd pool get .mgr size
    15. size: 3
    • 在ceph中,操作块存储的命令也是rbd。
    • 创建存储池。如果不指定操作哪一个存储池,rbd命令将会操作名为rbd的存储池。该存储池不存在,需要自己创建。
    1. # 不指定存储池名字执行查看操作。提示名为rbd的存储池不存在
    2. [ceph: root@ceph1 /]# rbd ls
    3. rbd: error opening default pool 'rbd'
    4. Ensure that the default pool has been created or specify an alternate pool name.
    5. rbd: listing images failed: (2) No such file or directory

    存储池

    • 创建存储池是需要指定存储池中PG的数量。
    • Placement Group简称PG,可翻译为归置组。
    • PG只是一个组而已,用于把存储的对象分组管理。
    • 将数据放入集群时,对象被映射到pg,而这些pg被映射到OSD。这减少了我们需要跟踪的每个对象的元数据的数量以及我们需要运行的进程的数量。
    • 创建并使用存储池
    1. # 1. 创建名为rbd的存储池
    2. [ceph: root@ceph1 /]# ceph osd pool create rbd 100
    3. pool 'rbd' created
    4. # 2. 设置rbd存储池的应用类型是rbd。还可以是rgw或cephfs
    5. # 语法:ceph osd pool application enable <pool-name> <app-name>
    6. [ceph: root@ceph1 /]# ceph osd pool application enable rbd rbd
    7. # 3. 查看
    8. [ceph: root@ceph1 /]# ceph osd pool ls
    9. .mgr
    10. rbd
    11. [ceph: root@ceph1 /]# ceph df
    12. --- RAW STORAGE ---
    13. CLASS SIZE AVAIL USED RAW USED %RAW USED
    14. hdd 180 GiB 180 GiB 191 MiB 191 MiB 0.10
    15. TOTAL 180 GiB 180 GiB 191 MiB 191 MiB 0.10
    16. --- POOLS ---
    17. POOL ID PGS STORED OBJECTS USED %USED MAX AVAIL
    18. .mgr 1 1 897 KiB 2 2.6 MiB 0 57 GiB
    19. rbd 2 99 0 B 0 0 B 0 57 GiB
    20. # 4. 执行命令。不指定存储池,默认操作名为rbd的存储池。
    21. [ceph: root@ceph1 /]# rbd ls # 无输出内容,也不会报错

    镜像

    • 在存储池中划分空间提供给客户端作为硬盘使用。
    • 划分出来的空间,术语叫做镜像。
    1. # 1. 查看rbd存储池中有哪些镜像
    2. [ceph: root@ceph1 /]# rbd ls
    3. # 2. 创建名为img1的镜像,大小10GB
    4. [ceph: root@ceph1 /]# rbd create img1 --size 10G
    5. # 3. 查看存储池中有哪些镜像
    6. [ceph: root@ceph1 /]# rbd ls
    7. img1
    8. # 4. 查看镜像详情
    9. [ceph: root@ceph1 /]# rbd info img1
    10. rbd image 'img1':
    11. size 10 GiB in 2560 objects
    12. ...略...
    13. # 5. 扩容。容量只是承诺大小,并不会立即分配全部空间,所以值可以超过总容量。
    14. [ceph: root@ceph1 /]# rbd resize img1 --size 200G
    15. Resizing image: 100% complete...done.
    16. [ceph: root@ceph1 /]# rbd info img1
    17. rbd image 'img1':
    18. size 200 GiB in 51200 objects
    19. ...略...
    20. # 6. 删除镜像
    21. [ceph: root@ceph1 /]# rbd rm img1
    22. Removing image: 100% complete...done.

    ceph客户端

    • 客户端使用ceph块存储需要解决的问题:

      • 怎么用?装软件
      • ceph集群在哪?通过配置文件说明集群地址
      • 权限。keyring文件
    1. # 1. 拷贝/linux-soft/s2/zzg/ceph_soft/cephclient-rpm/目录内所有rpm包到pubserver的/var/ftp/rpms目录
    2. # 2. 更新yum仓库
    3. [root@pubserver ~]# createrepo /var/ftp/rpms/
    4. # 3. 安装ceph客户端软件
    5. [root@client1 ~]# yum install -y ceph-common
    6. # 4. 将ceph1上的配置文件和密钥keyring文件拷贝给客户端
    7. [root@ceph1 ceph_soft]# scp /etc/ceph/ceph.client.admin.keyring /etc/ceph/ceph.conf 192.168.88.10:/etc/ceph/
    8. # 5. 在客户端验证是否可以操作ceph
    9. [root@client1 ~]# rbd create img1 --size 10G
    10. [root@client1 ~]# rbd ls
    11. img1
    12. [root@client1 ~]# rbd info img1
    13. rbd image 'img1':
    14. size 10 GiB in 2560 objects
    15. ...略...
    16. # 6. 将ceph镜像映射为本地硬盘
    17. [root@client1 ~]# rbd map img1
    18. /dev/rbd0 # rbd为固定名称,0是编号
    19. # 7. 查看
    20. [root@client1 ~]# lsblk
    21. NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINT
    22. sda 8:0 0 60G 0 disk
    23. └─sda1 8:1 0 60G 0 part /
    24. sr0 11:0 1 10.5G 0 rom
    25. rbd0 253:0 0 10G 0 disk # rbd0来自于ceph镜像
    26. [root@client1 ~]# rbd showmapped # 镜像img1映射为了本地硬盘rbd0
    27. id pool namespace image snap device
    28. 0 rbd img1 - /dev/rbd0
    29. # 8. 应用
    30. [root@client1 ~]# mkdir /data
    31. [root@client1 ~]# mkfs.xfs /dev/rbd0
    32. [root@client1 ~]# mount /dev/rbd0 /data/
    33. [root@client1 ~]# df -h /data/
    34. Filesystem Size Used Avail Use% Mounted on
    35. /dev/rbd0 10G 105M 9.9G 2% /data
    36. [root@client1 ~]# cp /etc/hosts /data/
    37. [root@client1 ~]# ls /data/
    38. hosts
    • 删除
    1. # 查看img1的状态
    2. [root@client1 ~]# rbd status img1
    3. # 按以下步骤删除img1
    4. [root@client1 ~]# umount /dev/rbd0
    5. [root@client1 ~]# rbd unmap img1
    6. [root@client1 ~]# rbd rm img1
    7. Removing image: 100% complete...done.

    快照

    • 快照可以保存某一时间点时的状态数据
    • 快照是映像在特定时间点的只读逻辑副本
    • 希望回到以前的一个状态,可以恢复快照
    • 使用镜像、快照综合示例
    1. # 1. 在rbd存储池中创建10GB的镜像,名为img1
    2. [root@client1 ~]# rbd --help # 查看子命令
    3. [root@client1 ~]# rbd help create # 查看子命令create的帮助
    4. [root@client1 ~]# rbd create img1 --size 10G
    5. [root@client1 ~]# rbd list
    6. img1
    7. [root@client1 ~]# rbd info img1
    8. rbd image 'img1':
    9. size 10 GiB in 2560 objects
    10. order 22 (4 MiB objects)
    11. snapshot_count: 0
    12. id: fa91208bfdaf
    13. block_name_prefix: rbd_data.fa91208bfdaf
    14. format: 2
    15. features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
    16. op_features:
    17. flags:
    18. create_timestamp: Sat Dec 17 10:44:17 2022
    19. access_timestamp: Sat Dec 17 10:44:17 2022
    20. modify_timestamp: Sat Dec 17 10:44:17 2022
    21. # 2. 在客户端使用镜像img1,将其挂载到/mnt
    22. [root@client1 ~]# rbd list
    23. img1
    24. [root@client1 ~]# rbd map img1
    25. /dev/rbd0
    26. [root@client1 ~]# mkfs.xfs /dev/rbd0
    27. [root@client1 ~]# mount /dev/rbd0 /mnt/
    28. [root@client1 ~]# rbd showmapped
    29. id pool namespace image snap device
    30. 0 rbd img1 - /dev/rbd0
    31. [root@client1 ~]# df -h /mnt/
    32. Filesystem Size Used Avail Use% Mounted on
    33. /dev/rbd0 10G 105M 9.9G 2% /mnt
    34. # 3. 向/mnt中写入数据
    35. [root@client1 ~]# cp /etc/hosts /mnt/
    36. [root@client1 ~]# cp /etc/passwd /mnt/
    37. [root@client1 ~]# ls /mnt/
    38. hosts passwd
    39. # 4. 创建img1的快照,名为img1-sn1
    40. [root@client1 ~]# rbd snap create img1 --snap img1-sn1
    41. Creating snap: 100% complete...done.
    42. [root@client1 ~]# rbd snap ls img1
    43. SNAPID NAME SIZE PROTECTED TIMESTAMP
    44. 4 img1-sn1 10 GiB Sat Dec 17 10:46:07 2022
    45. # 5. 删除/mnt/中的数据
    46. [root@client1 ~]# rm -f /mnt/*
    47. # 6. 通过快照还原数据
    48. [root@client1 ~]# umount /mnt/
    49. [root@client1 ~]# rbd unmap /dev/rbd0
    50. [root@client1 ~]# rbd help snap rollback # 查看子命令帮助
    51. # 回滚img1到快照img1-sn1
    52. [root@client1 ~]# rbd snap rollback img1 --snap img1-sn1
    53. # 重新挂载
    54. [root@client1 ~]# rbd map img1
    55. /dev/rbd0
    56. [root@client1 ~]# mount /dev/rbd0 /mnt/
    57. [root@client1 ~]# ls /mnt/ # 数据还原完成
    58. hosts passwd
    • 保护快照,防止删除
    1. [root@client1 ~]# rbd help snap protect
    2. # 保护镜像img1的快照img1-sn1
    3. [root@client1 ~]# rbd snap protect img1 --snap img1-sn1
    4. [root@client1 ~]# rbd snap rm img1 --snap img1-sn1 # 不能删
    • 删除操作
    1. # 1. 取消对快照的保护
    2. [root@client1 ~]# rbd snap unprotect img1 --snap img1-sn1
    3. # 2. 删除快照
    4. [root@client1 ~]# rbd snap rm img1 --snap img1-sn1
    5. # 3. 卸载块设备
    6. [root@client1 ~]# umount /dev/rbd0
    7. # 4. 取消映射
    8. [root@client1 ~]# rbd unmap img1
    9. # 5. 删除镜像
    10. [root@client1 ~]# rbd rm img1

    快照克隆

    • 不能将一个镜像同时挂载到多个节点,如果这样操作,将会损坏数据
    • 如果希望不同的节点,拥有完全相同的数据盘,可以使用克隆技术
    • 克隆是基于快照的,不能直接对镜像克隆
    • 快照必须是受保护的快照,才能克隆
    • 克隆流程

    • 给多个客户端生成数据相同的数据盘
    1. # 1. 创建名为img2的镜像,大小10GB
    2. [root@client1 ~]# rbd create img2 --size 10G
    3. # 2. 向镜像中写入数据
    4. [root@client1 ~]# rbd map img2
    5. /dev/rbd0
    6. [root@client1 ~]# mkfs.xfs /dev/rbd0
    7. [root@client1 ~]# mount /dev/rbd0 /mnt/
    8. [root@client1 ~]# for i in {1..20}
    9. > do
    10. > echo "Hello World $i" > /mnt/file$i.txt
    11. > done
    12. [root@client1 ~]# ls /mnt/
    13. file10.txt file15.txt file1.txt file5.txt
    14. file11.txt file16.txt file20.txt file6.txt
    15. file12.txt file17.txt file2.txt file7.txt
    16. file13.txt file18.txt file3.txt file8.txt
    17. file14.txt file19.txt file4.txt file9.txt
    18. # 3. 卸载镜像
    19. [root@client1 ~]# umount /mnt/
    20. [root@client1 ~]# rbd unmap img2
    21. # 4. 为img2创建名为img2-sn1快照
    22. [root@client1 ~]# rbd snap create img2 --snap img2-sn1
    23. # 5. 保护img2-sn1快照
    24. [root@client1 ~]# rbd snap protect img2 --snap img2-sn1
    25. # 6. 通过受保护的快照img2-sn1创建克隆镜像
    26. [root@client1 ~]# rbd clone img2 --snap img2-sn1 img2-sn1-1
    27. [root@client1 ~]# rbd clone img2 --snap img2-sn1 img2-sn1-2
    28. # 7. 查看创建出来的、克隆的镜像
    29. [root@client1 ~]# rbd ls
    30. img2
    31. img2-sn1-1
    32. img2-sn1-2
    33. # 8. 不同的客户端挂载不同的克隆镜像,看到的是相同的数据
    34. [root@client1 ~]# rbd map img2-sn1-1
    35. /dev/rbd0
    36. [root@client1 ~]# mkdir /data
    37. [root@client1 ~]# mount /dev/rbd0 /data
    38. [root@client1 ~]# ls /data
    39. file10.txt file15.txt file1.txt file5.txt
    40. file11.txt file16.txt file20.txt file6.txt
    41. file12.txt file17.txt file2.txt file7.txt
    42. file13.txt file18.txt file3.txt file8.txt
    43. file14.txt file19.txt file4.txt file9.txt
    44. [root@ceph1 ~]# yum install -y ceph-common
    45. [root@ceph1 ~]# rbd map img2-sn1-2
    46. /dev/rbd0
    47. [root@ceph1 ~]# mkdir /data
    48. [root@ceph1 ~]# mount /dev/rbd0 /data/
    49. [root@ceph1 ~]# ls /data/
    50. file10.txt file15.txt file1.txt file5.txt
    51. file11.txt file16.txt file20.txt file6.txt
    52. file12.txt file17.txt file2.txt file7.txt
    53. file13.txt file18.txt file3.txt file8.txt
    54. file14.txt file19.txt file4.txt file9.txt
    • 查询镜像和快照
    1. # 查看快照信息
    2. [root@client1 ~]# rbd info img2 --snap img2-sn1
    3. rbd image 'img2':
    4. size 10 GiB in 2560 objects
    5. order 22 (4 MiB objects)
    6. snapshot_count: 1
    7. id: d46eed84bb61
    8. block_name_prefix: rbd_data.d46eed84bb61
    9. format: 2
    10. features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
    11. op_features:
    12. flags:
    13. create_timestamp: Sat Dec 17 10:58:05 2022
    14. access_timestamp: Sat Dec 17 10:58:05 2022
    15. modify_timestamp: Sat Dec 17 10:58:05 2022
    16. protected: True # 受保护
    17. # 查看克隆的快照
    18. [root@client1 ~]# rbd info img2-sn1-2
    19. rbd image 'img2-sn1-2':
    20. size 10 GiB in 2560 objects
    21. order 22 (4 MiB objects)
    22. snapshot_count: 0
    23. id: d48fe3d6559e
    24. block_name_prefix: rbd_data.d48fe3d6559e
    25. format: 2
    26. features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
    27. op_features:
    28. flags:
    29. create_timestamp: Sat Dec 17 10:59:53 2022
    30. access_timestamp: Sat Dec 17 10:59:53 2022
    31. modify_timestamp: Sat Dec 17 10:59:53 2022
    32. parent: rbd/img2@img2-sn1 # 父对象是rbd池中img2镜像的img2-sn1快照
    33. overlap: 10 GiB
    • 合并父子镜像

      • img2-sn1-2是基于img2的快照克隆来的,不能独立使用。
      • 如果父镜像删除了,子镜像也无法使用。
      • 将父镜像内容合并到子镜像中,子镜像就可以独立使用了。
    1. # 把img2的数据合并到子镜像img2-sn1-2
    2. [root@client1 ~]# rbd flatten img2-sn1-2
    3. # 查看状态,它就没有父镜像了
    4. [root@client1 ~]# rbd info img2-sn1-2
    5. rbd image 'img2-sn1-2':
    6. size 10 GiB in 2560 objects
    7. order 22 (4 MiB objects)
    8. snapshot_count: 0
    9. id: d48fe3d6559e
    10. block_name_prefix: rbd_data.d48fe3d6559e
    11. format: 2
    12. features: layering, exclusive-lock, object-map, fast-diff, deep-flatten
    13. op_features:
    14. flags:
    15. create_timestamp: Sat Dec 17 10:59:53 2022
    16. access_timestamp: Sat Dec 17 10:59:53 2022
    17. modify_timestamp: Sat Dec 17 10:59:53 2022
    18. # 删除父镜像,如果镜像正在被使用,则先取消
    19. [root@client1 ~]# umount /data/
    20. [root@client1 ~]# rbd unmap img2-sn1-1
    21. # 1. 删除镜像img2-sn1-1
    22. [root@client1 ~]# rbd rm img2-sn1-1
    23. # 2. 取消img2-sn1的保护
    24. [root@client1 ~]# rbd snap unprotect img2 --snap img2-sn1
    25. # 3. 删除img2-sn1快照
    26. [root@client1 ~]# rbd snap rm img2 --snap img2-sn1
    27. # 4. 删除img2
    28. [root@client1 ~]# rbd rm img2
    29. # 因为img2-sn1-2已经是独立的镜像了,所以它还可以使用
    30. # ceph1上的镜像没有受到影响
    31. [root@ceph1 ~]# cat /data/file1.txt
    32. Hello World 1

    开机自动挂载

    1. # 1. 准备镜像
    2. [root@client1 ~]# rbd create img1 --size 10G
    3. [root@client1 ~]# rbd map img1
    4. /dev/rbd0
    5. [root@client1 ~]# mkfs.xfs /dev/rbd0
    6. # 2. 设置开机自动挂载
    7. [root@client1 ~]# vim /etc/ceph/rbdmap # 指定要挂载的镜像及用户名、密钥
    8. rbd/img1 id=admin,keyring=/etc/ceph/ceph.client.admin.keyring
    9. [root@client1 ~]# vim /etc/fstab # 追加
    10. /dev/rbd/rbd/img1 /data xfs noauto 0 0
    11. # noauto的意思是,等rbdmap服务启动后,再执行挂载
    12. # 3. 启动rbdmap服务
    13. [root@client1 ~]# systemctl enable rbdmap --now
    14. # 4. reboot后查看结果
    15. [root@client1 ~]# df -h /data/
    16. Filesystem Size Used Avail Use% Mounted on
    17. /dev/rbd0 10G 105M 9.9G 2% /data

    ceph文件系统

    • 文件系统:相当于是组织数据存储的方式。
    • 格式化时,就是在为存储创建文件系统。
    • Linux对ceph有很好的支持,可以把ceph文件系统直接挂载到本地。
    • 要想实现文件系统的数据存储方式,需要有MDS组件

    使用MDS

    • 元数据就是描述数据的属性。如属主、属组、权限等。

    • ceph文件系统中,数据和元数据是分开存储的

    • 新建存储池

      • 归置组PG:存储池包含PG。PG是一个容器,用于存储数据。
      • 为了管理方便,将数量众多的数据放到不同的PG中管理,而不是直接把所有的数据扁平化存放。
      • 通常一个存储池中创建100个PG。
    • 创建ceph文件系统

    1. # 1. 新建一个名为data1的存储池,目的是存储数据,有100个PG
    2. [root@client1 ~]# ceph osd pool create data01 100
    3. # 2. 新建一个名为metadata1的存储池,目的是存储元数据
    4. [root@client1 ~]# ceph osd pool create metadata01 100
    5. # 3. 创建名为myfs1的cephfs,数据保存到data1中,元数据保存到metadata1
    6. [root@client1 ~]# ceph fs new myfs01 metadata01 data01
    7. # 4. 查看存储池
    8. [root@client1 ~]# ceph osd lspools
    9. 1 .mgr
    10. 2 rbd
    11. 3 data01
    12. 4 metadata01
    13. [root@client1 ~]# ceph df
    14. --- RAW STORAGE ---
    15. CLASS SIZE AVAIL USED RAW USED %RAW USED
    16. hdd 180 GiB 180 GiB 206 MiB 206 MiB 0.11
    17. TOTAL 180 GiB 180 GiB 206 MiB 206 MiB 0.11
    18. --- POOLS ---
    19. POOL ID PGS STORED OBJECTS USED %USED MAX AVAIL
    20. .mgr 1 1 449 KiB 2 1.3 MiB 0 57 GiB
    21. rbd 2 32 7.1 MiB 43 22 MiB 0.01 57 GiB
    22. data01 3 94 0 B 0 0 B 0 57 GiB
    23. metadata01 4 94 0 B 0 0 B 0 57 GiB
    24. # 5. 查看文件系统
    25. [root@client1 ~]# ceph fs ls
    26. name: myfs01, metadata pool: metadata01, data pools: [data01 ]
    27. # 6. 启动MDS服务
    28. [root@client1 ~]# ceph orch apply mds myfs01 --placement="2 ceph1 ceph2"
    29. # 7. 查看部署结果
    30. [root@client1 ~]# ceph -s
    31. cluster:
    32. id: a4b69ab4-79dd-11ed-ae7b-000c2953b002
    33. health: HEALTH_OK
    34. services:
    35. mon: 3 daemons, quorum ceph1,ceph3,ceph2 (age 92m)
    36. mgr: ceph1.gmqorm(active, since 92m), standbys: ceph3.giqaph
    37. mds: 1/1 daemons up, 1 standby # mds服务信息
    38. osd: 9 osds: 9 up (since 92m), 9 in (since 4d)
    39. ...略...
    • 客户端使用cephfs
    1. # 挂载文件系统需要密码。查看密码
    2. [root@client1 ~]# cat /etc/ceph/ceph.client.admin.keyring
    3. [client.admin]
    4. key = AQBmhINh1IZjHBAAvgk8m/FhyLiH4DCCrnrdPQ==
    5. # -t 指定文件系统类型。-o是选项,提供用户名和密码
    6. [root@client1 ~]# mkdir /mydata
    7. [root@client1 ~]# mount.ceph 192.168.88.13:/ /mydata -o name=admin,secret=AQC5u5ZjnTA1ERAAruLAI8F1W1nyOgxZSx0UXw==
    8. [root@client1 ~]# df -h /mydata/
    9. Filesystem Size Used Avail Use% Mounted on
    10. 192.168.88.13:/ 57G 0 57G 0% /mydata

    对象存储

    配置服务器端

    • 需要专门的客户端访问
    • 键值对存储方式
    • 对象存储需要rgw组件
    • 安装部署
    1. # 1. 在ceph1/ceph2上部署rgw服务,名为myrgw
    2. [root@client1 ~]# ceph orch apply rgw myrgw --placement="2 ceph1 ceph2" --port 8080
    3. [root@client1 ~]# ceph -s
    4. cluster:
    5. id: a4b69ab4-79dd-11ed-ae7b-000c2953b002
    6. health: HEALTH_OK
    7. services:
    8. mon: 3 daemons, quorum ceph1,ceph3,ceph2 (age 101m)
    9. mgr: ceph1.gmqorm(active, since 6h), standbys: ceph3.giqaph
    10. mds: 1/1 daemons up, 1 standby
    11. osd: 9 osds: 9 up (since 6h), 9 in (since 5d); 1 remapped pgs
    12. rgw: 2 daemons active (2 hosts, 1 zones) # rgw信息
    13. ...略...

    配置客户端

    • ceph对象存储提供了一个与亚马逊S3(Amazon Simple Storage Service)兼容的接口
    • 在S3中,对象被存储在一个称作桶(bucket)的器皿中。这就好像是本地文件存储在目录中一样。
    1. # 1. 安装amazon S3 cli工具(客户端工具)
    2. [root@client1 ~]# yum install -y awscli
    3. # 2. 在ceph中创建一个用户
    4. [root@client1 ~]# radosgw-admin user create --uid=testuser --display-name="Test User" --email=test@tedu.cn --access-key=12345 --secret=67890
    5. # 3. 初始化客户端
    6. [root@client1 ~]# aws configure --profile=ceph
    7. AWS Access Key ID [None]: 12345
    8. AWS Secret Access Key [None]: 67890
    9. Default region name [None]: # 回车
    10. Default output format [None]: # 回车
    11. # 4. 创建名为testbucket的bucket,用于存储数据
    12. [root@client1 ~]# vim /etc/hosts # 添加以下内容
    13. 192.168.88.11 ceph1
    14. 192.168.88.12 ceph2
    15. 192.168.88.13 ceph3
    16. [root@client1 ~]# aws --profile=ceph --endpoint=http://ceph1:8080 s3 mb s3://testbucket
    17. # 5. 上传文件
    18. [root@client1 ~]# aws --profile=ceph --endpoint=http://ceph1:8080 --acl=public-read-write s3 cp /etc/hosts s3://testbucket/hosts.txt
    19. # 6. 查看bucket中的数据
    20. [root@client1 ~]# aws --profile=ceph --endpoint=http://ceph1:8080 s3 ls s3://testbucket
    21. 2022-12-17 17:05:58 241 hosts.txt
    22. # 7. 下载数据
    23. [root@client1 ~]# wget -O zhuji http://ceph1:8080/testbucket/hosts.txt

    访问Dashborad

    • 通过浏览器访问https://192.168.88.11:8443,用户名为admin,密码是安装时指定的123456。
  • 相关阅读:
    如何有效建立客户关系,提高复购率与客户的终生价值
    do while实现九宫格概率抽奖
    Python自学笔记8:实操案例五(循环输出26个字母对应的ASCII码值,模拟用户登录,猜数游戏,计算100-999之间的水仙花数)
    数据结构之查找(分块查找)
    飞桨平台搭建PP-YOLOE模型
    C++17future类+可变参模板实现线程池
    Python常用类库:提升编程效率的利器
    必应bing国内广告怎样开户投放呢?
    美妆行业的市场分析
    模拟实现list
  • 原文地址:https://blog.csdn.net/2301_79227925/article/details/133064251