这是搭建Openstack云平台的第七堂课,主要讲述存储组件cinder的配置过程。Cinder负责管理Openstack所有存储资源,因此要求磁盘性能有保障。
创建数据库用户
mysql -uroot -pMariadb123
create database cinder; grant all privileges on cinder.* to 'cinder'@'localhost' identified by 'Cinder123'; grant all privileges on cinder.* to 'cinder'@'%' identified by 'Cinder123'; flush privileges; exit
配置cinder服务凭证
创建cinder服务凭证
# source /opt/scripts/admin # 开始创建用户 openstack user create \ --domain default \ --password-prompt cinder
输入密码(Cinder123)后继续:
openstack role add \ --project service \ --user cinder admin openstack service create \ --name cinderv2 \ --description "OpenStack Block Storage" volumev2 openstack service create \ --name cinderv3 \ --description "OpenStack Block Storage" volumev3
创建endpoint
openstack endpoint create \ --region RegionOne volumev2 public http://controller:8776/v2/%\(project_id\)s openstack endpoint create \ --region RegionOne volumev2 internal http://controller:8776/v2/%\(project_id\)s openstack endpoint create \ --region RegionOne volumev2 admin http://controller:8776/v2/%\(project_id\)s openstack endpoint create \ --region RegionOne volumev3 public http://controller:8776/v3/%\(project_id\)s openstack endpoint create \ --region RegionOne volumev3 internal http://controller:8776/v3/%\(project_id\)s openstack endpoint create \ --region RegionOne volumev3 admin http://controller:8776/v3/%\(project_id\)s
配置控制节点上的服务
安装cinder
yum -y install openstack-cinder
配置cinder
修改配置/etc/cinder/cinder.conf:
[DEFAULT] my_ip = 10.10.100.150 auth_strategy = keystone log_dir = /var/log/cinder transport_url = rabbit://openstack:Openstack123@controller:5672 #如果使用ceph存储,请取消以下注释 #enabled_backends = ceph #glance_api_servers = http://controller:9292 #osapi_volume_listen = $my_ip #osapi_volume_listen_port = 8776 #state_path = /var/lib/cinder [ceph] #如果使用ceph,取消如下注释,并注释后面lvm段中的所有内容 #volume_driver = cinder.volume.drivers.rbd.RBDDriver #rbd_pool = volumes #rbd_ceph_conf = /etc/ceph/ceph.conf #rbd_flatten_volume_from_snapshot = False #rbd_max_clone_depth = 5 #rbd_store_chunk_size = 4 #rados_connect_timeout = -1 #glance_api_version = 2 #rbd_user = cinder #rbd_secret_uuid = {uuid} [database] connection = mysql+pymysql://cinder:Cinder123@controller/cinder [keystone_authtoken] #auth_uri = http://controller:5000 www_authenticate_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 = Cinder123 [oslo_concurrency] lock_path = /var/lib/cinder/tmp #lock_path = $state_path/tmp
初始化cinder数据
su -s /bin/sh -c "cinder-manage db sync" cinder
配置nova
修改配置/etc/nova/nova.conf:
[cinder] os_region_name = RegionOne
启动应用
systemctl restart openstack-nova-api systemctl enable openstack-cinder-api openstack-cinder-scheduler systemctl start openstack-cinder-api openstack-cinder-scheduler
配置存储节点上的服务
启用lvm
一般情况下,系统默认已经启动lvm服务,无需以下操作。
systemctl enable lvm2-lvmetad; systemctl start lvm2-lvmetad
配置专用存储块
# 找到要添加的存储块 fdisk -l # 创建pv pvcreate /dev/sdb # 创建vg vgcreate cinder-volumes /dev/sdb
安装cinder
yum -y install openstack-cinder targetcli python-keystone
配置cinder
修改配置/etc/cinder/cinder.conf:
[DEFAULT] my_ip = 10.10.100.151 auth_strategy = keystone enabled_backends = lvm glance_api_servers = http://controller:9292 transport_url = rabbit://openstack:Openstack123@controller:5672 [database] connection = mysql+pymysql://cinder:Cinder123@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 = Cinder123 [lvm] volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver volume_group = cinder-volumes iscsi_protocol = iscsi iscsi_helper = lioadm [oslo_concurrency] lock_path = /var/lib/cinder/tmp
启动应用
systemctl enable openstack-cinder-volume target systemctl start openstack-cinder-volume target
在控制节点上验证存储
openstack volume service list
原创文章禁止转载:技术学堂 » Openstack云平台搭建课程七·存储服务Cinder