Ceph搭建

简介: ceph

Ceph搭建

一、系统环境初始化

时间同步

关闭selinux和防火墙(Centos)

配置主机域名解析或通过DNS解析

所有节点安装podman

apt install -y podman lvm2
主机名 ip
ceph1 192.168.11.10 \ 192.168.75.10
ceph2 192.168.11.11 \ 192.168.75.11
ceph3 192.168.11.12 \ 192.168.75.12
root@ceph3:~# cat /etc/hosts
127.0.0.1 localhost

# The following lines are desirable for IPv6 capable hosts
::1     ip6-localhost ip6-loopback
fe00::0 ip6-localnet
ff00::0 ip6-mcastprefix
ff02::1 ip6-allnodes
ff02::2 ip6-allrouters
192.168.11.10 ceph1
192.168.11.11 ceph2
192.168.11.12 ceph3

配置时间同步 使用自带的timedate

timedatectl set-timezone Asia/Shanghai

二、部署RADOS集群

https://mirrors.aliyun.com/ceph/
https://mirrors.163.com/ceph/
https://mirrors.tuna.tsinghua.edu.cn/ceph/

2.1仓库准备

各节点配置ceph 仓库

aliyun默认带了ceph

root@ceph3:~# apt-cache madison ceph
      ceph | 19.2.3-0ubuntu0.24.04.3 | http://mirrors.aliyun.com/ubuntu noble-updates/main amd64 Packages
      ceph | 19.2.3-0ubuntu0.24.04.3 | http://mirrors.aliyun.com/ubuntu noble-security/main amd64 Packages
      ceph | 19.2.0~git20240301.4c76c50-0ubuntu6 | http://mirrors.aliyun.com/ubuntu noble/main amd64 Packages
root@ceph3:~#

2. 2安装 Cephadm(仅在主节点 ceph1)

apt update
apt install -y podman lvm2
apt install -y cephadm

初始化主节点

root@ceph1:~# cephadm bootstrap --mon-ip 192.168.11.10
Creating directory /etc/ceph for ceph.conf
Verifying podman|docker is present...
Verifying lvm2 is present...
Verifying time synchronization is in place...
Unit systemd-timesyncd.service is enabled and running
Repeating the final host check...
podman (/usr/bin/podman) version 4.9.3 is present
systemctl is present
lvcreate is present
Unit systemd-timesyncd.service is enabled and running
Host looks OK
Cluster fsid: 24f2c24c-75e6-11f1-b8f1-000c291acd7f
Verifying IP 192.168.11.10 port 3300 ...
Verifying IP 192.168.11.10 port 6789 ...
Mon IP `192.168.11.10` is in CIDR network `192.168.11.0/24`
Mon IP `192.168.11.10` is in CIDR network `192.168.11.0/24`
Internal network (--cluster-network) has not been provided, OSD replication will default to the public_network
Pulling container image quay.io/ceph/ceph:v19...
Ceph version: ceph version 19.2.4 (7cc0193a616a3333d22b7762037fa5b73a4d06a6) squid (stable)
Extracting ceph user uid/gid from container image...
Creating initial keys...
Creating initial monmap...
Creating mon...
Waiting for mon to start...
Waiting for mon...
mon is available
Assimilating anything we can from ceph.conf...
Generating new minimal ceph.conf...
Restarting the monitor...
Setting public_network to 192.168.11.0/24 in mon config section
Wrote config to /etc/ceph/ceph.conf
Wrote keyring to /etc/ceph/ceph.client.admin.keyring
Creating mgr...
Verifying port 0.0.0.0:9283 ...
Verifying port 0.0.0.0:8765 ...
Verifying port 0.0.0.0:8443 ...
Waiting for mgr to start...
Waiting for mgr...
mgr not available, waiting (1/15)...
mgr not available, waiting (2/15)...
mgr not available, waiting (3/15)...
mgr is available
Enabling cephadm module...
Waiting for the mgr to restart...
Waiting for mgr epoch 5...
mgr epoch 5 is available
Setting orchestrator backend to cephadm...
Generating ssh key...
Wrote public SSH key to /etc/ceph/ceph.pub
Adding key to root@localhost authorized_keys...
Adding host ceph1...
Deploying mon service with default placement...
Deploying mgr service with default placement...
Deploying crash service with default placement...
Deploying ceph-exporter service with default placement...
Deploying prometheus service with default placement...
Deploying grafana service with default placement...
Deploying node-exporter service with default placement...
Deploying alertmanager service with default placement...
Enabling the dashboard module...
Waiting for the mgr to restart...
Waiting for mgr epoch 9...
mgr epoch 9 is available
Generating a dashboard self-signed certificate...
Creating initial admin user...
Fetching dashboard port number...
Ceph Dashboard is now available at:

             URL: https://ceph1:8443/
            User: admin
        Password: 5vcur62785

Enabling client.admin keyring and conf on hosts with "admin" label
Saving cluster configuration to /var/lib/ceph/24f2c24c-75e6-11f1-b8f1-000c291acd7f/config directory
You can access the Ceph CLI as following in case of multi-cluster or non-default config:

        sudo /usr/sbin/cephadm shell --fsid 24f2c24c-75e6-11f1-b8f1-000c291acd7f -c /etc/ceph/ceph.conf -k /etc/ceph/ceph.client.admin.keyring

Or, if you are only running a single cluster on this host:

        sudo /usr/sbin/cephadm shell

Please consider enabling telemetry to help improve Ceph:

        ceph telemetry on

For more information see:

        https://docs.ceph.com/en/latest/mgr/telemetry/

Bootstrap complete.

此命令将

  • 在本地主机上为新集群创建一个 Monitor 和一个 Manager 守护程序。
  • 为 Ceph 集群生成一个新的 SSH 密钥,并将其添加到 root 用户的 /root/.ssh/authorized_keys 文件中。
  • 将公钥副本写入 /etc/ceph/ceph.pub。
  • 将最小配置文件写入 /etc/ceph/ceph.conf。此文件是与 Ceph 守护程序通信所必需的。
  • 将 client.admin 管理(特权!)密钥副本写入 /etc/ceph/ceph.client.admin.keyring。
  • 将 _admin 标签添加到引导主机。默认情况下,任何具有此标签的主机都将(也)获得 /etc/ceph/ceph.conf 和 /etc/ceph/ceph.client.admin.keyring 的副本。

免密失败了 /etc/ceph/ceph.pub

ssh-keygen

重新初始化

root@ceph1:~# cephadm bootstrap \
  --mon-ip 192.168.11.10 \
  --ssh-private-key /root/.ssh/id_ed25519 \
  --ssh-public-key /root/.ssh/id_ed25519.pub \
  --allow-overwrite
Verifying podman|docker is present...
Verifying lvm2 is present...
Verifying time synchronization is in place...
Unit systemd-timesyncd.service is enabled and running
Repeating the final host check...
podman (/usr/bin/podman) version 4.9.3 is present
systemctl is present
lvcreate is present
Unit systemd-timesyncd.service is enabled and running
Host looks OK
Cluster fsid: 10b97a6a-75ef-11f1-8612-000c291acd7f
Verifying IP 192.168.11.10 port 3300 ...
Verifying IP 192.168.11.10 port 6789 ...
Mon IP `192.168.11.10` is in CIDR network `192.168.11.0/24`
Mon IP `192.168.11.10` is in CIDR network `192.168.11.0/24`
Internal network (--cluster-network) has not been provided, OSD replication will default to the public_network
Pulling container image quay.io/ceph/ceph:v19...
Ceph version: ceph version 19.2.4 (7cc0193a616a3333d22b7762037fa5b73a4d06a6) squid (stable)
Extracting ceph user uid/gid from container image...
Creating initial keys...
Creating initial monmap...
Creating mon...
Waiting for mon to start...
Waiting for mon...
mon is available
Assimilating anything we can from ceph.conf...
Generating new minimal ceph.conf...
Restarting the monitor...
Setting public_network to 192.168.11.0/24 in mon config section
Wrote config to /etc/ceph/ceph.conf
Wrote keyring to /etc/ceph/ceph.client.admin.keyring
Creating mgr...
Verifying port 0.0.0.0:9283 ...
Verifying port 0.0.0.0:8765 ...
Verifying port 0.0.0.0:8443 ...
Waiting for mgr to start...
Waiting for mgr...
mgr not available, waiting (1/15)...
mgr not available, waiting (2/15)...
mgr not available, waiting (3/15)...
mgr is available
Enabling cephadm module...
Waiting for the mgr to restart...
Waiting for mgr epoch 5...
mgr epoch 5 is available
Setting orchestrator backend to cephadm...
Using provided ssh keys...
Adding key to root@localhost authorized_keys...
Adding host ceph1...
Deploying mon service with default placement...
Deploying mgr service with default placement...
Deploying crash service with default placement...
Deploying ceph-exporter service with default placement...
Deploying prometheus service with default placement...
Deploying grafana service with default placement...
Deploying node-exporter service with default placement...
Deploying alertmanager service with default placement...
Enabling the dashboard module...
Waiting for the mgr to restart...
Waiting for mgr epoch 9...
mgr epoch 9 is available
Generating a dashboard self-signed certificate...
Creating initial admin user...
Fetching dashboard port number...
Ceph Dashboard is now available at:

             URL: https://ceph1:8443/
            User: admin
        Password: tvhp9krki9

Enabling client.admin keyring and conf on hosts with "admin" label
Saving cluster configuration to /var/lib/ceph/10b97a6a-75ef-11f1-8612-000c291acd7f/config directory
You can access the Ceph CLI as following in case of multi-cluster or non-default config:

        sudo /usr/sbin/cephadm shell --fsid 10b97a6a-75ef-11f1-8612-000c291acd7f -c /etc/ceph/ceph.conf -k /etc/ceph/ceph.client.admin.keyring

Or, if you are only running a single cluster on this host:

        sudo /usr/sbin/cephadm shell

Please consider enabling telemetry to help improve Ceph:

        ceph telemetry on

For more information see:

        https://docs.ceph.com/en/latest/mgr/telemetry/

Bootstrap complete.

2.3 安装 Ceph 命令行工具

为了方便直接在终端输入 ceph 命令,在 ceph1 上安装客户端:

root@ceph1:~# apt install -y ceph-common

三、编排三节点集群

3.1 允许主节点免密登录其他节点

Cephadm 需要通过 SSH 管理 ceph2 和 ceph3。

3.2 将主机加入集群

在 node1 上执行命令,把其他两个 Ubuntu 节点拉进集群:

Bash

root@ceph1:~# ceph orch host add ceph2 192.168.11.11
Added host 'ceph2' with addr '192.168.11.11'
root@ceph1:~# ceph orch host add ceph3 192.168.11.12
Added host 'ceph3' with addr '192.168.11.12'

验证节点状态:ceph orch host ls

root@ceph1:~# ceph orch host ls
HOST   ADDR           LABELS  STATUS
ceph1  192.168.11.10  _admin
ceph2  192.168.11.11
ceph3  192.168.11.12
3 hosts in cluster

4. 部署高可用组件(Mon & Mgr)

为了让 3 个节点对等且具备高可用性,将 Monitor 和 Manager 拓扑应用到所有节点:

# 让 3 个节点都运行 mon
root@ceph1:~# ceph orch apply mon --placement="3 ceph1 ceph2 ceph3"
Scheduled mon update...

# 让 3 个节点都运行 mgr
root@ceph1:~# ceph orch apply mgr --placement="3 ceph1 ceph2 ceph3"
Scheduled mgr update...

5. 添加 OSD(存储裸盘)

确保你准备用于存储数据的硬盘没有分区表,没有被挂载过。

5.1 检查可用硬盘

root@ceph1:~# ceph orch device ls
HOST   PATH      TYPE  DEVICE ID                                             SIZE  AVAILABLE  REFRESHED  REJECT REASONS
ceph1  /dev/sdb  hdd                                                        40.0G  Yes        15m ago
ceph1  /dev/sr0  hdd   VMware_Virtual_SATA_CDRW_Drive_01000000000000000001  1023M  No         15m ago    Failed to determine if device is BlueStore, Insufficient space (<5GB)
ceph2  /dev/sdb  hdd                                                        40.0G  Yes        4m ago
ceph2  /dev/sr0  hdd   VMware_Virtual_SATA_CDRW_Drive_01000000000000000001  1023M  No         4m ago     Failed to determine if device is BlueStore, Insufficient space (<5GB)
ceph3  /dev/sdb  hdd                                                        40.0G  Yes        5s ago
ceph3  /dev/sr0  hdd   VMware_Virtual_SATA_CDRW_Drive_01000000000000000001  1023M  No         5s ago     Failed to determine if device is BlueStore, Insufficient space (<5GB)
root@ceph1:~#

如果看到各节点的硬盘(如 /dev/sdb)状态为 Available: Insufficient space (0B) 或 False,说明盘不干净,需要用 wipefs -a /dev/sdb 清理。

5.2 自动挂载所有可用裸盘

ceph orch apply osd --all-available-devices

6. 完工检查

在 node1 上输入:

root@ceph1:~# ceph -s
  cluster:
    id:     10b97a6a-75ef-11f1-8612-000c291acd7f
    health: HEALTH_OK

  services:
    mon: 3 daemons, quorum ceph1,ceph3,ceph2 (age 7m)
    mgr: ceph1.uwzqip(active, since 25m), standbys: ceph3.ftoasw, ceph2.wevbmh
    osd: 3 osds: 3 up (since 5m), 3 in (since 5m)

  data:
    pools:   1 pools, 1 pgs
    objects: 2 objects, 449 KiB
    usage:   81 MiB used, 120 GiB / 120 GiB avail
    pgs:     1 active+clean

只要看到 health: HEALTH_OK,且 mon 和 mgr 的数量都显示为 3,三节点 Ceph 集群就已经搭建成功了!

image-20260702165445177

相关文章
|
5月前
|
弹性计算 Ubuntu Linux
阿里云Linux云服务器搭建Apache:从零开始的完整部署与优化指南
本文提供了一份完整的阿里云Linux云服务器搭建Apache Web服务器的技术指南。首先介绍ECS实例的选购与初始化,重点讲解安全组规则配置,开放22、80、443等必要端口。然后详细演示通过SSH连接服务器,使用yum/dnf包管理器安装Apache及常用模块,并通过systemctl管理服务。接着深入讲解Apache核心配置文件httpd.conf的关键参数,包括ServerName、DocumentRoot、DirectoryIndex等,并详细演示基于域名的虚拟主机配置方法。在性能优化方面,系统讲解KeepAlive长连接调优、MPM多处理模块的选择与参数设置(prefork与eve
|
5月前
|
Kubernetes 并行计算 算法框架/工具
|
5月前
|
存储 Kubernetes 调度
|
5月前
|
存储 Prometheus Kubernetes
Kubeasz 部署 K8s 生产方案
Kubeasz 部署 K8s 生产方案
|
5月前
|
存储 关系型数据库 API
|
12月前
|
Ubuntu 芯片 Windows
掌握timedatectl命令:Ubuntu 系统时间管理指南
掌握timedatectl命令:Ubuntu 系统时间管理指南
2635 121
|
5月前
|
存储 文字识别 安全
2026阿里云最新云产品活动信息汇总:优惠券、特价、扶持政策一览
本文汇总了2026年阿里云全品类最新优惠活动,覆盖新用户专属折扣券、学生300元无门槛券、中小企业最高百万扶持金等福利,同时整理了云安全、云通信、无影云桌面、云原生、数据库、OCR识别等十余条细分产品线的特惠专场,从建站、AI开发到企业数字化转型的各类上云需求都能找到适配的高性价比方案,还补充了优惠券使用规则的常见问题解答,帮助不同类型的用户精准匹配优惠权益,最大化降低上云成本。
|
5月前
|
数据采集 存储 人工智能
DCMM 2.0 九大能力域技术架构深度解析:数据中台作为贯标评估核心基础设施的实现路径
本文解析DCMM 2.0(GB/T 36073-2025)新标准,聚焦新增“数据资产”能力域,从技术架构视角系统梳理九大能力域与数据中台的映射关系,提出“理采存管用”五阶段落地路径,助力企业实现数据资产化闭环管理。
|
6月前
|
Kubernetes Ubuntu 网络协议
|
5月前
|
人工智能 自然语言处理 开发工具
最新版通义千问(Qwen3.8-Max-Preview)功能介绍
通义千问Qwen3.8-Max-Preview是通义千问团队推出的旗舰级预览版大模型,以2.4万亿参数的MoE混合专家架构为核心,实现了原生多模态融合、超长上下文处理、全栈代码工程、多智能体协同等能力的跨越式升级,成为面向复杂生产场景的全域生产力模型。该模型不仅在参数规模上实现突破,更通过架构优化、能力重构,解决了传统大模型在长文本处理、复杂推理、工程落地中的诸多痛点,为开发者、企业用户提供了更强大、更高效、更灵活的AI能力支撑。
12973 4