🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
存储节点cinder在云端上的作用是为计算节点提供块存储资源,为虚拟机实例提供一个存储分区接入到虚拟机中,同时还能进行管理虚拟机卷快照和卷类型。 1)在controller1上创建数据库用户并赋予权限 ``` MariaDB [(none)]> CREATE DATABASE cinder; MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'yjscloud'; MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'yjscloud'; ``` 2)在controller1上创建cinder用户并赋予admin权限 ``` source /root/admin-openrc openstack user create --domain default cinder --password yjscloud openstack role add --project service --user cinder admin ``` 3)在controller1上创建volume服务 ``` openstack service create --name cinder --description "OpenStack Block Storage" volume openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2 ``` 4)在controller1上创建endpoint ``` openstack endpoint create --region RegionOne volume public http://yjscloud.com:8776/v1/%\(tenant_id\)s openstack endpoint create --region RegionOne volume internal http://yjscloud.com:8776/v1/%\(tenant_id\)s openstack endpoint create --region RegionOne volume admin http://yjscloud.com:8776/v1/%\(tenant_id\)s openstack endpoint create --region RegionOne volumev2 public http://yjscloud.com:8776/v2/%\(tenant_id\)s openstack endpoint create --region RegionOne volumev2 internal http://yjscloud.com:8776/v2/%\(tenant_id\)s openstack endpoint create --region RegionOne volumev2 admin http://yjscloud.com:8776/v2/%\(tenant_id\)s ``` 5)在controller1、2、3上安装cinder相关服务 ``` yum install openstack-cinder -y ``` 6)在controller1、2、3上配置cinder配置文件 ``` >/etc/cinder/cinder.conf openstack-config --set /etc/cinder/cinder.conf DEFAULT debug False openstack-config --set /etc/cinder/cinder.conf DEFAULT verbose True openstack-config --set /etc/cinder/cinder.conf DEFAULT my_ip 10.1.1.156 openstack-config --set /etc/cinder/cinder.conf DEFAULT osapi_volume_listen_port 8776 openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone openstack-config --set /etc/cinder/cinder.conf DEFAULT enable_v1_api True openstack-config --set /etc/cinder/cinder.conf DEFAULT enable_v2_api True openstack-config --set /etc/cinder/cinder.conf DEFAULT enable_v3_api True openstack-config --set /etc/cinder/cinder.conf DEFAULT glance_api_servers http://yjscloud.com:9292 openstack-config --set /etc/cinder/cinder.conf DEFAULT glance_api_version 2 openstack-config --set /etc/cinder/cinder.conf DEFAULT storage_availability_zone nova openstack-config --set /etc/cinder/cinder.conf DEFAULT default_availability_zone nova openstack-config --set /etc/cinder/cinder.conf DEFAULT allow_availability_zone_fallback True openstack-config --set /etc/cinder/cinder.conf DEFAULT service_down_time 180 openstack-config --set /etc/cinder/cinder.conf DEFAULT report_interval 10 openstack-config --set /etc/cinder/cinder.conf DEFAULT osapi_volume_workers 4 openstack-config --set /etc/cinder/cinder.conf DEFAULT enable_force_upload True openstack-config --set /etc/cinder/cinder.conf DEFAULT rootwrap_config /etc/cinder/rootwrap.conf openstack-config --set /etc/cinder/cinder.conf database connection mysql+pymysql://cinder:yjscloud@yjscloud.com/cinder openstack-config --set /etc/cinder/cinder.conf database idle_timeout 3600 openstack-config --set /etc/cinder/cinder.conf database max_pool_size 30 openstack-config --set /etc/cinder/cinder.conf database max_retries -1 openstack-config --set /etc/cinder/cinder.conf database retry_interval 2 openstack-config --set /etc/cinder/cinder.conf database max_overflow 60 openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_hosts controller1:5672,controller2:5672,controller3:5672 openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_userid openstack openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_password yjscloud openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_ha_queues True openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_use_ssl False openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_retry_interval 1 openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_retry_backoff 2 openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_max_retries 0 openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit amqp_durable_queuesFalse openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_uri http://yjscloud.com:5000 openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://yjscloud.com:35357 openstack-config --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers controller1:11211,controller2:11211,controller3: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 yjscloud openstack-config --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/cinder/tmp ``` 7)在controller1上同步数据库 ``` su -s /bin/sh -c "cinder-manage db sync" cinder ``` 8)在controller1、2、3上启动cinder服务,并设置开机启动 ``` systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service systemctl status openstack-cinder-api.service openstack-cinder-scheduler.service ``` **注意!!!其他controller2、3重复做5、6、8步即可** 11)安装Cinder节点,Cinder节点这里我们需要额外的添加一个硬盘(/dev/sdb)用作cinder的存储服务(注意!这一步是在cinder节点 操作的) ``` yum install lvm2 -y ``` 12)启动服务并设置为开机自启**(注意!这一步是在cinder节点操作的)** ``` systemctl enable lvm2-lvmetad.service systemctl start lvm2-lvmetad.service systemctl status lvm2-lvmetad.service ``` 13)创建lvm, 这里的/dev/sdb就是额外添加的硬盘**(注意!这一步是在cinder节点操作的)** ``` fdisk -l pvcreate /dev/sdb vgcreate cinder-volumes /dev/sdb ``` 14)编辑存储节点lvm.conf文件**(注意!这一步是在cinder节点操作的)** ``` vim /etc/lvm/lvm.conf ``` ``` filter=[“a/sda/”,”a/sdb/”,”r/.*/*”] ``` ``` systemctl restart lvm2-lvmetad.service ``` 然后重启下lvm2服务: ``` systemctl restart lvm2-lvmetad.service systemctl status lvm2-lvmetad.service ``` 15)安装openstack-cinder、targetcli**(注意!这一步是在cinder节点操作的)** ``` yum install openstack-cinder openstack-utils targetcli python-keystone ntpdate scsi-target-utils -y ``` 16)配置cinder配置文件**(注意!这一步是在cinder节点操作的)** ``` cp /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak >/etc/cinder/cinder.conf openstack-config --set /etc/cinder/cinder.conf DEFAULT debug False openstack-config --set /etc/cinder/cinder.conf DEFAULT verbose True openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone openstack-config --set /etc/cinder/cinder.conf DEFAULT my_ip 10.1.1.156 openstack-config --set /etc/cinder/cinder.conf DEFAULT enabled_backends lvm openstack-config --set /etc/cinder/cinder.conf DEFAULT glance_api_servers http://yjscloud.com:9292 openstack-config --set /etc/cinder/cinder.conf DEFAULT glance_api_version 2 openstack-config --set /etc/cinder/cinder.conf DEFAULT enable_v1_api True openstack-config --set /etc/cinder/cinder.conf DEFAULT enable_v2_api True openstack-config --set /etc/cinder/cinder.conf DEFAULT enable_v3_api True openstack-config --set /etc/cinder/cinder.conf DEFAULT storage_availability_zone nova openstack-config --set /etc/cinder/cinder.conf DEFAULT default_availability_zone nova openstack-config --set /etc/cinder/cinder.conf DEFAULT service_down_time 180 openstack-config --set /etc/cinder/cinder.conf DEFAULT report_interval 10 openstack-config --set /etc/cinder/cinder.conf DEFAULT osapi_volume_workers 4 openstack-config --set /etc/cinder/cinder.conf DEFAULT os_region_name RegionOne openstack-config --set /etc/cinder/cinder.conf DEFAULT api_paste_config /etc/cinder/api-paste.ini openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_hosts controller1:5672,controller2:5672,controller3:5672 openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_userid openstack openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_password yjscloud openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_ha_queues True openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_use_ssl False openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_retry_interval 1 openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_retry_backoff 2 openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_max_retries 0 openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit amqp_durable_queues False openstack-config --set /etc/cinder/cinder.conf database connection mysql+pymysql://cinder:yjscloud@yjscloud.com/cinder openstack-config --set /etc/cinder/cinder.conf database idle_timeout 3600 openstack-config --set /etc/cinder/cinder.conf database max_pool_size 30 openstack-config --set /etc/cinder/cinder.conf database max_retries -1 openstack-config --set /etc/cinder/cinder.conf database retry_interval 2 openstack-config --set /etc/cinder/cinder.conf database max_overflow 60 openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_uri http://yjscloud.com:5000 openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://yjscloud.com:35357 openstack-config --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers controller1:11211,controller2:11211,controller3: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 yjscloud openstack-config --set /etc/cinder/cinder.conf lvm volume_driver cinder.volume.drivers.lvm.LVMVolumeDriver openstack-config --set /etc/cinder/cinder.conf lvm volume_group cinder-volumes openstack-config --set /etc/cinder/cinder.conf lvm iscsi_protocol iscsi openstack-config --set /etc/cinder/cinder.conf lvm iscsi_helper lioadm openstack-config --set /etc/cinder/cinder.conf oslo_convcurrency lock_path /var/lib/cinder/tmp ``` 17)启动openstack-cinder-volume和target并设置开机启动**(注意!这一步是在cinder节点操作的)** ``` systemctl enable openstack-cinder-volume.service target.service systemctl restart openstack-cinder-volume.service target.service systemctl status openstack-cinder-volume.service target.service ``` 18)在任意一个节点验证cinder服务是否正常 ``` source /root/admin-openrc cinder service-list netstat -ntlp | grep 3260 ``` ![8-1-27](http://pded8ke3e.bkt.clouddn.com/8-1-27.jpg)