• Loongnix单机部署Ceph(LoongArch架构、Ceph N版、手动部署MON、OSD、MGR、Dashboard服务)


    基础环境信息

    • CPU:龙芯3C5000L×2
    • 内存:128G
    • 硬盘
      • 系统盘:一块512G的NVME的SSD
      • 数据盘:三块16T的HDD
    • 操作系统版本:Loongnix 8.4
    • Ceph版本:Ceph 14.2.21(Nautilus)

    Ceph集群角色

    主机名IP地址Ceph角色
    ceph0110.40.64.191mon×1、mgr×1、osd×3

    环境预配置

    1. 配置主机名称

      hostnamectl set-hostname ceph01
      bash
      
      • 1
      • 2
    2. 关闭防火墙和selinux

      systemctl disable --now firewalld
      setenforce 0
      sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
      
      • 1
      • 2
      • 3
    3. 配置时间同步

      yum install -y chrony
      sed -i '/^pool/d' /etc/chrony.conf
      sed -i '/^server/d' /etc/chrony.conf
      echo "pool ntp.aliyun.com iburst" >> /etc/chrony.conf
      systemctl restart chronyd.service && systemctl enable chronyd.service
      timedatectl status
      chronyc sources
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
    4. 安装Ceph源N版

      yum install -y loongnix-release-ceph-nautilus
      
      • 1

    部署ceph mon服务

    1. 安装ceph-mon服务程序

      yum install -y ceph-mon
      
      • 1
    2. 初始化mon服务

      生成uuid

      uuidgen
      468e23e9-c98d-48f2-9432-9b17774613c7
      
      • 1
      • 2

      创建Ceph集群配置文件

      vim /etc/ceph/ceph.conf
      
      • 1
      fsid = 468e23e9-c98d-48f2-9432-9b17774613c7
      mon_initial_members = ceph01 
      mon_host = 10.40.64.191 
      public_network = 10.40.64.0/24 
      auth_cluster_required = cephx
      auth_service_required = cephx
      auth_client_required = cephx
      osd_journal_size = 1024
      osd_pool_default_size = 3
      osd_pool_default_min_size = 2
      osd_pool_default_pg_num = 64
      osd_pool_default_pgp_num = 64
      osd_crush_chooseleaf_type = 1
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • fsid: 文件系统ID,用于标识Ceph集群中的特定文件系统。
      • mon_initial_members: 监控器(Mon)服务的初始成员列表,这里只有一个成员"ceph01"。
      • mon_host: 监控器(Mon)服务所在的主机地址。
      • public_network: 公共网络地址范围,用于定义Ceph集群与外部网络的通信范围。
      • auth_cluster_required: 认证集群所需的最小OSD数量。
      • auth_service_required: 认证服务所需的最小OSD数量。
      • auth_client_required: 认证客户端所需的最小OSD数量。
      • osd_journal_size: OSD日志的大小,以MB为单位。
      • osd_pool_default_size: 默认的OSD池大小,以OSD数量为单位。
      • osd_pool_default_min_size: 默认的OSD池最小大小,以OSD数量为单位。
      • osd_pool_default_pg_num: 默认的PG数量,用于副本集中的CRUSH映射。
      • osd_pool_default_pgp_num: 默认的PG优先级数量,用于副本集中的CRUSH映射。
      • osd_crush_chooseleaf_type: 在CRUSH算法中选择叶子节点的类型。

      创建集群Monitor密钥

      ceph-authtool --create-keyring /tmp/ceph.mon.keyring --gen-key -n mon. --cap mon 'allow *'
      
      • 1

      创建client.admin用户,添加到集群密钥中。

      ceph-authtool --create-keyring /etc/ceph/ceph.client.admin.keyring --gen-key -n client.admin --cap mon 'allow *' --cap osd 'allow *' --cap mds 'allow *' --cap mgr 'allow *'
      
      • 1

      创建client.bootstrap-osd用户密钥,添加到集群密钥中。

      ceph-authtool --create-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring --gen-key -n client.bootstrap-osd --cap mon 'profile bootstrap-osd' --cap mgr 'allow r'
      
      • 1

      将生成的密钥添加到ceph.mon.keyring

      ceph-authtool /tmp/ceph.mon.keyring --import-keyring /etc/ceph/ceph.client.admin.keyring
      ceph-authtool /tmp/ceph.mon.keyring --import-keyring /var/lib/ceph/bootstrap-osd/ceph.keyring
      
      • 1
      • 2

      使用主机名、主机IP地址、FSID生成监视器映射monitor map。

      monmaptool --create --add ceph01 10.40.64.191 --fsid 468e23e9-c98d-48f2-9432-9b17774613c7 /tmp/monmap
      
      • 1
      • 10.40.64.191:/etc/ceph/ceph.conf中对应的mon_host
      • 468e23e9-c98d-48f2-9432-9b17774613c7:/etc/ceph/ceph.conf中对应的fsid

      在监视主机上创建默认数据目录。

      sudo -u ceph mkdir /var/lib/ceph/mon/ceph-ceph01
      
      • 1

      使用监视器映射monitor map和keyring填充监视器守护进程。

      chown ceph.ceph -R /var/lib/ceph /etc/ceph /tmp/ceph.mon.keyring /tmp/monmap
      sudo -u ceph ceph-mon --mkfs -i ceph01 --monmap /tmp/monmap --keyring /tmp/ceph.mon.keyring
      ls /var/lib/ceph/mon/ceph-ceph01/
      
      • 1
      • 2
      • 3
    3. 启动monitor服务

      systemctl start ceph-mon@ceph01
      systemctl enable ceph-mon@ceph01
      systemctl status ceph-mon@ceph01
      
      • 1
      • 2
      • 3
    4. 查看当前集群状态

      [root@ceph01 ceph]# ceph -s
      
      • 1

    HEALTH_WARN警报信息清除

    出现警告:mons are allowing insecure global_id reclaim。
    解决办法:ceph config set mon auth_allow_insecure_global_id_reclaim false

    出现警告:monitors have not enabled msgr2
    解决办法:ceph mon enable-msgr2

    部署ceph osd服务(ceph-volume 自动化创建)

    1. 安装ceph-osd服务程序

      yum install -y ceph-osd
      
      • 1
    2. 初始化osd服务

      通过fdisk等工具查看磁盘盘符,然后利用ceph-volume工具自动化创建osd服务。

      ceph-volume lvm create: error: GPT headers found, they must be removed on: /dev/sda

      sgdisk --zap-all /dev/sda
      
      • 1
      ceph-volume lvm create --data /dev/sda
      ceph-volume lvm create --data /dev/sdb
      ceph-volume lvm create --data /dev/sdc
      
      • 1
      • 2
      • 3
    3. 查看当前集群状态

      通过ceph osd tree命令查询集群状态,可见集群services中所有osd服务已启动。

      ceph osd tree
      
      • 1
      ID CLASS WEIGHT   TYPE NAME       STATUS REWEIGHT PRI-AFF 
      -1       43.65807 root default                            
      -3       43.65807     host ceph01                         
       0   hdd 14.55269         osd.0       up  1.00000 1.00000 
       1   hdd 14.55269         osd.1       up  1.00000 1.00000 
       2   hdd 14.55269         osd.2       up  1.00000 1.00000
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6

    部署ceph mgr服务并开启Dashboard

    1. 安装ceph-mgr服务程序

      yum install -y ceph-mgr
      
      • 1
    2. 初始化并启动主mgr服务

      mkdir -p /var/lib/ceph/mgr/ceph-ceph01
      chown ceph.ceph -R /var/lib/ceph
      ceph-authtool --create-keyring /etc/ceph/ceph.mgr.ceph01.keyring --gen-key -n mgr.ceph01 --cap mon 'allow profile mgr' --cap osd 'allow *' --cap mds 'allow *'
      ceph auth import -i /etc/ceph/ceph.mgr.ceph01.keyring
      ceph auth get-or-create mgr.ceph01 -o /var/lib/ceph/mgr/ceph-ceph01/keyring
      
      • 1
      • 2
      • 3
      • 4
      • 5
      systemctl start ceph-mgr@ceph01
      systemctl enable ceph-mgr@ceph01
      systemctl status ceph-mgr@ceph01
      
      • 1
      • 2
      • 3
    3. 查看当前集群状态

      [root@ceph01 ceph]# ceph -s
        cluster:
          id:     468e23e9-c98d-48f2-9432-9b17774613c7
          health: HEALTH_OK
       
        services:
          mon: 1 daemons, quorum ceph01 (age 2h)
          mgr: ceph01(active, since 112m)
          osd: 3 osds: 3 up (since 3h), 3 in (since 3h)
       
        data:
          pools:   0 pools, 0 pgs
          objects: 0 objects, 0 B
          usage:   3.0 GiB used, 44 TiB / 44 TiB avail
          pgs:     
      
      • 1
      • 2
      • 3
      • 4
      • 5
      • 6
      • 7
      • 8
      • 9
      • 10
      • 11
      • 12
      • 13
      • 14
      • 15
    4. 使能Dashboard访问功能

      开启mgr dashboard功能

      ceph mgr module enable dashboard
      
      • 1

      生成并安装自签名的证书

      ceph dashboard create-self-signed-cert
      
      • 1

      配置dashboard

      ceph config set mgr mgr/dashboard/server_addr 10.40.64.191
      ceph config set mgr mgr/dashboard/server_port 8080
      ceph config set mgr mgr/dashboard/ssl_server_port 8443
      
      • 1
      • 2
      • 3

      创建一个dashboard登录用户名密码

      echo '123456' > password.txt
      ceph dashboard ac-user-create admin  administrator -i password.txt
      
      • 1
      • 2

      通过Web访问Ceph Dashboard,用户名密码为admin/123456

      https://10.40.64.191:8443
      
      • 1
  • 相关阅读:
    Flutter组件--OverflowBox、SizedOverflowBox(子组件超出父组件裁剪)
    linux命令:netstat ---net-tools安装
    峰会回顾 | 阿里云与StarRocks合作、开放、共赢
    SD卡格式化如何恢复数据?
    vue3 + ElementPlus 封装函数式弹窗组件
    怎么使用Git远程删除某个历史提交记录
    最长上升子序列 + 优化(线段树、树状数组)
    simple_php (攻防世界)
    python+vue+elementui旅游信息管理系统pycharm源码
    代理的匿名级别有哪些?为什么匿名性很重要?
  • 原文地址:https://blog.csdn.net/gengduc/article/details/132764178