直接将cinder服务和块设备都部署在controller节点上

在controller节点添加一块100G的块设备/dev/sdb

配置数据库

(root@localhost) [(none)]> CREATE DATABASE cinder;
Query OK, 1 row affected (0.02 sec) (root@localhost) [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'cinder';       
Query OK, 0 rows affected (0.10 sec) (root@localhost) [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'cinder'; 
Query OK, 0 rows affected (0.00 sec) (root@localhost) [(none)]> flush privileges ;
Query OK, 0 rows affected (0.04 sec)

配置cinder服务认证

创建cinder用户:

root@controller:~#  openstack user create --password-prompt cinder
User Password:cinder
Repeat User Password:cinder
+----------+----------------------------------+
| Field    | Value                            |
+----------+----------------------------------+
| email    | None                             |
| enabled  | True                             |
| id       | cbdfbba062b6446dac61ca9b9ce67eb6 |
| name     | cinder                           |
| username | cinder                           |
+----------+----------------------------------+

将admin角色添加给cinder用户:

root@controller:~# openstack role add --project service --user cinder admin
+-------+----------------------------------+
| Field | Value                            |
+-------+----------------------------------+
| id    | 63561476dd124bc1b6fe1e4f3cb7f3dc |
| name  | admin                            |
+-------+----------------------------------+

创建cinder的服务实体:

root@controller:~# openstack service create --name cinder --description "OpenStack Block Storage" volume
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Block Storage          |
| enabled     | True                             |
| id          | 91fafad225f1475c9b4596ec663a8d9e |
| name        | cinder                           |
| type        | volume                           |
+-------------+----------------------------------+ root@controller:~# openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Block Storage          |
| enabled     | True                             |
| id          | 53b6766c632b43d0ae442d6e07af5a03 |
| name        | cinderv2                         |
| type        | volumev2                         |
+-------------+----------------------------------+

创建cinder服务的API endpoint:

root@controller:~# openstack endpoint create --publicurl http://controller:8776/v2/%\(tenant_id\)s --internalurl http://controller:8776/v2/%\(tenant_id\)s --adminurl http://controller:8776/v2/%\(tenant_id\)s --region RegionOne volume
+--------------+-----------------------------------------+
| Field        | Value                                   |
+--------------+-----------------------------------------+
| adminurl     | http://controller:8776/v2/%(tenant_id)s |
| id           | d9246387b6ec4f0f9a63e60c25b481f4        |
| internalurl  | http://controller:8776/v2/%(tenant_id)s |
| publicurl    | http://controller:8776/v2/%(tenant_id)s |
| region       | RegionOne                               |
| service_id   | 91fafad225f1475c9b4596ec663a8d9e        |
| service_name | cinder                                  |
| service_type | volume                                  |
+--------------+-----------------------------------------+ root@controller:~# openstack endpoint create --publicurl http://controller:8776/v2/%\(tenant_id\)s --internalurl http://controller:8776/v2/%\(tenant_id\)s --adminurl http://controller:8776/v2/%\(tenant_id\)s --region RegionOne volumev2
+--------------+-----------------------------------------+
| Field        | Value                                   |
+--------------+-----------------------------------------+
| adminurl     | http://controller:8776/v2/%(tenant_id)s |
| id           | 7f4e8c7a9b794336a61013ce56ceb994        |
| internalurl  | http://controller:8776/v2/%(tenant_id)s |
| publicurl    | http://controller:8776/v2/%(tenant_id)s |
| region       | RegionOne                               |
| service_id   | 53b6766c632b43d0ae442d6e07af5a03        |
| service_name | cinderv2                                |
| service_type | volumev2                                |
+--------------+-----------------------------------------+

安装cinder-server

root@controller:~# apt-get install cinder-api cinder-scheduler python-cinderclient cinder-volume

配置cinder-server

[DEFAULT]
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 10.0.0.200 [database] 
connection = mysql://cinder:cinder@controller/cinder [oslo_messaging_rabbit]
rabbit_host = controller 
rabbit_userid = openstack 
rabbit_password = openstack [keystone_authtoken]
auth_uri = http://controller:5000 
auth_url = http://controller:35357 
auth_plugin = password 
project_domain_id = default 
user_domain_id = default 
project_name = service
username = cinder
password = cinder [oslo_concurrency]
lock_path = /var/lock/cinder

初始化数据库:

root@controller:~# su -s /bin/sh -c "cinder-manage db sync" cinder

重启服务:

root@controller:~# service cinder-scheduler restart
cinder-scheduler stop/waiting
cinder-scheduler start/running, process 5420 root@controller:~# service cinder-api restart
cinder-api stop/waiting
cinder-api start/running, process 5444

删除Ubuntu自带的SQLit数据库:

root@controller:~# rm -f /var/lib/cinder/cinder.sqlite

块存储配置

创建新分区:将sdb整块盘建立一个分区:

root@controller:~# fdisk /dev/sdb
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel with disk identifier 0x622b5756.
Changes will remain in memory only, until you decide to write them.
After that, of course, the previous content won't be recoverable. Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite) Command (m for help): n
Partition type:
   p   primary (0 primary, 0 extended, 4 free)
   e   extended
Select (default p): p
Partition number (1-4, default 1): 1
First sector (2048-209715199, default 2048): 
Using default value 2048
Last sector, +sectors or +size{K,M,G} (2048-209715199, default 209715199): 
Using default value 209715199 Command (m for help): p Disk /dev/sdb: 107.4 GB, 107374182400 bytes
255 heads, 63 sectors/track, 13054 cylinders, total 209715200 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x622b5756    Device Boot      Start         End      Blocks   Id  System
/dev/sdb1            2048   209715199   104856576   83  Linux Command (m for help): w
The partition table has been altered! Calling ioctl() to re-read partition table.
Syncing disks.

配置LVM的物理卷:

root@controller:~# pvcreate /dev/sdb1
  Physical volume "/dev/sdb1" successfully created root@controller:~# pvdisplay  
  --- Physical volume ---
  PV Name               /dev/sdb1
  VG Name               cinder-volumes
  PV Size               100.00 GiB / not usable 3.00 MiB
  Allocatable           yes 
  PE Size               4.00 MiB
  Total PE              25599
  Free PE               25599
  Allocated PE          0
  PV UUID               bLnc53-Yv3d-samm-nGLL-riM8-TyJc-xQn0i5

创建LVM的卷组cinder-volumes:

root@controller:~# vgcreate cinder-volumes /dev/sdb1
  Volume group "cinder-volumes" successfully created root@controller:~# vgdisplay  
  --- Volume group ---
  VG Name               cinder-volumes
  System ID             
  Format                lvm2
  Metadata Areas        1
  Metadata Sequence No  1
  VG Access             read/write
  VG Status             resizable
  MAX LV                0
  Cur LV                0
  Open LV               0
  Max PV                0
  Cur PV                1
  Act PV                1
  VG Size               100.00 GiB
  PE Size               4.00 MiB
  Total PE              25599
  Alloc PE / Size       0 / 0   
  Free  PE / Size       25599 / 100.00 GiB
  VG UUID               B623Af-5Uru-0S81-23Cr-XOZt-ZCkq-Wh42sf

配置LVM仅仅扫描含有cinder-volume的卷组

编辑/etc/lvm/lvm.conf,在devices部分,添加一个筛选器,仅仅允许/dev/sdb设备并拒绝所有其他设备:

devices {
...
filter = [ "a/sdb/", "r/.*/"]

安装cinder

由于都部署在controller节点上,可以忽略这步

root@controller:~# apt-get install -y cinder-volume python-mysqldb

配置cinder

/etc/cinder/cinder.conf 添加:

[DEFAULT]
#启用LVM作为后端存储系统
enabled_backends = lvm
#镜像服务运行的节点
glance_host = controller #配置LVM驱动,卷组,iscsi的协议和helper:
[lvm]
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
volume_group = cinder-volumes
iscsi_protocol = iscsi
iscsi_helper = tgtadm

重启服务:

root@controller:~# service tgt restart
tgt stop/waiting
tgt start/running, process 3785 root@controller:~# service cinder-volume restart
cinder-volume stop/waiting
cinder-volume start/running, process 3838

检查块存储服务启动的服务组件:

root@controller:~# cinder service-list 
+------------------+----------------+------+---------+-------+----------------------------+-----------------+
|      Binary      |      Host      | Zone |  Status | State |         Updated_at         | Disabled Reason |
+------------------+----------------+------+---------+-------+----------------------------+-----------------+
| cinder-scheduler |   controller   | nova | enabled |   up  | 2019-08-27T03:43:37.000000 |       None      |
|  cinder-volume   |   controller   | nova | enabled |   up  | 2019-08-27T03:42:48.000000 |       None      |
|  cinder-volume   | controller@lvm | nova | enabled |   up  | 2019-08-27T03:43:33.000000 |       None      |
+------------------+----------------+------+---------+-------+----------------------------+-----------------+

卷的管理

创建1GB的一个卷:

root@controller:~# cinder create --name demo-volume1 1
+---------------------------------------+--------------------------------------+
|                Property               |                Value                 |
+---------------------------------------+--------------------------------------+
|              attachments              |                  []                  |
|           availability_zone           |                 nova                 |
|                bootable               |                false                 |
|          consistencygroup_id          |                 None                 |
|               created_at              |      2019-08-27T03:44:20.000000      |
|              description              |                 None                 |
|               encrypted               |                False                 |
|                   id                  | 2eea737f-6d26-48d9-b396-5c40062dc606 |
|                metadata               |                  {}                  |
|              multiattach              |                False                 |
|                  name                 |             demo-volume1             |
|         os-vol-host-attr:host         |                 None                 |
|     os-vol-mig-status-attr:migstat    |                 None                 |
|     os-vol-mig-status-attr:name_id    |                 None                 |
|      os-vol-tenant-attr:tenant_id     |   e2fc7b33877b4d4e844d63b4343e9d14   |
|   os-volume-replication:driver_data   |                 None                 |
| os-volume-replication:extended_status |                 None                 |
|           replication_status          |               disabled               |
|                  size                 |                  1                   |
|              snapshot_id              |                 None                 |
|              source_volid             |                 None                 |
|                 status                |               creating               |
|                user_id                |   5726ba166bea4c9b957ed227bfd26692   |
|              volume_type              |                 None                 |
+---------------------------------------+--------------------------------------+

查看可用的卷:

root@controller:~# cinder list 
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
|                  ID                  |   Status  |     Name     | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| 2eea737f-6d26-48d9-b396-5c40062dc606 | available | demo-volume1 |  1   |     None    |  false   |             |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+ root@controller:~# nova volume-list 
+--------------------------------------+-----------+--------------+------+-------------+-------------+
| ID                                   | Status    | Display Name | Size | Volume Type | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+-------------+
| 2eea737f-6d26-48d9-b396-5c40062dc606 | available |              | 1    | -           |             |
+--------------------------------------+-----------+--------------+------+-------------+-------------+

将卷添加到实例中:

root@controller:~# nova volume-attach demo1 2eea737f-6d26-48d9-b396-5c40062dc606
+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/vdb                             |
| id       | 2eea737f-6d26-48d9-b396-5c40062dc606 |
| serverId | 69eacd59-57dd-49b4-a310-b1cd98edd935 |
| volumeId | 2eea737f-6d26-48d9-b396-5c40062dc606 |
+----------+--------------------------------------+ root@controller:~# cinder list 
+--------------------------------------+--------+--------------+------+-------------+----------+--------------------------------------+
|                  ID                  | Status |     Name     | Size | Volume Type | Bootable |             Attached to              |
+--------------------------------------+--------+--------------+------+-------------+----------+--------------------------------------+
| 2eea737f-6d26-48d9-b396-5c40062dc606 | in-use | demo-volume1 |  1   |     None    |  false   | 69eacd59-57dd-49b4-a310-b1cd98edd935 |
+--------------------------------------+--------+--------------+------+-------------+----------+--------------------------------------+
root@controller:~# nova volume-list             
+--------------------------------------+--------+--------------+------+-------------+--------------------------------------+
| ID                                   | Status | Display Name | Size | Volume Type | Attached to                          |
+--------------------------------------+--------+--------------+------+-------------+--------------------------------------+
| 2eea737f-6d26-48d9-b396-5c40062dc606 | in-use |              | 1    | -           | 69eacd59-57dd-49b4-a310-b1cd98edd935 |
+--------------------------------------+--------+--------------+------+-------------+--------------------------------------+

OpenStack kilo版(8) 部署cinder的更多相关文章

  1. OpenStack kilo版(1) 部署环境

    硬件 VMware workstation虚拟机 Ubuntu14.04操作系统 虚拟机网络规划 管理网络: eth0, 桥接模式 10.0.0.0/24 外部网络: eth1, nat模式(需要关闭 ...

  2. OpenStack kilo版(7) 部署dashboard

    安装dashboard  root@controller:~# apt-get install openstack-dashboard  配置 /etc/openstack-dashboard/loc ...

  3. OpenStack Kilo版加CEPH部署手册

    OpenStack Kilo版加CEPH部署手册 作者: yz联系方式: QQ: 949587200日期: 2015-7-13版本: Kilo 转载地址: http://mp.weixin.qq.co ...

  4. CentOS7安装OpenStack(Rocky版)-09.安装Cinder存储服务组件(控制节点)

    本文分享openstack的Cinder存储服务组件,cinder服务可以提供云磁盘(卷),类似阿里云云盘 ----------------------- 完美的分隔线  -------------- ...

  5. OpenStack kilo版(5) Neutron部署

    neutron简介: Neutron 通过 plugin 和 agent 提供的网络服务. plugin 位于 Neutron server,包括 core plugin 和 service plug ...

  6. OpenStack kilo版(4) Glance部署

    Glance简介 Glance-api:接受云系统镜像的构建.删除.读取请求 Glance-Registry:云系统的镜像注册服务 部署在controller节点 配置数据库 MariaDB [(no ...

  7. OpenStack kilo版(3) Nova部署

    部署在controller和compute节点 配置数据库 MariaDB [(none)]> CREATE DATABASE nova;  Query OK, 1 row affected ( ...

  8. OpenStack kilo版(2) keystone部署

    部署在controller节点 配置数据库 MariaDB [(none)]> CREATE DATABASE keystone; Query OK, 1 row affected (0.00 ...

  9. OpenStack Train版 简单部署流程

    environment 1.网络平面 management(管理网络)→软件安装,组件通信 provider(提供实例网络)→:提供者网络:直接获取ip地址,实例之间直接互通   自服务网络(私有网络 ...

随机推荐

  1. 《楞严经四种清净明诲》 (转自学佛网:http://www.xuefo.net/nr/article56/559965.html)

    <楞严经四种清净明诲> 佛告阿难:“汝常闻我毗奈耶中,宣说修行三决定义.所谓摄心为戒,因戒生定,因定发慧,是则名为三无漏学. “阿难,云何摄心,我名为戒? “若诸世界六道众生其心不淫,则不 ...

  2. c#中多线程同步Lock(锁)的研究以及跨线程UI的操作 (转)

    https://www.cnblogs.com/tommyheng/p/4104552.html 本文只针对C#中,多线程同步所用到的锁(lock)作为研究对象.由于想更直观的显示结果,所以,在做de ...

  3. face_code业务信息不匹配

    face_code业务信息不匹配 检查获取 face code时的 appid, mch_id,out_trade_no以及可选的sub_mch_id ,  与 face pay 时是否一致.

  4. 微信小程序中的事件绑定

    前言: 微信小程序中的事件绑定和Vue中的事件绑定其实有很多的相似之处,所以如果有过Vue相关的经验,学起来的话还是比较容易的. js代码: // 页面级的js文件必须调用Page函数来注册页面, / ...

  5. 查询SQL时间段内执行过的哪些SQL语句

    QS.creation_time, ) , (( ) ) AS statement_text, ST.text, QS.total_worker_time, QS.last_worker_time, ...

  6. mysql索引 多个单列索引和联合索引的区别详解

    背景: 为了提高数据库效率,建索引是家常便饭:那么当查询条件为2个及以上时,我们是创建多个单列索引还是创建一个联合索引好呢?他们之间的区别是什么?哪个效率高呢?我在这里详细测试分析下. 一.联合索引测 ...

  7. 《ucore lab1》实验报告

    资源 ucore在线实验指导书 我的ucore实验代码 练习1:理解通过make生成执行文件的过程 详见<ucore lab1 exercise1>实验报告 练习2:使用qemu执行并调试 ...

  8. 客户端负载均衡Ribbon之三:AvailabilityFilteringRule的坑(Spring Cloud Finchley.SR2)

    我们项目配置了AvailabilityFilteringRule作为所有Ribbon调用的负载均衡规则,它有那些坑呢(理解歧义和注意点)? 首先来看com.netflix.loadbalancer.A ...

  9. 往List集合循环add(对象)得到的是重复对象

    记录每次的错误,强大是慢慢的积累,先看看代码, 往list中循环添加RoleKungFu对象,看似没有问题,结果打印则显示: 全部是重复的数据!这是因为啥呢,因为将对象add入list中时,放入lis ...

  10. 剑指offer31:整数中1出现的次数(从1到n整数中1出现的次数)

    1 题目描述 求出1~13的整数中1出现的次数,并算出100~1300的整数中1出现的次数?为此他特别数了一下1~13中包含1的数字有1.10.11.12.13因此共出现6次,但是对于后面问题他就没辙 ...