当前位置:   article > 正文

【OpenStack(Train版)安装部署(八)】之Compute节点部署Cinder服务_openstack怎么使用computer节点其他分区的存储

openstack怎么使用computer节点其他分区的存储

本文章由公号【开发小鸽】发布!欢迎关注!!!


老规矩–妹妹镇楼:

1. 创建cinder数据库并授权

       进入mysql中创建cinder数据库以及赋予该数据库的权限给用户cinder,并设置密码为CINDER_DBPASS。

[root@controller ~]# mysql
MariaDB [(none)]> CREATE DATABASE cinder;
Query OK, 1 row affected (0.012 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'CINDER_DBPASS';
Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'CINDER_DBPASS';
Query OK, 0 rows affected (0.000 sec)
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9

2.创建cinder用户

       在openStack中创建cinder用户:

[root@controller ~]# openstack user create --domain default --password CINDER_PASS cinder
  • 1

在这里插入图片描述


3.向cinder用户添加admin角色

[root@controller ~]# openstack role add --project service --user cinder admin
  • 1

4.创建cinderv2和cinderv3服务实体

       cinder有v2和v3两个并存版本的API,所以需要创建两个版本的service实例

[root@controller ~]# openstack service create --name cinderv2 
--description "OpenStack Block Storage" volumev2
  • 1
  • 2

在这里插入图片描述

[root@controller ~]# openstack service create --name cinderv3 
--description "OpenStack Block Storage" volumev3
  • 1
  • 2

在这里插入图片描述

5.创建块存储服务API端点

       给v2和v3版本的api创建endpoint

[root@controller ~]# openstack endpoint create --region RegionOne volumev2 public http://192.168.112.146:8776/v2/%\(project_id\)s
  • 1

在这里插入图片描述

[root@controller ~]# openstack endpoint create --region RegionOne volumev2 internal http://192.168.112.146:8776/v2/%\(project_id\)s
  • 1

在这里插入图片描述

[root@controller ~]# openstack endpoint create --region RegionOne volumev2 admin http://192.168.112.146:8776/v2/%\(project_id\)s
  • 1

在这里插入图片描述

[root@controller ~]# openstack endpoint create --region RegionOne volumev3 public http://192.168.112.146:8776/v3/%\(project_id\)s
  • 1

在这里插入图片描述

[root@controller ~]# openstack endpoint create --region RegionOne volumev3 internal http://192.168.112.146:8776/v3/%\(project_id\)s
  • 1

在这里插入图片描述

[root@controller ~]# openstack endpoint create --region RegionOne volumev3 admin http://192.168.112.146:8776/v3/%\(project_id\)s
  • 1

在这里插入图片描述


6.Controller节点安装cinder软件包并修改配置文件

       安装openstack-cinder软件:

yum install openstack-cinder
  • 1

       精简cinder.conf的配置文件:

cp /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak
grep -Ev '#|^$' /etc/cinder/cinder.conf.bak>/etc/cinder/cinder.conf
  • 1
  • 2
openstack-config --set /etc/cinder/cinder.conf   database connection mysql+pymysql://cinder:CINDER_DBPASS@192.168.112.146/cinder
openstack-config --set /etc/cinder/cinder.conf   DEFAULT  transport_url  rabbit://openstack:RABBIT_PASS@192.168.112.146
openstack-config --set /etc/cinder/cinder.conf   DEFAULT  auth_strategy  keystone
openstack-config --set /etc/cinder/cinder.conf   keystone_authtoken   www_authenticate_uri  http://192.168.112.146:5000
openstack-config --set /etc/cinder/cinder.conf   keystone_authtoken   auth_url  http://192.168.112.146:5000
openstack-config --set /etc/cinder/cinder.conf   keystone_authtoken   memcached_servers  192.168.112.146:11211
openstack-config --set /etc/cinder/cinder.conf   keystone_authtoken   auth_type  password
openstack-config --set /etc/cinder/cinder.conf   keystone_authtoken   project_domain_name  default
openstack-config --set /etc/cinder/cinder.conf   keystone_authtoken   user_domain_name  default
openstack-config --set /etc/cinder/cinder.conf   keystone_authtoken   project_name  service
openstack-config --set /etc/cinder/cinder.conf   keystone_authtoken   username  cinder
openstack-config --set /etc/cinder/cinder.conf   keystone_authtoken   password  CINDER_PASS
openstack-config --set /etc/cinder/cinder.conf   DEFAULT  my_ip  192.168.112.146
openstack-config --set /etc/cinder/cinder.conf   oslo_concurrency  lock_path  /var/lib/cinder/tmp
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14

7.填充块存储数据库

       同步cinder数据库(填充块存储数据库)

[root@controller ~]# su -s /bin/sh -c "cinder-manage db sync" cinder
  • 1

8.配置计算节点的nova.conf来使用块存储

       在Compute节点中配置nova.conf文件,修改cinder选项为RegionOne:

[root@compute01 ~]# vim /etc/nova/nova.conf
....
[cinder]
os_region_name = RegionOne
  • 1
  • 2
  • 3
  • 4

9.重新启动Compute API服务

[root@controller ~]# systemctl restart openstack-nova-api.service
  • 1

10.启动块存储服务,并设置开机自启

[root@controller ~]# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
[root@controller ~]# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
  • 1
  • 2

11.控制节点验证

[root@controller ~]# cinder service-list
  • 1

在这里插入图片描述

12.安装和配置存储节点【compute】

(1)安装LVM软件包

[root@compute01 ~]# yum install lvm2 device-mapper-persistent-data
  • 1

(2)启动LVM元数据服务,并设置开机自启

[root@compute01 ~]# systemctl enable lvm2-lvmetad.service
[root@compute01 ~]# systemctl start lvm2-lvmetad.service
  • 1
  • 2

(3)新增一个硬盘

       在vmware中新建一个20g的硬盘/dev/sdb,在compute节点中查看当前的硬盘情况:

在这里插入图片描述


(4)创建LVM物理卷/dev/sdb;在这之前新增20G硬盘

[root@compute01 ~]# pvcreate /dev/sdb
  Physical volume "/dev/sdb" successfully created.
  • 1
  • 2

(5)创建LVM卷组cinder-volumes

[root@compute01 ~]# vgcreate cinder-volumes /dev/sdb
  Volume group "cinder-volumes" successfully created
  • 1
  • 2

(6)修改lvm配置文件(指定使用sdb磁盘)

[root@computer ~]# vim /etc/lvm/lvm.conf
141行,取消,
#a表示允许,r表示拒绝 
#只允许lvm服务访问sdb中的数据,不允许lvm服务访问其他磁盘,这也间接实现了openstack创建的虚拟机只能访问sdb中的数据,不能访问其他磁盘
#设置只允许实例访问sdb逻辑卷中的数据;如果不配置的话,本机的其他服务也有可能会访问sdb逻辑卷中的数据
  • 1
  • 2
  • 3
  • 4
  • 5
filter = [ "a/sdb/", "r/.*/"]
  • 1

(7)Compute节点安装软件包

yum install openstack-cinder targetcli python-keystone -y

yum install python-openstackclient -y
  • 1
  • 2
  • 3

(8)修改cinder配置文件

[root@compute01 ~]# cp /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak
[root@compute01 ~]# grep -Ev '#|^$' /etc/cinder/cinder.conf.bak>/etc/cinder/cinder.conf
  • 1
  • 2
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  database  connection mysql+pymysql://cinder:CINDER_DBPASS@192.168.112.146/cinder
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  DEFAULT transport_url rabbit://openstack:RABBIT_PASS@192.168.112.146
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  DEFAULT auth_strategy keystone
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  DEFAULT my_ip 192.168.112.145
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  DEFAULT enabled_backends lvm
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  DEFAULT glance_api_servers http://192.168.112.146:9292
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  keystone_authtoken www_authenticate_uri http://192.168.112.146:5000
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  keystone_authtoken auth_url http://192.168.112.146:5000
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  keystone_authtoken memcached_servers 192.168.112.146:11211
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  keystone_authtoken auth_type password
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  keystone_authtoken project_domain_name default
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  keystone_authtoken user_domain_name default
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  keystone_authtoken project_name service
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  keystone_authtoken username cinder
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  keystone_authtoken password CINDER_PASS
#指定LVM驱动程序;即通过指定的驱动创建LVM
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  lvm volume_driver cinder.volume.drivers.lvm.LVMVolumeDriver
#指定卷组(vg)
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  lvm volume_group cinder-volumes
#pv使用的是iscsi协议,可以提供块存储服务
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  lvm target_protocol iscsi
#iscsi管理工具
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  lvm target_helper lioadm
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf  oslo_concurrency lock_path /var/lib/cinder/tmp
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24

(9)启动块存储卷服务及其相关,并设置开机自启

[root@compute01 ~]# systemctl enable openstack-cinder-volume.service target.service
[root@compute01 ~]# systemctl start openstack-cinder-volume.service target.service
  • 1
  • 2

(10)验证cinder块存储服务【controller节点】

查看卷的列表:

[root@controller ~]# openstack volume service list
  • 1

在这里插入图片描述

(11)使用块存储服务向实例提供数据盘

创建一个20 GB的卷:

[root@controller ~]# openstack volume create --size 20 volume1
  • 1

在这里插入图片描述

[root@controller ~]# openstack volume list
  • 1

在这里插入图片描述

(12)将卷附加到实例

openstack server add volume INSTANCE_NAME VOLUME_NAME
  • 1

       将volume1卷附加到firstVM实例:

[root@controller ~]# openstack server add volume firstVM volume1
  • 1

       再次查看openstack中的volume状态可以看到volume1已经attach到了实例上

[root@controller ~]# openstack volume list
  • 1

在这里插入图片描述

       通过Dashboard查看volume1的状态是可用,再通过界面的操作可以直接将volume1连接到实例firstVM中。想要验证该实例是否挂载了volume1,直接进入firstVM的控制台中,通过命令sudo fdisk -l命令可以查看到该实例挂载的卷。

在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/小丑西瓜9/article/detail/720729
推荐阅读
相关标签
  

闽ICP备14008679号