赞
踩
老规矩–妹妹镇楼:
进入mysql中创建cinder数据库以及赋予该数据库的权限给用户cinder,并设置密码为CINDER_DBPASS。
[root@controller ~]# mysql
MariaDB [(none)]> CREATE DATABASE cinder;
Query OK, 1 row affected (0.012 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'CINDER_DBPASS';
Query OK, 0 rows affected (0.001 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'CINDER_DBPASS';
Query OK, 0 rows affected (0.000 sec)
在openStack中创建cinder用户:
[root@controller ~]# openstack user create --domain default --password CINDER_PASS cinder
[root@controller ~]# openstack role add --project service --user cinder admin
cinder有v2和v3两个并存版本的API,所以需要创建两个版本的service实例
[root@controller ~]# openstack service create --name cinderv2
--description "OpenStack Block Storage" volumev2
[root@controller ~]# openstack service create --name cinderv3
--description "OpenStack Block Storage" volumev3
给v2和v3版本的api创建endpoint
[root@controller ~]# openstack endpoint create --region RegionOne volumev2 public http://192.168.112.146:8776/v2/%\(project_id\)s
[root@controller ~]# openstack endpoint create --region RegionOne volumev2 internal http://192.168.112.146:8776/v2/%\(project_id\)s
[root@controller ~]# openstack endpoint create --region RegionOne volumev2 admin http://192.168.112.146:8776/v2/%\(project_id\)s
[root@controller ~]# openstack endpoint create --region RegionOne volumev3 public http://192.168.112.146:8776/v3/%\(project_id\)s
[root@controller ~]# openstack endpoint create --region RegionOne volumev3 internal http://192.168.112.146:8776/v3/%\(project_id\)s
[root@controller ~]# openstack endpoint create --region RegionOne volumev3 admin http://192.168.112.146:8776/v3/%\(project_id\)s
安装openstack-cinder软件:
yum install openstack-cinder
精简cinder.conf的配置文件:
cp /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak
grep -Ev '#|^$' /etc/cinder/cinder.conf.bak>/etc/cinder/cinder.conf
openstack-config --set /etc/cinder/cinder.conf database connection mysql+pymysql://cinder:CINDER_DBPASS@192.168.112.146/cinder
openstack-config --set /etc/cinder/cinder.conf DEFAULT transport_url rabbit://openstack:RABBIT_PASS@192.168.112.146
openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken www_authenticate_uri http://192.168.112.146:5000
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://192.168.112.146:5000
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers 192.168.112.146: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 DEFAULT my_ip 192.168.112.146
openstack-config --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/cinder/tmp
同步cinder数据库(填充块存储数据库)
[root@controller ~]# su -s /bin/sh -c "cinder-manage db sync" cinder
在Compute节点中配置nova.conf文件,修改cinder选项为RegionOne:
[root@compute01 ~]# vim /etc/nova/nova.conf
....
[cinder]
os_region_name = RegionOne
[root@controller ~]# systemctl restart openstack-nova-api.service
[root@controller ~]# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
[root@controller ~]# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
[root@controller ~]# cinder service-list
[root@compute01 ~]# yum install lvm2 device-mapper-persistent-data
[root@compute01 ~]# systemctl enable lvm2-lvmetad.service
[root@compute01 ~]# systemctl start lvm2-lvmetad.service
在vmware中新建一个20g的硬盘/dev/sdb,在compute节点中查看当前的硬盘情况:
[root@compute01 ~]# pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
[root@compute01 ~]# vgcreate cinder-volumes /dev/sdb
Volume group "cinder-volumes" successfully created
[root@computer ~]# vim /etc/lvm/lvm.conf
141行,取消,
#a表示允许,r表示拒绝
#只允许lvm服务访问sdb中的数据,不允许lvm服务访问其他磁盘,这也间接实现了openstack创建的虚拟机只能访问sdb中的数据,不能访问其他磁盘
#设置只允许实例访问sdb逻辑卷中的数据;如果不配置的话,本机的其他服务也有可能会访问sdb逻辑卷中的数据
filter = [ "a/sdb/", "r/.*/"]
yum install openstack-cinder targetcli python-keystone -y
yum install python-openstackclient -y
[root@compute01 ~]# cp /etc/cinder/cinder.conf /etc/cinder/cinder.conf.bak
[root@compute01 ~]# grep -Ev '#|^$' /etc/cinder/cinder.conf.bak>/etc/cinder/cinder.conf
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf database connection mysql+pymysql://cinder:CINDER_DBPASS@192.168.112.146/cinder
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf DEFAULT transport_url rabbit://openstack:RABBIT_PASS@192.168.112.146
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf DEFAULT my_ip 192.168.112.145
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf DEFAULT enabled_backends lvm
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf DEFAULT glance_api_servers http://192.168.112.146:9292
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken www_authenticate_uri http://192.168.112.146:5000
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://192.168.112.146:5000
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers 192.168.112.146:11211
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_type password
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_domain_name default
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken user_domain_name default
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_name service
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken username cinder
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken password CINDER_PASS
#指定LVM驱动程序;即通过指定的驱动创建LVM
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf lvm volume_driver cinder.volume.drivers.lvm.LVMVolumeDriver
#指定卷组(vg)
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf lvm volume_group cinder-volumes
#pv使用的是iscsi协议,可以提供块存储服务
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf lvm target_protocol iscsi
#iscsi管理工具
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf lvm target_helper lioadm
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/cinder/tmp
[root@compute01 ~]# systemctl enable openstack-cinder-volume.service target.service
[root@compute01 ~]# systemctl start openstack-cinder-volume.service target.service
查看卷的列表:
[root@controller ~]# openstack volume service list
创建一个20 GB的卷:
[root@controller ~]# openstack volume create --size 20 volume1
[root@controller ~]# openstack volume list
openstack server add volume INSTANCE_NAME VOLUME_NAME
将volume1卷附加到firstVM实例:
[root@controller ~]# openstack server add volume firstVM volume1
再次查看openstack中的volume状态可以看到volume1已经attach到了实例上
[root@controller ~]# openstack volume list
通过Dashboard查看volume1的状态是可用,再通过界面的操作可以直接将volume1连接到实例firstVM中。想要验证该实例是否挂载了volume1,直接进入firstVM的控制台中,通过命令sudo fdisk -l命令可以查看到该实例挂载的卷。
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。