ThinkChat🤖让你学习和工作更高效,注册即送10W Token,即刻开启你的AI之旅 广告
[TOC] ## 功能简述 块存储服务(cinder)为实例提供块存储。通过驱动程序可支持的各种各样的存储,如NAS/SAN,NFS,LVM,Ceph等。 **常用组件:** cinder-api: 接收和响应外部有关块存储请求 cinder-volume: 提供存储空间 cinder-scheduler:调度器,决定将要分配的空间由哪一个cinder-volume提供 cinder-backup: 备份卷 **openstack服务通用步骤** 1. 数据库创库授权 2. 在keystone创建系统用户关联角色 3. 在keystone上创建服务,注册api 4. 安装相应服务软件包 5. 修改相应服务的配置文件 6. 同步数据库 7. 启动服务 ## 服务部署-控制节点 这里先以默认的lvm存储为例进行演示,后续会有专门使用NFS存储的章节 ### 1:数据库创库授权 ```sh CREATE DATABASE cinder; GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'CINDER_DBPASS'; GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'CINDER_DBPASS'; ``` ### 2:在keystone创建系统用户关联角色 ```sh openstack user create --domain default --password CINDER_PASS cinder openstack role add --project service --user cinder admin ``` ### 3:在keystone上创建服务和注册api ```sh openstack service create --name cinder --description "OpenStack Block Storage" volume openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2 openstack endpoint create --region RegionOQe volume public http://controller:8776/v1/%\(tenant_id\)s openstack endpoint create --region RegionOne volume internal http://controller:8776/v1/%\(tenant_id\)s openstack endpoint create --region RegionOne volume admin http://controller:8776/v1/%\(tenant_id\)s openstack endpoint create --region RegionOne volumev2 public http://controller:8776/v2/%\(tenant_id\)s openstack endpoint create --region RegionOne volumev2 internal http://controller:8776/v2/%\(tenant_id\)s openstack endpoint create --region RegionOne volumev2 admin http://controller:8776/v2/%\(tenant_id\)s ``` ### 4:安装服务相应软件包 ```sh yum install openstack-cinder -y ``` ### 5:修改相应服务的配置文件 **备份配置** ```sh cp /etc/cinder/cinder.conf{,.bak} grep -Ev '^$|#' /etc/cinder/cinder.conf.bak >/etc/cinder/cinder.conf my_ip=$(ip addr show dev eth0|awk -F"[ |/]+" 'NR==3 {print $3'}) ``` **非交互式修改cinder.conf配置** ```sh openstack-config --set /etc/cinder/cinder.conf DEFAULT rpc_backend rabbit openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone openstack-config --set /etc/cinder/cinder.conf DEFAULT my_ip $my_ip openstack-config --set /etc/cinder/cinder.conf database connection mysql+pymysql://cinder:CINDER_DBPASS@controller/cinder openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_uri http://controller:5000 openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://controller:35357 openstack-config --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers controller: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 CINDER_PASS openstack-config --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/cinder/tmp openstack-config --set /etc/cinder/cinder.conf oslo_messaging_rabbit rabbit_host controller 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 RABBIT_PASS ``` **非交互式修改novw.conf配置** ```sh #/etc/nova/nova.conf openstack-config --set /etc/nova/nova.conf cinder os_region_name RegionOne ``` ### 6:同步数据库 ```sh su -s /bin/sh -c "cinder-manage db sync" cinder ``` ### 7:启动服务 ```sh systemctl restart openstack-nova-api.service systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service ``` **检查:** `cinder service-list` ## 服务部署-计算节点 ### 1. 先决条件-安装启动lvm ```sh yum install lvm2 -y systemctl enable lvm2-lvmetad.service systemctl start lvm2-lvmetad.service ``` ### 2. 增加两块硬盘 先在虚拟机设置中为计算节点分别添加30G和10G两块硬盘,然后按下面方法可以在不重启虚拟机的情况下使硬盘生效,然后就可以创建lvm的pv和vg ```sh echo '- - -' >/sys/class/scsi_host/host0/scan fdisk -l pvcreate /dev/sdb pvcreate /dev/sdc vgcreate cinder-ssd /dev/sdb vgcreate cinder-sata /dev/sdc ``` ### 3. 修改/etc/lvm/lvm.conf ```sh 在130下面插入一行: filter = [ "a/sdb/", "a/sdc/","r/.*/"] ``` ### 安装配置cinder服务 ```sh **安装** yum install openstack-cinder targetcli python-keystone -y ``` **配置** ```sh [root@compute1 ~]# cat /etc/cinder/cinder.conf [DEFAULT] rpc_backend = rabbit auth_strategy = keystone my_ip = 10.0.0.31 glance_api_servers = http://10.0.0.32:9292 enabled_backends = ssd,sata [BACKEND] [BRCD_FABRIC_EXAMPLE] [CISCO_FABRIC_EXAMPLE] [COORDINATION] [FC-ZONE-MANAGER] [KEYMGR] [cors] [cors.subdomain] [database] connection = mysql+pymysql://cinder:CINDER_DBPASS@controller/cinder [keystone_authtoken] auth_uri = http://controller:5000 auth_url = http://controller:35357 memcached_servers = controller:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = cinder password = CINDER_PASS [matchmaker_redis] [oslo_concurrency] lock_path = /var/lib/cinder/tmp [oslo_messaging_amqp] [oslo_messaging_notifications] [oslo_messaging_rabbit] rabbit_host = controller rabbit_userid = openstack rabbit_password = RABBIT_PASS [oslo_middleware] [oslo_policy] [oslo_reports] [oslo_versionedobjects] [ssl] [ssd] volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver volume_group = cinder-ssd iscsi_protocol = iscsi iscsi_helper = lioadm volume_backend_name = ssd [sata] volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver volume_group = cinder-sata iscsi_protocol = iscsi iscsi_helper = lioadm volume_backend_name = sata ``` **启动** ```sh systemctl enable openstack-cinder-volume.service target.service systemctl start openstack-cinder-volume.service target.service ```