OpenStack部署(七)
作者:互联网
部署版本:pike
部署环境:CentOS7.6
配置文件中所有controller可修改为控制节点ip地址
配置过程中使用 echo $?
验证命令执行情况
Block Storage service
块存储服务Cinder
该服务使用LVM驱动程序在此设备上提供逻辑卷,并通过iSCSI传输将其提供给实例。
安装并配置存储节点
一、先决条件
1.安装需要的软件
安装LVM包:
[root@controller /]# yum install lvm2 device-mapper-persistent-data
启动LVM元数据服务,并将其配置为在系统启动时启动:
[root@controller /]# systemctl enable lvm2-lvmetad.service
[root@controller /]# echo $?
0
[root@controller /]# systemctl start lvm2-lvmetad.service
[root@controller /]# echo $?
0
2.创建LVM物理卷/dev/sdb:
首先添加硬盘磁盘
执行lsblk查看
[root@controller /]# lsblk
刷新总线
[root@controller /]# echo "- - -">/sys/class/scsi_host/host0/scan
[root@controller /]#
[root@controller /]# echo "- - -">/sys/class/scsi_host/host1/scan
[root@controller /]#
[root@controller /]# echo "- - -">/sys/class/scsi_host/host2/scan
[root@controller /]#
再执行lsblk就可以看到新加的盘sdb(如果还是没有就重启机器)
后执行
[root@controller /]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
3.创建cinder-volumes卷LVM(块存储服务在此卷组中创建逻辑卷):
[root@controller /]# vgcreate cinder-volumes /dev/sdb
Volume group "cinder-volumes" successfully created
4.只有实例才能访问块存储卷。但是,底层操作系统管理与卷关联的设备。默认情况下,LVM卷扫描工具会在/dev目录中扫描包含卷的块存储设备。如果项目在其卷上使用LVM,扫描工具会检测这些卷并尝试缓存它们,这可能会导致底层操作系统和项目卷出现各种问题。必须重新配置LVM,以便仅扫描包含cinder volume组的设备。编辑/etc/lvm/lvm.conf文件并完成以下操作:
在device部分,添加一个接受/dev/sdb设备并拒绝所有其他设备的过滤器:
devices {
...
filter = [ "a/sdb/", "r/.*/"]
二、安装和配置组件
1.安装软件
[root@controller /]# yum install openstack-cinder targetcli python-keystone
2.打开/etc/cinder/cinder.conf文件及修改其中内容
[root@controller /]# vim /etc/cinder/cinder.conf
[database]
# ...
connection = mysql+pymysql://cinder:qwer1234@controller/cinder
[DEFAULT]
# ...
transport_url = rabbit://openstack:RABBIT_PASS@controller
[DEFAULT]
# ...
auth_strategy = keystone
[keystone_authtoken]
# ...
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = qwer1234
[DEFAULT]
# ...
my_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
在[lvm]部分,使用lvm驱动程序、cinder volumes卷组、iSCSI协议和适当的iSCSI服务配置lvm后端。如果[lvm]部分不存在,请创建它:
[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
iscsi_protocol = iscsi
iscsi_helper = lioadm
[DEFAULT]
# ...
enabled_backends = lvm
[DEFAULT]
# ...
glance_api_servers = http://controller:9292
[oslo_concurrency]
# ...
lock_path = /var/lib/cinder/tmp
三、完成安装
启动并设置服务开机重启
[root@controller /]# systemctl start openstack-cinder-volume.service target.service
[root@controller /]# echo $?
0
[root@controller /]# systemctl enable openstack-cinder-volume.service target.service
[root@controller /]# echo $?
0
安装与配置控制节点
一、先决条件
1.创建数据库
使用root进入数据库
[root@controller /]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor.
创建Cinder数据库
MariaDB [(none)]> CREATE DATABASE cinder;
Query OK, 1 row affected (0.00 sec)
赋予合适的权限
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \
-> IDENTIFIED BY 'qwer1234';
Query OK, 0 rows affected (0.02 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \
-> IDENTIFIED BY 'qwer1234';
Query OK, 0 rows affected (0.00 sec)
2.获取admin凭据以访问仅限管理员的CLI命令:
[root@controller openrc]# source admin-openrc.sh
3.创建凭据
创建Cinder用户
[root@controller openrc]# openstack user create --domain default --password-prompt cinder
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 41ad64c50c8f4ba89790dd844b90a95c |
| name | cinder |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
给Cinder用户管理员权限
[root@controller /]# openstack role add --project service --user cinder admin
[root@controller /]# echo $?
0
创建cinderv2和cinderv3服务实体:
[root@controller /]# openstack service create --name cinderv2 \
> --description "OpenStack Block Storage" volumev2
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | bd09eb2aec054597b05017c20d6300a0 |
| name | cinderv2 |
| type | volumev2 |
+-------------+----------------------------------+
[root@controller /]# openstack service create --name cinderv3 \
> --description "OpenStack Block Storage" volumev3
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Block Storage |
| enabled | True |
| id | bd751776bfd14e86a9ebeec97d013948 |
| name | cinderv3 |
| type | volumev3 |
+-------------+----------------------------------+
4.创建块存储服务API端点:
[root@controller /]# openstack endpoint create --region RegionOne \
> volumev2 public http://controller:8776/v2/%\(project_id\)s
+--------------+---------------------------------------------+
| Field | Value |
+--------------+---------------------------------------------+
| enabled | True |
| id | e6bedcb5d3524d89bc1d91259d10b698 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | bd09eb2aec054597b05017c20d6300a0 |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller:8776/v2/%(project_id)s |
+--------------+---------------------------------------------+
[root@controller /]# openstack endpoint create --region RegionOne \
> volumev2 internal http://controller:8776/v2/%\(project_id\)s
+--------------+---------------------------------------------+
| Field | Value |
+--------------+---------------------------------------------+
| enabled | True |
| id | 6cce3016eafd4c498123265fe3505f65 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | bd09eb2aec054597b05017c20d6300a0 |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller:8776/v2/%(project_id)s |
+--------------+---------------------------------------------+
[root@controller /]# openstack endpoint create --region RegionOne \
> volumev2 admin http://controller:8776/v2/%\(project_id\)s
+--------------+---------------------------------------------+
| Field | Value |
+--------------+---------------------------------------------+
| enabled | True |
| id | 9e0ec665b8874cf2aa2a8ee35fa56e5d |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | bd09eb2aec054597b05017c20d6300a0 |
| service_name | cinderv2 |
| service_type | volumev2 |
| url | http://controller:8776/v2/%(project_id)s |
+--------------+---------------------------------------------+
[root@controller /]# openstack endpoint create --region RegionOne \
> volumev3 public http://controller:8776/v3/%\(project_id\)s
+--------------+---------------------------------------------+
| Field | Value |
+--------------+---------------------------------------------+
| enabled | True |
| id | c01c009628d941b485fba9c3f56b8639 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | bd751776bfd14e86a9ebeec97d013948 |
| service_name | cinderv3 |
| service_type | volumev3 |
| url | http://controller:8776/v3/%(project_id)s |
+--------------+---------------------------------------------+
[root@controller /]# openstack endpoint create --region RegionOne \
> volumev3 internal http://controller:8776/v3/%\(project_id\)s
+--------------+---------------------------------------------+
| Field | Value |
+--------------+---------------------------------------------+
| enabled | True |
| id | 162cef6fb39541bbba7b8dcb7598ef6a |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | bd751776bfd14e86a9ebeec97d013948 |
| service_name | cinderv3 |
| service_type | volumev3 |
| url | http://controller:8776/v3/%(project_id)s |
+--------------+---------------------------------------------+
[root@controller /]# openstack endpoint create --region RegionOne \
> volumev3 admin http://controller:8776/v3/%\(project_id\)s
+--------------+---------------------------------------------+
| Field | Value |
+--------------+---------------------------------------------+
| enabled | True |
| id | 654f9590216344069e306df684538310 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | bd751776bfd14e86a9ebeec97d013948 |
| service_name | cinderv3 |
| service_type | volumev3 |
| url | http://controller:8776/v3/%(project_id)s |
+--------------+---------------------------------------------+
三、安装和配置组件
1.安装软件
[root@controller /]# yum install openstack-cinder
2.编辑/etc/cinder/cinder.conf文件及修改其内容
[root@controller /]# vim /etc/cinder/cinder.conf
[database]
# ...
connection = mysql+pymysql://cinder:qwer1234@controller/cinder
[DEFAULT]
# ...
transport_url = rabbit://openstack:qwer1234@controller
[DEFAULT]
# ...
auth_strategy = keystone
[keystone_authtoken]
# ...
auth_uri = http://controller:5000
auth_url = http://controller:35357
memcached_servers = controller:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = qwer1234
[DEFAULT]
# ...
my_ip = 10.0.0.11
3.在[oslo_concurrency]部分,配置锁路径:
[oslo_concurrency]
# ...
lock_path = /var/lib/cinder/tmp
4.填充块存储数据库(忽略弃用信息):
[root@controller /]# su -s /bin/sh -c "cinder-manage db sync" cinder
Option "logdir" from group "DEFAULT" is deprecated. Use option "log-dir" from group "DEFAULT".
[root@controller /]# echo $?
0
将Compute配置为使用块存储
编辑/etc/nova/nova.conf文件修改其内容
[cinder]
os_region_name = RegionOne
四、验证安装
1.重启计算API服务:
[root@controller /]# systemctl restart openstack-nova-api.service
[root@controller /]# echo $?
0
2.启动块存储服务,并将其配置为在系统启动时启动:
[root@controller /]# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
[root@controller /]# echo $?
0
[root@controller /]# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
[root@controller /]# echo $?
0
验证Cinder
1.获取admin凭据以访问仅限管理员的CLI命令:
[root@controller openrc]# source admin-openrc.sh
2.列出验证每个流程成功启动的服务组件:
[root@controller openrc]# openstack volume service list
+------------------+------------+------+---------+-------+----------------------------+
| Binary | Host | Zone | Status | State | Updated At |
+------------------+------------+------+---------+-------+----------------------------+
| cinder-scheduler | controller | nova | enabled | up | 2022-02-25T02:46:46.000000 |
+------------------+------------+------+---------+-------+-------------------------
标签:openstack,service,部署,controller,cinder,OpenStack,root,id 来源: https://blog.csdn.net/weixin_44099173/article/details/123186003