ceph 17版本:使用cephadm部署单节点集群

ceph 17版本:使用cephadm部署17.2版本的单节点集群


前言

ceph17.2.0版本的单节点集群部署记录


一、环境版本信息

  • cephadm版本:17.2.0-0ubuntu0.22.04.2
  • ceph版本:17.2.0
  • 操作系统版本:Ubuntu 22.04.1 LTS
  • 网络:192.168.150.0/24
  • ip:192.168.150.37

二、基础环境部署

1.服务器准备

准备了一台虚拟机,挂载了3块20GB的盘作为osd介质

sda                         8:0    0   20G  0 disk 
├─sda1                      8:1    0    1M  0 part 
├─sda2                      8:2    0  1.8G  0 part /boot
└─sda3                      8:3    0 18.2G  0 part 
  └─ubuntu--vg-ubuntu--lv 253:0    0   10G  0 lvm  /
sdb                         8:16   0   20G  0 disk 
sdc                         8:32   0   20G  0 disk 
sdd                         8:48   0   20G  0 disk

2.配置DNS

cat >> /etc/systemd/resolved.conf << EOF
DNS=8.8.8.8 114.114.114.114
EOF
systemctl restart systemd-resolved.service

3.安装时间服务

sudo apt install -y chrony && sudo systemctl enable --now chronyd

4.关闭防火墙

systemctl stop ufw
systemctl disable ufw

5.安装docker服务

sudo apt-get purge docker-ce docker-ce-cli containerd.io
sudo rm -rf /var/lib/docker
sudo apt-get update
sudo apt install curl -y
sudo apt-get -y install apt-transport-https ca-certificates curl gnupg-agent software-properties-common
curl -fsSL http://mirrors.aliyun.com/docker-ce/linux/ubuntu/gpg | sudo apt-key add -
sudo add-apt-repository "deb [arch=amd64] http://mirrors.aliyun.com/docker-ce/linux/ubuntu $(lsb_release -cs) stable"
sudo apt-get -y update
sudo apt-get -y install docker-ce docker-ce-cli containerd.io
systemctl status docker

5.安装lvm服务

apt install lvm2 -y

二、ceph部署

1.安装cephadm

#安装
sudo apt install -y cephadm
#安装结果
cephadm is already the newest version (17.2.0-0ubuntu0.22.04.2)

2.执行bootstrap

cephadm bootstrap --mon-ip 192.168.150.37 --cluster-network 192.168.150.0/24 --single-host-defaults

3.安装客户端软件

#安装客户端软件
apt install ceph-common
#设置mon数量
ceph orch apply mon 1
#设置mgr数量
ceph orch apply mgr 1
#查看集群状态
ceph orch ls
#输出
NAME           PORTS        RUNNING  REFRESHED  AGE  PLACEMENT  
alertmanager   ?:9093,9094      1/1  9m ago     34m  count:1    
crash                           1/1  9m ago     34m  *          
grafana        ?:3000           1/1  9m ago     34m  count:1    
mgr                             2/1  9m ago     3s   count:1    
mon                             1/1  9m ago     4s   count:1    
node-exporter  ?:9100           1/1  9m ago     34m  *          
prometheus     ?:9095           1/1  9m ago     34m  count:1

3.增加osd

#部署osd
ceph orch apply osd --all-available-devices
#查看部署结果
ceph osd status
#输出
ID  HOST     USED  AVAIL  WR OPS  WR DATA  RD OPS  RD DATA  STATE      
 0  ceph01  22.5M  19.9G      0        0       0        0   exists,up  
 1  ceph01  22.5M  19.9G      0        0       0        0   exists,up  
 2  ceph01  19.4M  19.9G      0        0       0        0   exists,up

4.创建存储池

ceph osd pool create test 64 64
ceph osd pool ls 
#输出
.mgr
test

5.查看集群状态

ceph -s

ceph -s
  cluster:
    id:     672a7e5a-9642-11ed-b356-c34fd8a37286
    health: HEALTH_OK
 
  services:
    mon: 1 daemons, quorum ceph01 (age 38m)
    mgr: ceph01.nokwhs(active, since 34m)
    osd: 3 osds: 3 up (since 119s), 3 in (since 2m)
 
  data:
    pools:   2 pools, 65 pgs
    objects: 2 objects, 577 KiB
    usage:   64 MiB used, 60 GiB / 60 GiB avail
    pgs:     65 active+clean

三、移除方式

当部署异常的时候,可以使用下面的命令删除掉集群信息重新部署

ceph orch pause
ceph fsid
cephadm rm-cluster --force --zap-osds --fsid <fsid>

总结

简单整理了一下,供以后部署时参考

### 使用 cephadm-ansible 部署 Ceph 集群的指南 使用 `cephadm-ansible` 可以简化 Ceph 集群部署过程,通过 Ansible Playbook 的方式实现自动化配置和管理。以下是关于如何使用 `cephadm-ansible` 部署 Ceph 集群的详细说明: #### 1. 环境准备 在开始之前,需要确保所有节点满足以下条件: - 所有节点已正确配置 SSH 密钥对,以便无密码登录。 - 安装并配置好 Ansible 和 Python 环境。 - 节点之间网络互通,DNS 或 `/etc/hosts` 文件中包含所有节点的主机名映射。 #### 2. 下载 cephadm-ansible 项目 从官方仓库克隆 `cephadm-ansible` 项目到本地环境: ```bash git clone https://gitcode.com/gh_mirrors/ce/cephadm-ansible cd cephadm-ansible ``` [^2] #### 3. 配置 Ansible Inventory 创建或编辑 `inventory` 文件,定义集群中的节点角色。例如: ```ini [mons] node1 node2 node3 [osds] node1 node2 node3 [mgrs] node1 ``` 每个组对应不同的 Ceph 组件,如监控节点(mons)、存储节点(osds)和管理节点(mgrs)[^3]。 #### 4. 运行 Preflight 剧本 在执行实际部署之前,运行 `preflight.yml` 剧本来检查环境是否符合要求: ```bash ansible-playbook -i inventory preflight.yml ``` 如果发现任何问题,请根据输出信息进行修正[^1]。 #### 5. 部署 Ceph 集群 使用 `site.yml` 剧本完成集群的初始化和部署: ```bash ansible-playbook -i inventory site.yml ``` 此剧本会自动安装 Ceph 并配置所有必要的组件[^1]。 #### 6. 配置客户端访问 为了允许其他客户端访问 Ceph 集群,可以运行 `cephadm-clients.yml` 剧本: ```bash ansible-playbook -i inventory cephadm-clients.yml ``` 这将生成客户端所需的密钥文件,并将其分发到指定的客户端节点[^1]。 #### 7. 监控与维护 - 定期更新 `cephadm-ansible` 和 Ceph 版本以获得最新的功能和安全补丁[^1]。 - 使用 Ceph 提供的监控工具(如 Ceph Dashboard)来实时查看集群状态[^1]。 - 备份 Ansible 的 inventory 文件和 Ceph 配置文件以防止数据丢失[^1]。 #### 示例代码 以下是一个简单的 Ansible 剧本片段,用于验证集群健康状态: ```yaml - name: Check Ceph cluster health hosts: mgrs tasks: - name: Run 'ceph -s' command shell: ceph -s register: ceph_status - name: Display Ceph status debug: msg: "{{ ceph_status.stdout }}" ``` ### 注意事项 - 如果需要移除整个集群,可以运行 `cephadm-purge-cluster.yml` 剧本,但需谨慎操作,因为这将删除所有数据。 - 在部署过程中遇到问题时,可以通过调整 `group_vars` 和 `host_vars` 中的参数来适应特定需求[^3]。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值