目录
1、OpenStack-cinder 组件部署
1.1、创建数据库实例和角色
[root@ct ~]# mysql -uroot -p123456
MariaDB [(none)]> CREATE DATABASE cinder;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY 'CINDER_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' IDENTIFIED BY 'CINDER_DBPASS';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> show databases;
MariaDB [(none)]> exit
1.2、创建用户、修改配置文件
1.2.1、创建cinder用户,密码设置为CINDER_PASS
[root@ct ~]# openstack user create --domain default --password CINDER_PASS cinder
1.2.2、把cinder用户添加到service服务中,并授予admin权限
[root@ct ~]# openstack role add --project service --user cinder admin
1.2.3、cinder有v2和v3两个并存版本的API,所以需要创建两个版本的service实例
[root@ct ~]# openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
[root@ct ~]# openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3
1.2.4、给v2和v3版本的api创建endpoint
[root@ct ~]# openstack endpoint create --region RegionOne volumev2 public http://ct:8776/v2/%\(project_id\)s
[root@ct ~]# openstack endpoint create --region RegionOne volumev2 internal http://ct:8776/v2/%\(project_id\)s
[root@ct ~]# openstack endpoint create --region RegionOne volumev2 admin http://ct:8776/v2/%\(project_id\)s
[root@ct ~]# openstack endpoint create --region RegionOne volumev3 public http://ct:8776/v3/%\(project_id\)s
[root@ct ~]# openstack endpoint create --region RegionOne volumev3 internal http://ct:8776/v3/%\(project_id\)s
[root@ct ~]# openstack endpoint create --region RegionOne volumev3 admin http://ct:8776/v3/%\(project_id\)s
1.3、yum 安装cinder 服务
[root@ct ~]# yum -y install openstack-cinder
1.3.1、修改cinder 配置文件
[root@ct ~]# cp /etc/cinder/cinder.conf{
,.bak}
[root@ct ~]# grep -Ev '#|^$' /etc/cinder/cinder.conf.bak>/etc/cinder/cinder.conf
[root@ct ~]# openstack-config --set /etc/cinder/cinder.conf database connection mysql+pymysql://cinder:CINDER_DBPASS@ct/cinder
[root@ct ~]# openstack-config --set /etc/cinder/cinder.conf DEFAULT transport_url rabbit://openstack:RABBIT_PASS@ct
[root@ct ~]# openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
[root@ct ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken www_authenticate_uri http://ct:5000
[root@ct ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://ct:5000
[root@ct ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers ct:11211
[root@ct ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_type password
[root@ct ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_domain_name default
[root@ct ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken user_domain_name default
[root@ct ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken project_name service
[root@ct ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken username cinder
[root@ct ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken password CINDER_PASS
[root@ct ~]# openstack-config --set /etc/cinder/cinder.conf DEFAULT my_ip 192.168.74.11
[root@ct ~]# openstack-config --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/cinder/tmp
[root@ct ~]# cd /etc/cinder/
[root@ct cinder]# cat cinder.conf
[DEFAULT]
transport_url = rabbit://openstack:RABBIT_PASS@ct #配置rabbitmq连接
auth_strategy = keystone #认证方式
my_ip = 192.168.74.11 #内网IP
[backend]
[backend_defaults]
[barbican]
[brcd_fabric_example]
[cisco_fabric_example]
[coordination]
[cors]
[database] #对接数据库
connection = mysql+pymysql://cinder:CINDER_DBPASS@ct/cinder
[fc-zone-manager]
[healthcheck]
[key_manager]
[keystone_authtoken] #配置keystone认证信息
www_authenticate_uri = http://ct:5000 #keystone地址
auth_url = http://ct:5000
memcached_servers = ct:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder #指定通过cinder账号到keystone做认证(用户名、密码)
password = CINDER_PASS
[nova]
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp #配置锁路径
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_middleware]
[oslo_policy]
[oslo_reports]
[oslo_versionedobjects]
[privsep]
[profiler]
[sample_castellan_source]
[sample_remote_file_source]
[service_user]
[ssl]
[vault]
1.3.2、同步cinder数据库(填充块存储数据库)
[root@ct ~]# su -s /bin/sh -c "cinder-manage db sync" cinder
1.3.3、修改 Nova 配置文件,并重启服务
[root@ct ~]# openstack-config --set /etc/nova/nova.conf cinder os_region_name RegionOne
[root@ct ~]# systemctl restart openstack-nova-api.service
1.3.4、配置Cinder服务
[root@ct ~]# systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
[root@ct ~]# systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
1.3.5、配置控制节点验证
[root@ct ~]# cinder service-list
1.4、在计算节点c2配置Cinder(存储节点)
[root@c2 ~]# yum -y install openstack-cinder targetcli python-keystone
[root@c2 ~]# yum -y install lvm2 device-mapper-persistent-data
[root@c2 ~]# systemctl enable lvm2-lvmetad.service
[root@c2 ~]# systemctl start lvm2-lvmetad.service
1.4.1、创建lvm物理卷和卷组(新建一块硬盘,并重启)
[root@c2 ~]# pvcreate /dev/sdc
Physical volume "/dev/sdc" successfully created.
[root@c2 ~]# vgcreate cinder-volumes /dev/sdc
Volume group "cinder-volumes" successfully created
1.4.2、修改lvm配置文件(指定使用sdc磁盘)
[root@c2 ~]# vim /etc/lvm/lvm.conf
141行,取消,
# a表示允许,r表示拒绝
# 只允许lvm服务访问sdc中的数据,不允许lvm服务访问其他磁盘,这也间接实现了openstack创建的虚拟机只能访问sdb中的数据,不能访问其他磁盘
# 设置只允许实例访问sdc逻辑卷中的数据;如果不配置的话,本机的其他服务也有可能会访问sdc逻辑卷中的数据
1.4.3、重启lvm服务
[root@c2 ~]# systemctl restart lvm2-lvmetad.service
1.4.4、配置cinder模块
[root@c2 ~]# cp /etc/cinder/cinder.conf{
,.bak}
[root@c2 ~]# 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@ct/cinder
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf DEFAULT transport_url rabbit://openstack:RABBIT_PASS@ct
[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.74.13
[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://ct:9292
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken www_authenticate_uri http://ct:5000
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://ct:5000
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers ct: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
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf lvm volume_driver cinder.volume.drivers.lvm.LVMVolumeDriver
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf lvm volume_group cinder-volumes
[root@c2 ~]# openstack-config --set /etc/cinder/cinder.conf lvm target_protocol 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@c2 ~]# cd /etc/cinder/
[root@c2 cinder]# cat cinder.conf
[DEFAULT]
transport_url = rabbit://openstack:RABBIT_PASS@ct
auth_strategy = keystone
my_ip = 192.168.74.13
enabled_backends = lvm
glance_api_servers = http://ct:9292
[backend]
[backend_defaults]
[barbican]
[brcd_fabric_example]
[cisco_fabric_example]
[coordination]
[cors]
[database]
connection = mysql+pymysql://cinder:CINDER_DBPASS@ct/cinder
[fc-zone-manager]
[healthcheck]
[key_manager]
[keystone_authtoken]
www_authenticate_uri = http://ct:5000
auth_url = http://ct:5000
memcached_servers = ct:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = cinder
password = CINDER_PASS
[nova]
[oslo_concurrency] #配置锁路径
lock_path = /var/lib/cinder/tmp
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_middleware]
[oslo_policy]
[oslo_reports]
[oslo_versionedobjects]
[privsep]
[profiler]
[sample_castellan_source]
[sample_remote_file_source]
[service_user]
[ssl]
[vault]
[lvm] #为LVM后端配置LVM驱动程序
volume_driver = cinder.volume.drivers.lvm.LVMVolumeDriver #指定LVM驱动程序;即通过指定的驱动创建LVM
volume_group = cinder-volumes #指定卷组(vg)
target_protocol = iscsi #pv使用的是iscsi协议,可以提供块存储服务
target_helper = lioadm #iscsi管理工具
#volume_backend_name=Openstack-lvm #选择:当后端有多个不同类型的存储时,可以在openstack中调用指定的存储;
给当前存储指定个名称,用于后期区分多个不同的存储
1.4.5、开启cinder卷服务
[root@c2 ~]# systemctl enable openstack-cinder-volume.service target.service
[root@c2 ~]# systemctl start openstack-cinder-volume.service target.service
1.4.6、查看卷列表
[root@ct ~]# openstack volume service list
2、小结
1、Cinder配置思路:
创建管理、对接的用户、密码、服务和endpoint
2、修改配置文件:
主要内容为 向keystone对接认证授权、组件之间通讯模块、配置所在的域等
3、配置计算节点中虚拟机所用的卷