1、控制节点

1.1、数据库配置

  1. mysql -uroot -p123456
  2. CREATE DATABASE cinder;
  3. GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'cinder';
  4. GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'cinder';

1.2、创建项目

  1. openstack user create --domain default --password cinder cinder
  2. openstack role add --project service --user cinder admin
  3. openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
  4. openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3
  5. openstack endpoint create --region RegionOne volumev2 public http://controller:8776/v2/%\(project_id\)s
  6. openstack endpoint create --region RegionOne volumev2 internal http://controller:8776/v2/%\(project_id\)s
  7. openstack endpoint create --region RegionOne volumev2 admin http://controller:8776/v2/%\(project_id\)s
  8. openstack endpoint create --region RegionOne volumev3 public http://controller:8776/v3/%\(project_id\)s
  9. openstack endpoint create --region RegionOne volumev3 internal http://controller:8776/v3/%\(project_id\)s
  10. openstack endpoint create --region RegionOne volumev3 admin http://controller:8776/v3/%\(project_id\)s

1.3、安装cinder

  1. yum install openstack-cinder -y
  2. cp /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak
  3. vim /etc/cinder/cinder.conf
  4. [database]
  5. # ...
  6. connection = mysql+pymysql://cinder:cinder@controller/cinder
  7. [DEFAULT]
  8. # ...
  9. transport_url = rabbit://openstack:openstack@controller
  10. auth_strategy = keystone
  11. my_ip = 192.168.189.150
  12. [keystone_authtoken]
  13. # ...
  14. www_authenticate_uri = http://controller:5000
  15. auth_url = http://controller:5000
  16. memcached_servers = controller:11211
  17. auth_type = password
  18. project_domain_name = default
  19. user_domain_name = default
  20. project_name = service
  21. username = cinder
  22. password = cinder
  23. [oslo_concurrency]
  24. # ...
  25. lock_path = /var/lib/cinder/tmp

1.4、同步数据库

  1. su -s /bin/sh -c "cinder-manage db sync" cinder

1.5、将计算配置使用块存储

  1. vim /etc/nova/nova.conf
  2. [cinder]
  3. os_region_name = RegionOne

1.6、启动

  1. systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
  2. systemctl restart openstack-cinder-api.service openstack-cinder-scheduler.service
  3. systemctl status openstack-cinder-api.service openstack-cinder-scheduler.service

2、存储节点

2.1、块设备准备

  1. #安装
  2. yum install lvm2 device-mapper-persistent-data -y
  3. systemctl enable lvm2-lvmetad.service
  4. systemctl restart lvm2-lvmetad.service
  5. systemctl status lvm2-lvmetad.service
  6. #创建 LVM 物理卷:/dev/sdb
  7. pvcreate /dev/sdb
  8. #创建 LVM 卷组:cinder-volumes
  9. vgcreate cinder-volumes /dev/sdb
  10. #配置过滤规则
  11. cp /etc/lvm/lvm.conf /etc/lvm/lvm.conf.bak
  12. vim /etc/lvm/lvm.conf
  13. devices {
  14. ...
  15. filter = [ "a|/sdb|", "r|/.*/|"]

2.2、安装cinder

  1. yum install openstack-cinder targetcli python-keystone -y
  2. cp /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak
  3. sed -ri '/^[ \t]*(#|$)/d' /etc/cinder/cinder.conf
  4. vim /etc/cinder/cinder.conf
  5. [database]
  6. # ...
  7. connection = mysql+pymysql://cinder:cinder@controller/cinder
  8. [DEFAULT]
  9. # ...
  10. transport_url = rabbit://openstack:openstack@controller
  11. auth_strategy = keystone
  12. my_ip = 192.168.189.153
  13. enabled_backends = lvm
  14. glance_api_servers = http://controller:9292
  15. [keystone_authtoken]
  16. # ...
  17. www_authenticate_uri = http://controller:5000
  18. auth_url = http://controller:5000
  19. memcached_servers = controller:11211
  20. auth_type = password
  21. project_domain_name = default
  22. user_domain_name = default
  23. project_name = service
  24. username = cinder
  25. password = cinder
  26. [lvm]
  27. volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver
  28. volume_group = cinder-volumes
  29. target_protocol = iscsi
  30. target_helper = lioadm
  31. [oslo_concurrency]
  32. # ...
  33. lock_path = /var/lib/cinder/tmp

2.3、启动

  1. systemctl enable openstack-cinder-volume.service target.service
  2. systemctl restart openstack-cinder-volume.service target.service
  3. systemctl status openstack-cinder-volume.service target.service

3、验证

  1. openstack volume service list
  2. #创建1GB的卷
  3. openstack volume create --size 1 volume1

4、配置多个存储后端

  • 多个存储后端
  • cinder replication 链接2

    修改配置文件

    1. [DEFAULT]
    2. enabled_backends=lvmdriver-1,lvmdriver-2,lvmdriver-3
    3. [lvmdriver-1]
    4. volume_group=cinder-volumes-1
    5. volume_driver=cinder.volume.drivers.lvm.LVMVolumeDriver
    6. volume_backend_name=LVM
    7. [lvmdriver-2]
    8. volume_group=cinder-volumes-2
    9. volume_driver=cinder.volume.drivers.lvm.LVMVolumeDriver
    10. volume_backend_name=LVM
    11. [lvmdriver-3]
    12. volume_group=cinder-volumes-3
    13. volume_driver=cinder.volume.drivers.lvm.LVMVolumeDriver
    14. volume_backend_name=LVM_b

    添加卷类型

    1. openstack volume type create lvm1
    2. openstack volume type set lvm1 --property volume_backend_name=lvm1
    3. openstack volume type create lvm2
    4. openstack volume type set lvm2 --property volume_backend_name=lvm2
    5. openstack volume type list --long