控制节点

创建数据库

[root@controller ~]# mysql -u root -p -e "CREATE DATABASEcinder;"

Enter password:

[root@controller ~]#  mysql -u root-p -e "GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIEDBY 'cinder';"

Enter password:

[root@controller ~]# mysql -u root -p -e "GRANT ALL PRIVILEGES ONcinder.* TO 'cinder'@'%' IDENTIFIED BY 'cinder';"

Enter password:

控制节点

安装cinder

[root@controller ~]# yum install -y openstack-cinder python-cinderclient

配置cinder

同步数据库

[root@controller ~]# vim /etc/cinder/cinder.conf

2516 connection = mysql://cinder:cinder@192.168.1.11/cinder

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

创建用户

[root@controller ~]# openstack user create --domain default--password-prompt cinder

User Password:

Repeat User Password:

+-----------+----------------------------------+

| Field     | Value                            |

+-----------+----------------------------------+

| domain_id | default                          |

| enabled   | True                             |

| id        |c510d9f858ff4bb4842a8993ad335da7 |

| name      | cinder                           |

+-----------+----------------------------------+

将用户cinder加入service的项目

[[root@controller ~]# openstack role add --project service --user cinderadmin

配置使用keystone进行验证

[root@controller ~]# vim /etc/cinder/cinder.conf

536 auth_strategy = keystone

2640 [keystone_authtoken]

2641 auth_uri = http://192.168.1.11:5000

2642 auth_url = http://192.168.1.11:35357

2643 auth_plugin = password

2644 project_domain_id = default

2645 user_domain_id = default

2646 project_name = service

2647 username = cinder

2648 password = cinder

配置使用rabbitmq

[root@controller ~]# vim /etc/cinder/cinder.conf

2294 rpc_backend = rabbit

3173 rabbit_host = 192.168.1.11

3177 rabbit_port = 5672

3189 rabbit_userid = openstack

3193 rabbit_password = openstack

配置使用glance

[root@controller ~]# vim /etc/cinder/cinder.conf

421 glance_host = 192.168.1.11

配置锁路径

[root@controller ~]# vim /etc/cinder/cinder.conf

2874 lock_path = /var/lib/cinder/tmp

配置nova-api

[root@controller ~]# vim /etc/nova/nova.conf

2143 [cinder]

2144 os_region_name = RegionOn

启动服务

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

[root@controller ~]# systemctl enable openstack-cinder-api.serviceopenstack-cinder-scheduler.service

[root@controller ~]# systemctl start openstack-cinder-api.serviceopenstack-cinder-scheduler.service

注册服务

[root@controller ~]# openstack service create --name cinder \

--description "OpenStack Block Storage" volume

+-------------+----------------------------------+

| Field       | Value                            |

+-------------+----------------------------------+

| description | OpenStack Block Storage          |

| enabled     | True                             |

| id          |73651b73fbc349a395e6c3b93f72c772 |

| 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          |8e7a52669fc34e7ba0b89dbcc2490b2a |

| name        | cinderv2                         |

| type        | volumev2                         |

+-------------+----------------------------------+

[root@controller ~]#  openstackendpoint create --region RegionOne \

volume public http://192.168.1.11:8776/v1/%\(tenant_id\)s

+--------------+-------------------------------------------+

| Field        | Value                                     |

+--------------+-------------------------------------------+

| enabled      | True                                      |

| id           |fd62f38f07f7416abda61380fb44963e         |

| interface    | public                                    |

| region       | RegionOne                                 |

| region_id    | RegionOne                                 |

| service_id   |73651b73fbc349a395e6c3b93f72c772         |

| service_name | cinder                                    |

| service_type | volume                                    |

| url          |http://192.168.1.11:8776/v1/%(tenant_id)s |

+--------------+-------------------------------------------+

[root@controller ~]# openstack endpoint create --region RegionOne \

 volume internalhttp://192.168.1.11:8776/v1/%\(tenant_id\)s

+--------------+-------------------------------------------+

| Field        | Value                                     |

+--------------+-------------------------------------------+

| enabled      | True                                      |

| id           |7dd968d509674e2b8c4fbbf3c24294c2         |

| interface    | internal                                  |

| region       | RegionOne                                 |

| region_id    | RegionOne                                 |

| service_id   |73651b73fbc349a395e6c3b93f72c772         |

| service_name | cinder                                    |

| service_type | volume                                    |

| url          |http://192.168.1.11:8776/v1/%(tenant_id)s |

+--------------+-------------------------------------------+

[root@controller ~]# openstack endpoint create --region RegionOne \

volume admin http://192.168.1.11:8776/v1/%\(tenant_id\)s

+--------------+-------------------------------------------+

| Field        | Value                                     |

+--------------+-------------------------------------------+

| enabled      | True                                      |

| id           |05b05b6302e44ac2a78130696c3b9e05         |

| interface    | admin                                     |

| region       | RegionOne                                 |

| region_id    | RegionOne                                 |

| service_id   |73651b73fbc349a395e6c3b93f72c772         |

| service_name | cinder                                    |

| service_type | volume                                    |

| url          |http://192.168.1.11:8776/v1/%(tenant_id)s |

+--------------+-------------------------------------------+

[root@controller ~]# openstack endpoint create --region RegionOne \

volumev2 public http://192.168.1.11:8776/v2/%\(tenant_id\)s

+--------------+-------------------------------------------+

| Field        | Value                                     |

+--------------+-------------------------------------------+

| enabled      | True                                      |

| id           |6a510667fbba48ecb711dc9c07ef8b27         |

| interface    | public                                    |

| region       | RegionOne                                 |

| region_id    | RegionOne                                 |

| service_id   |8e7a52669fc34e7ba0b89dbcc2490b2a         |

| service_name | cinderv2                                  |

| service_type | volumev2                                  |

| url          |http://192.168.1.11:8776/v2/%(tenant_id)s |

+--------------+-------------------------------------------+

[root@controller ~]# openstack endpoint create --region RegionOne \

> volumev2 internal http://192.168.1.11:8776/v2/%\(tenant_id\)s

+--------------+-------------------------------------------+

| Field        | Value                                     |

+--------------+-------------------------------------------+

| enabled      | True                                      |

| id           |37701b9929b6450585c050f1fc98242b         |

| interface    | internal                                  |

| region       | RegionOne                                 |

| region_id    | RegionOne                                 |

| service_id   |8e7a52669fc34e7ba0b89dbcc2490b2a         |

| service_name | cinderv2                                  |

| service_type | volumev2                                  |

| url          | http://192.168.1.11:8776/v2/%(tenant_id)s|

+--------------+-------------------------------------------+

[root@controller ~]# openstack endpoint create --region RegionOne \

> volumev2 admin http://192.168.1.11:8776/v2/%\(tenant_id\)s

+--------------+-------------------------------------------+

| Field        | Value                                     |

+--------------+-------------------------------------------+

| enabled      | True                                      |

| id           |1ce121d3250d475da8a3ac9e730449e7          |

| interface    | admin                                     |

| region       | RegionOne                                 |

| region_id    | RegionOne                                 |

| service_id   |8e7a52669fc34e7ba0b89dbcc2490b2a         |

| service_name | cinderv2                                  |

| service_type | volumev2                                  |

| url          |http://192.168.1.11:8776/v2/%(tenant_id)s |

+--------------+-------------------------------------------+

计算节点

   在计算节点添加一块硬盘,至少20G

创建lvm

[root@compute ~]# pvcreate /dev/sdb

  Physical volume"/dev/sdb" successfully created

[root@compute ~]# vgcreate cinder-volumes /dev/sdb //必须一样

  Volume group"cinder-volumes" successfully created

[root@compute ~]# vim /etc/lvm/lvm.conf

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

安装存储节点

[root@compute ~]# yum install -y openstack-cinder targetclipython-oslo-policy

配置存储节点

配置和前面的类似,可以直接从控制节点拷贝

[root@controller ~]# scp /etc/cinder/cinder.conf192.168.1.12:/etc/cinder/cinder.conf

[root@compute ~]# vim /etc/cinder/cinder.conf

540 enabled_backends = lvm

在最后添加

[lvm]

volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver

volume_group = cinder-volumes

iscsi_protocol = iscsi

iscsi_helper = lioadm

启动服务

[root@compute ~]# systemctl enable openstack-cinder-volume.servicetarget.service

[root@compute ~]# systemctl start openstack-cinder-volume.servicetarget.service

验证查看

[root@controller ~]# cinder service-list

+------------------+-------------+------+---------+-------+----------------------------+-----------------+

|      Binary      |    Host    | Zone |  Status | State |         Updated_at         | Disabled Reason |

+------------------+-------------+------+---------+-------+----------------------------+-----------------+

| cinder-scheduler |  controller |nova | enabled |   up  | 2015-12-30T08:54:33.000000 |        -       |

|  cinder-volume   | compute@lvm | nova | enabled |   up  |2015-12-30T08:54:35.000000 |       -        |

+------------------+-------------+------+---------+-------+----------------------------+-----------------+

出现类似上面的结果表明已经成功,可以创建云硬盘了。如果出现down首先查看时间是否同步。