• 基于LVM和NFS的cinder多后端


    1. 环境

    云平台:兼容OpenStack Queens的发行版(kolla)
    HOST OS:Kylin-Server-10-SP1-Release-Build20-20210518-arm64


    2. LVM后端

    2.1 创建LVM

    有以下两种方式提供LVM磁盘

    2.1.1 实际物理磁盘

    假如设备为sdb(本地盘或者san提供的盘)

    pvcreate /dev/sdb
    vgcreate cinder-volumes /dev/sdb
    
    • 1
    • 2

    2.1.2虚拟磁盘

    虚拟磁盘

    dd if=/dev/zero of=/opt/cinder-volumes bs=1 count=0 seek=100G
    losetup /dev/loop1 /opt/cinder-volumes
    pvcreate /dev/loop1
    vgcreate cinder-volumes /dev/loop1
    pvscan
    
    • 1
    • 2
    • 3
    • 4
    • 5

    2.2 cinder volume配置

    设置volume_backend_name,以便关联
    vim /etc/kolla/cinder-volume/cinder.conf

    [DEFAULT]
    enabled_backends = lvm
    [lvm]
    volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
    volume_group = cinder-volumes
    iscsi_protocol = iscsi
    iscsi_helper = tgtadm
    volume_backend_name=LVM
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    重启服务:

    docker restart cinder_volume
    
    • 1

    2.3 关联LVM类型

    cinder type-create lvm
    cinder type-key lvm set volume_backend_name=LVM
    cinder extra-specs-list
    
    • 1
    • 2
    • 3

    2.4 创建指定类型的卷

    cinder create 1 --volume-type lvm
    
    • 1

    通过命令查看cinder list

    +--------------------------------------+-----------+------+------+-------------+----------+-------------+
    | ID                                   | Status    | Name | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+------+------+-------------+----------+-------------+
    | 658f4257-295e-4518-a35b-400b602efef8 | available | -    | 1    | lvm         | false    |             |
    +--------------------------------------+-----------+------+------+-------------+----------+-------------+
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6

    3. NFS后端

    3.1 NFS服务端

    存在以下两种方式提供NFS后端

    3.1.1 NAS存储

    略,依据NAS存储手册,提供的存储地址和共享路径

    3.1.2 自建NFS SERVER

    安装nfs服务包,配置共享目录
    vim /etc/exports

    /nfs_share  x.x.x.x/x(rw,no_subtree_check,no_root_squash)
    
    • 1

    注:x.x.x.x/x代表可以提供nfs共享服务的网段

    exportfs -r重新加载配置,exportfs显示共享信息

    3.2 cinder volume配置

    可以添加多个共享存储
    vim /etc/kolla/cinder-volume/nfs_shares

    x.x.x.x:/nfs_share
    
    • 1

    注:x.x.x.x代表nfs server或者nas地址,nfs_share代表共享目录

    vim /etc/kolla/cinder-volume/config.json

    ......
            {
                "source": "/var/lib/kolla/config_files/nfs_shares",
                "dest": "/etc/cinder/nfs_shares",
                "owner": "cinder",
                "perm": "0600",
                "optional": true
            },
    ......
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9

    设置volume_backend_name,以便关联
    vim /etc/kolla/cinder-volume/cinder.conf

    [DEFAULT]
    enabled_backends = lvm,nfs
    [nfs]
    volume_backend_name=nfs
    nfs_mount_attempts = 3
    nfs_oversub_ratio = 1.0
    volume_driver=cinder.volume.drivers.nfs.NfsDriver
    nfs_shares_config=/etc/cinder/nfs_shares
    nfs_mount_point_base=$state_path/mnt
    nfs_sparsed_volumes = false
    nfs_used_ratio = 0.95
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11

    重启服务

    docker restart cinder_volume
    
    • 1

    3.3 关联LVM类型

    cinder type-create nfs
    cinder type-key nfs set volume_backend_name=nfs
    cinder extra-specs-list
    
    • 1
    • 2
    • 3

    3.4 创建指定类型的卷

    cinder create 1 --volume-type nfs
    
    • 1

    通过命令查看cinder list

    +--------------------------------------+-----------+------+------+-------------+----------+-------------+
    | ID                                   | Status    | Name | Size | Volume Type | Bootable | Attached to |
    +--------------------------------------+-----------+------+------+-------------+----------+-------------+
    | 03efe4b3-334e-44dc-804d-a3ad0201e385 | available | -    | 1    | nfs         | false    |             |
    | 658f4257-295e-4518-a35b-400b602efef8 | available | -    | 1    | lvm         | false    |             |
    +--------------------------------------+-----------+------+------+-------------+----------+-------------+
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7

    4. 问题记录


    5. 参考文献

  • 相关阅读:
    Chapter 6 Shell Logic and Arithmetic
    团建游戏---赢得用户
    科普:什么是视频监控平台?如何应用在场景中?
    Vue3语法糖setup(二)
    字符串函数以及内存函数的模拟实现(超详细,全面理解字符串函数!!!)
    02.爱芳地产项目小程序全栈项目经验(已上线)
    Ubuntu写python脚本实现自定义壁纸幻灯片:字符串拼接法、minidom法
    CVPR2023新作:源数据集对迁移学习性能的影响以及相应的解决方案
    技术博客一件发布系统的实验性技术方案Butterfly
    Taro 封装遮罩层
  • 原文地址:https://blog.csdn.net/nanhai_happy/article/details/125536704