注意要 按顺序 搭建服务,在 CentOS 7 安装 Openstack Rocky 版本 - 环境搭建 的基础上安装服务。
Block Storage service - 块存储服务(Cinder)
在 控制节点 和 块存储节点 安装
For simplicity, this configuration references one storage node with an empty local block storage device. The instructions use /dev/sdb, but you can substitute a different value for your particular node.
控制节点
数据库配置
连接数据库
数据库操作
1 2 3 4 5 6 7 8 9 CREATE DATABASE cinder;GRANT ALL PRIVILEGES ON cinder.* TO 'cinder' @'localhost' IDENTIFIED BY 'mariadb-cinder' ;GRANT ALL PRIVILEGES ON cinder.* TO 'cinder' @'%' IDENTIFIED BY 'mariadb-cinder' ;exit
身份认证和 API 配置
创建用户 cinder
并添加到 admin
角色
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 . admin-openrc openstack user create --domain default --password-prompt cinder openstack role add --project service --user cinder admin
创建 cinder
服务实体和端点(endpoint)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2 openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3 openstack endpoint create --region RegionOne volumev2 public http://controller:8776/v2/%\(project_id\)s openstack endpoint create --region RegionOne volumev2 internal http://controller:8776/v2/%\(project_id\)s openstack endpoint create --region RegionOne volumev2 admin http://controller:8776/v2/%\(project_id\)s openstack endpoint create --region RegionOne volumev3 public http://controller:8776/v3/%\(project_id\)s openstack endpoint create --region RegionOne volumev3 internal http://controller:8776/v3/%\(project_id\)s openstack endpoint create --region RegionOne volumev3 admin http://controller:8776/v3/%\(project_id\)s
安装和配置 cinder
安装软件包
1 2 yum install openstack-cinder -y
编辑配置文件 /etc/cinder/cinder.conf
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 [database] connection = mysql+pymysql://cinder:mariadb-cinder@controller/cinder [DEFAULT] transport_url = rabbit://openstack:rabbitmq@controller auth_strategy = keystone my_ip = 10.0.0.11 [keystone_authtoken] www_authenticate_uri = http://controller:5000 auth_url = http://controller:5000 memcached_servers = controller:11211 auth_type = password project_domain_id = default user_domain_id = default project_name = service username = cinder password = cinder [oslo_concurrency] lock_path = /var/lib/cinder/tmp
填充数据库
1 2 su -s /bin/sh -c "cinder-manage db sync" cinder
让计算节点使用块存储,编辑配置文件 /etc/nova/nova.conf
1 2 [cinder] os_region_name = RegionOne
完成安装
1 2 3 4 5 6 systemctl restart openstack-nova-api.service systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
块存储节点
添加 1 块新硬盘
安装并配置 LVM
1 2 3 4 5 6 7 8 9 10 11 12 yum install lvm2 device-mapper-persistent-data -y systemctl enable lvm2-lvmetad.service systemctl start lvm2-lvmetad.service pvcreate /dev/sdb vgcreate cinder-volumes /dev/sdb
编辑配置文件 /etc/lvm/lvm.conf
,添加过滤条件
1 2 devices { filter = [ "a/sda/", "a/sdb/", "r/.*/"]
在 计算节点 上修改配置文件 /etc/lvm/lvm.conf
1 2 devices { filter = [ "a/sda/", "r/.*/"]
安装并配置 cinder
安装软件包
1 2 yum install openstack-cinder targetcli python-keystone -y
编辑配置文件 /etc/cinder/cinder.conf
,没有的选项需要添加到相应的小节,[lvm]
小节直接添加即可
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 [database] connection = mysql+pymysql://cinder:mariadb-cinder@controller/cinder [DEFAULT] transport_url = rabbit://openstack:rabbitmq@controller auth_strategy = keystone my_ip = 10.0.0.41 enabled_backends = lvm glance_api_servers = http://controller:9292 [keystone_authtoken] www_authenticate_uri = http://controller:5000 auth_url = http://controller:5000 memcached_servers = controller:11211 auth_type = password project_domain_id = default user_domain_id = default project_name = service username = cinder password = cinder [lvm] volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver volume_group = cinder-volumes iscsi_protocol = iscsi iscsi_helper = lioadm [oslo_concurrency] lock_path = /var/lib/cinder/tmp
完成安装
1 2 3 systemctl enable openstack-cinder-volume.service target.service systemctl start openstack-cinder-volume.service target.service
备份服务(可选)
For simplicity, this configuration uses the Block Storage node and the Object Storage (swift) driver, thus depending on the Object Storage service.
在 控制节点 查看对象存储服务 API
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 openstack catalog show object-store
在 块存储节点 上执行操作,修改配置文件 /etc/cinder/cinder.conf
backup_swift_url
为 public
端点
1 2 3 [DEFAULT] backup_driver = cinder.backup.drivers.swift backup_swift_url = http://controller:8080/v1/AUTH_eb296de9a0e64b2a9243ad58f0805746
启用备份
1 2 3 systemctl enable openstack-cinder-backup.service systemctl start openstack-cinder-backup.service
验证
在 控制节点 上执行操作
1 2 3 4 5 6 7 8 9 10 11 12 . admin-openrc openstack volume service list