news 2026/5/26 11:32:27

Kolla-Ansible部署的OpenStack Train版,如何一步步对接外部Ceph集群(保姆级避坑指南)

作者头像

张小明

前端开发工程师

1.2k 24
文章封面图
Kolla-Ansible部署的OpenStack Train版,如何一步步对接外部Ceph集群(保姆级避坑指南)

Kolla-Ansible部署的OpenStack Train版对接外部Ceph集群实战指南

在云原生架构中,存储系统的稳定性和性能直接影响整个平台的用户体验。当使用Kolla-Ansible部署OpenStack Train版本时,与独立部署的Ceph集群对接是许多企业级用户的首选方案。这种架构分离不仅提升了存储系统的可维护性,还能充分利用现有Ceph集群的资源优势。

1. 环境规划与前置条件

对接外部Ceph集群前,需要确保双方环境满足基本通信要求。网络层面建议配置10Gbps及以上带宽,并确保OpenStack控制节点与Ceph集群各节点间的网络延迟低于2ms。以下是基础环境检查清单:

  • 版本兼容性矩阵

    组件最低版本要求推荐版本
    CephLuminousNautilus
    OpenStackSteinTrain
    librbd12.2.014.2.0
    python-rbd2.0.03.0.0
  • 网络连通性测试

    # 从OpenStack节点测试Ceph MON节点连通性 for node in ceph-mon1 ceph-mon2 ceph-mon3; do ping -c 4 $node && nc -zv $node 6789 done
  • 系统依赖检查

    # 在所有OpenStack节点执行 rpm -q ceph-common python-rbd || yum install -y ceph-common python-rbd

特别需要注意SELinux和防火墙配置。如果使用Firewalld,需要永久开放6789(Ceph MON)和6800-7300(Ceph OSD)端口范围:

firewall-cmd --permanent --add-port=6789/tcp firewall-cmd --permanent --add-port=6800-7300/tcp firewall-cmd --reload

2. Ceph集群端配置详解

在已有Ceph集群上,需要为OpenStack服务创建专用的存储池和认证用户。建议根据业务规模合理设置PG数量,通常每个存储池的PG数可按以下公式计算:

PG总数 = (OSD数量 × 100) / 副本数
例如:3节点集群(每个节点5个OSD),3副本配置
PG总数 = (15 × 100) / 3 = 500 → 512(取最近的2的幂次)

2.1 存储池创建与初始化

# 创建基础存储池(建议PG_NUM为64的倍数) ceph osd pool create volumes 512 512 ceph osd pool create images 128 128 ceph osd pool create vms 512 512 ceph osd pool create backups 128 128 # 初始化RBD特性 for pool in volumes images vms backups; do rbd pool init $pool ceph osd pool application enable $pool rbd done

2.2 细粒度权限配置

OpenStack各组件需要独立的Ceph用户,权限应遵循最小化原则:

# Glance用户(仅需images池权限) ceph auth get-or-create client.glance \ mon 'profile rbd' \ osd 'profile rbd pool=images' \ mgr 'profile rbd pool=images' \ -o /etc/ceph/ceph.client.glance.keyring # Cinder用户(需要volumes和vms池权限) ceph auth get-or-create client.cinder \ mon 'profile rbd' \ osd 'profile rbd pool=volumes, profile rbd pool=vms, profile rbd-read-only pool=images' \ mgr 'profile rbd pool=volumes, profile rbd pool=vms' \ -o /etc/ceph/ceph.client.cinder.keyring # Nova用户(需要vms池权限) ceph auth get-or-create client.nova \ mon 'profile rbd' \ osd 'profile rbd pool=vms, profile rbd-read-only pool=images' \ mgr 'profile rbd pool=vms' \ -o /etc/ceph/ceph.client.nova.keyring

密钥文件权限必须严格限制:

chmod 600 /etc/ceph/ceph.client.*.keyring

3. Kolla-Ansible配置深度优化

3.1 关键目录结构规划

在部署节点创建符合Kolla规范的配置目录:

mkdir -p /etc/kolla/config/{glance,cinder/{cinder-volume,cinder-backup},nova}

目录最终结构应如下:

/etc/kolla/config/ ├── cinder │ ├── ceph.conf │ ├── cinder-backup │ │ ├── ceph.client.cinder-backup.keyring │ │ └── ceph.client.cinder.keyring │ ├── cinder-backup.conf │ ├── cinder-volume │ │ └── ceph.client.cinder.keyring │ └── cinder-volume.conf ├── glance │ ├── ceph.client.glance.keyring │ ├── ceph.conf │ └── glance-api.conf └── nova ├── ceph.client.cinder.keyring ├── ceph.client.nova.keyring ├── ceph.conf └── nova-compute.conf

3.2 服务配置文件详解

Glance配置示例:
# /etc/kolla/config/glance/glance-api.conf [glance_store] stores = rbd default_store = rbd rbd_store_pool = images rbd_store_user = glance rbd_store_ceph_conf = /etc/ceph/ceph.conf rbd_store_chunk_size = 8
Cinder Volume核心参数:
# /etc/kolla/config/cinder/cinder-volume.conf [DEFAULT] enabled_backends=rbd-1 [rbd-1] rbd_ceph_conf=/etc/ceph/ceph.conf rbd_user=cinder backend_host=rbd:volumes rbd_pool=volumes volume_backend_name=rbd-1 volume_driver=cinder.volume.drivers.rbd.RBDDriver rbd_secret_uuid = {{ cinder_rbd_secret_uuid }} rbd_flatten_volume_from_snapshot = false rbd_max_clone_depth = 5

注意:rbd_secret_uuid需从/etc/kolla/passwords.yml中获取,实际部署时Kolla会自动替换变量

Nova计算节点关键配置:
# /etc/kolla/config/nova/nova-compute.conf [libvirt] images_type = rbd images_rbd_pool = vms images_rbd_ceph_conf = /etc/ceph/ceph.conf rbd_user = nova rbd_secret_uuid = {{ rbd_secret_uuid }} disk_cachemodes = "network=writeback" hw_disk_discard = unmap

4. 全局参数与部署验证

4.1 globals.yml关键配置

# /etc/kolla/globals.yml enable_ceph: "no" # 禁用Kolla内置Ceph部署 glance_backend_ceph: "yes" cinder_backend_ceph: "yes" nova_backend_ceph: "yes" # Ceph客户端配置 ceph_conf_overrides: global: osd_pool_default_size: 3 osd_pool_default_min_size: 2 rbd_cache: "true" rbd_cache_writethrough_until_flush: "true"

4.2 安全增强配置

/etc/kolla/config/ceph.conf中添加优化参数:

[global] fsid = {{ ceph_fsid }} mon host = 192.168.1.10,192.168.1.11,192.168.1.12 [client] rbd cache = true rbd cache writethrough until flush = true rbd cache size = 64MB rbd cache max dirty = 32MB rbd cache target dirty = 16MB

4.3 部署与验证流程

  1. 执行配置生成:

    kolla-ansible -i all-in-one reconfigure
  2. 验证服务状态:

    openstack volume service list openstack network agent list
  3. 功能测试案例:

    # 镜像上传测试 openstack image create --disk-format qcow2 --container-format bare \ --file cirros-0.5.2-x86_64-disk.img --public cirros-test # 卷创建测试 openstack volume create --size 1 test-volume openstack server add volume test-instance test-volume

5. 高级调优与故障排查

5.1 性能优化参数

在Ceph集群端的/etc/ceph/ceph.conf添加:

[osd] osd_op_threads = 8 osd_disk_threads = 4 osd_map_cache_size = 1024 osd_map_cache_bl_size = 128 osd_mount_options_xfs = "rw,noatime,inode64,logbsize=256k,delaylog"

5.2 常见问题解决方案

问题1:卷创建失败,日志显示权限拒绝

  • 检查项:
    # 确认密钥文件存在且权限正确 ls -l /etc/kolla/config/cinder/cinder-volume/ceph.client.cinder.keyring # 验证Cinder用户权限 ceph auth get client.cinder

问题2:虚拟机启动超时

  • 排查步骤:
    # 检查Nova日志 docker logs nova_compute # 验证libvirt连接 docker exec -it nova_libvirt virsh list --all # 检查rbd secret是否正确定义 docker exec -it nova_libvirt virsh secret-list

问题3:镜像上传缓慢

  • 优化建议:
    # 在glance-api.conf中增加 [glance_store] rbd_store_chunk_size = 8 show_image_direct_url = True

实际部署中遇到最多的问题是密钥文件权限和路径配置错误。建议在每次修改配置后,使用docker exec进入容器验证配置文件是否被正确加载:

docker exec -it glance_api cat /etc/glance/glance-api.conf
版权声明: 本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若内容造成侵权/违法违规/事实不符,请联系邮箱:809451989@qq.com进行投诉反馈,一经查实,立即删除!
网站建设 2026/5/26 11:32:10

Unity Wheel Collider物理原理与车辆控制系统实战指南

1. 为什么Unity的Wheel Collider不是“轮子”,而是一个需要重新理解的物理抽象层 在Unity中做车辆模拟,绝大多数人第一次拖一个 Wheel Collider 组件到车轮GameObject上时,都会下意识地认为:“这不就是个带物理响应的轮胎嘛&…

作者头像 李华
网站建设 2026/5/26 11:31:57

Unity Hub、文档、Asset Store 三大官方系统底层逻辑解析

1. 这些“官方入口”为什么总被新手绕着走?——不是找不到,是没搞懂它们各自管什么Unity Hub、官方文档、Asset Store,这三个词几乎每个刚接触Unity的人第一天就会撞见。但奇怪的是,我带过的几十个新人里,有超过七成在…

作者头像 李华
网站建设 2026/5/26 11:31:56

NX monorepo中Playwright端到端测试5分钟配置实战

1. 为什么“5分钟配置”不是营销话术,而是可复现的工程现实在NX工作区里配个Playwright端到端测试,真能5分钟跑通?我第一次看到这个标题时也皱了眉——毕竟上一个项目里,光是解决nx/playwright插件与playwright-core版本冲突就花了…

作者头像 李华