直接将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. log4j 异常时在日志文件里面显示空的。

    如下图所示,输入的时候不要写 e.getStackTrace() 一般情况下不会出问题,但有时候就会出问题 解决方案

  2. iOS popToViewController具体用法

    [self.navigationController popToViewController:[self.navigationController.viewControllers objectAtIn ...

  3. LeetCode_283. Move Zeroes

    283. Move Zeroes Easy Given an array nums, write a function to move all 0's to the end of it while m ...

  4. yarn那些事儿

    本篇文章立足于mac. 一.安装yarn 1.通过homebrew brew update brew install yarn 2.通过脚本 curl -o- -L https://yarnpkg.c ...

  5. 页面进行ajax时 显示一个中间浮动loading

    先发效果图,加载东西的时候如果没有设计或者其它提示会降低用户体验,所以写了个简单的loading弹层. 适用于触屏和pc页面. /* 页面进行ajax时 显示一个中间浮动loading @auther ...

  6. LeetCode 189. 旋转数组(Rotate Array)

    189. 旋转数组 LeetCode189. Rotate Array 题目描述 给定一个数组,将数组中的元素向右移动 k 个位置,其中 k 是非负数. 示例 1: 输入: [1,2,3,4,5,6, ...

  7. GraphHopper-初识

    GraphHopper  GraphHopper is a fast and Open Source road routing engine.   Is fast and memory efficie ...

  8. SCI-hub使用技巧(下载外文文献)

    下载外文文献方法指南: (1)首先查找需要下载文献的DOI (2)在Sci-Hub主页搜索框输入URL.DOI或者PMID. (3)点击open即可看见下载界面. 参考文献:https://mp.we ...

  9. 大数据架构(PB级)

    1.随着互联网快速发展,数据量的快速膨胀,我们日增3000多亿数据量,因此需要针对PB级存储.几百TB的增量数据处理架构设计 2.系统逻辑划分总图: 暂不便透露 3.系统架构图: 4.大数据计算引擎我 ...

  10. Java基础笔试练习(五)

    1.以下关于Integer与int的区别错误的是? A.int是java提供的8种原始数据类型之一 B.Integer是java为int提供的封装类 C.int的默认值为0 D.Integer的默认值 ...