Cinder project of OpenStack deployment (7-8)

Cinder project of OpenStack deployment (7-8)

1. Configure Cinder on the CT control node

CT VM:192.168.10.101 NAT:192.168.221.101

1. Create a database instance and role

mysql -uroot -p

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';
flush privileges;
exit
Insert picture description here

2. Create users and modify configuration files

#创建cinder用户,密码设置为CINDER_PASS
openstack user create --domain default --password CINDER_PASS cinder			

#把cinder用户添加到service服务中,并授予admin权限
openstack role add --project service --user cinder admin

#cinder有v2和v3两个并存版本的API,所以需要创建两个版本的service实例
openstack service create --name cinderv2 --description "OpenStack Block Storage" volumev2
openstack service create --name cinderv3 --description "OpenStack Block Storage" volumev3	


给v2和v3版本的api创建endpoint
openstack endpoint create --region RegionOne volumev2 public http://ct:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne volumev2 internal http://ct:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne volumev2 admin http://ct:8776/v2/%\(project_id\)s
openstack endpoint create --region RegionOne volumev3 public http://ct:8776/v3/%\(project_id\)s
openstack endpoint create --region RegionOne volumev3 internal http://ct:8776/v3/%\(project_id\)s
openstack endpoint create --region RegionOne volumev3 admin http://ct:8776/v3/%\(project_id\)s
Insert picture description here


Insert picture description here
yum 安装cinder 服务
yum -y install openstack-cinder

修改cinder 配置文件
cp /etc/cinder/cinder.conf{,.bak}
grep -Ev '#|^$' /etc/cinder/cinder.conf.bak > /etc/cinder/cinder.conf

传参(倒数第二个传输的参数书需要改成ct节点的ip地址)
openstack-config --set /etc/cinder/cinder.conf database connection mysql+pymysql://cinder:[email protected]/cinder
openstack-config --set /etc/cinder/cinder.conf DEFAULT transport_url rabbit://openstack:[email protected]
openstack-config --set /etc/cinder/cinder.conf DEFAULT auth_strategy keystone
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken www_authenticate_uri http://ct:5000
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken auth_url http://ct:5000
openstack-config --set /etc/cinder/cinder.conf keystone_authtoken memcached_servers ct: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.10.101
openstack-config --set /etc/cinder/cinder.conf oslo_concurrency lock_path /var/lib/cinder/tmp


同步cinder数据库(填充块存储数据库)
su -s /bin/sh -c "cinder-manage db sync" cinder

修改 Nova 配置文件,并重启服务
openstack-config --set /etc/nova/nova.conf cinder os_region_name RegionOne
systemctl restart openstack-nova-api.service
Insert picture description here

3. Turn on the Cinder service

systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service

验证
cinder service-list
Insert picture description here


Insert picture description here

2. Configure Cinder (storage node) on compute node c2

C2 VM:192.168.10.103 NAT:192.168.221.103

yum -y install openstack-cinder targetcli python-keystone
yum -y install lvm2 device-mapper-persistent-data
systemctl enable lvm2-lvmetad.service
systemctl start lvm2-lvmetad.service

创建lvm物理卷和卷组
pvcreate /dev/sdb
vgcreate cinder-volumes /dev/sdb

修改lvm配置文件(指定使用sdb磁盘)
vim /etc/lvm/lvm.conf
#141行,取消注释,修改filter规则
filter = [ "a/sdb/","r/.*/" ]

# a表示允许,r表示拒绝 
# 只允许lvm服务访问sdb中的数据,不允许lvm服务访问其他磁盘,这也间接实现了openstack创建的虚拟机只能访问sdb中的数据,不能访问其他磁盘 
# 设置只允许实例访问sdb逻辑卷中的数据;如果不配置的话,本机的其他服务也有可能会访问sdc逻辑卷中的数据

重启lvm服务

systemctl restart lvm2-lvmetad.service
Insert picture description here


Insert picture description here

2. Configure the cinder module and start the cinder volume service

修改cinder.conf配置
cp /etc/cinder/cinder.conf{,.bak}
grep -Ev '#|^$' /etc/cinder/cinder.conf.bak>/etc/cinder/cinder.conf

传参(第四行注意修改成自己本机的ip)
openstack-config --set /etc/cinder/cinder.conf  database  connection mysql+pymysql://cinder:[email protected]/cinder
openstack-config --set /etc/cinder/cinder.conf  DEFAULT transport_url rabbit://openstack:[email protected]
openstack-config --set /etc/cinder/cinder.conf  DEFAULT auth_strategy keystone
openstack-config --set /etc/cinder/cinder.conf  DEFAULT my_ip 192.168.10.103
openstack-config --set /etc/cinder/cinder.conf  DEFAULT enabled_backends lvm
openstack-config --set /etc/cinder/cinder.conf  DEFAULT glance_api_servers http://ct:9292
openstack-config --set /etc/cinder/cinder.conf  keystone_authtoken www_authenticate_uri http://ct:5000
openstack-config --set /etc/cinder/cinder.conf  keystone_authtoken auth_url http://ct:5000
openstack-config --set /etc/cinder/cinder.conf  keystone_authtoken memcached_servers ct: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  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 target_protocol iscsi
openstack-config --set /etc/cinder/cinder.conf  lvm target_helper lioadm
openstack-config --set /etc/cinder/cinder.conf  oslo_concurrency lock_path /var/lib/cinder/tmp

选择性配置
vim /etc/cinder/cinder.conf
[lvm]
volume_backend_name=Openstack-lvm   			
#选择:当后端有多个不同类型的存储时,可以在openstack中调用指定的存储;
#给当前存储指定个名称,用于后期区分多个不同的存储

开启cinder卷服务

systemctl enable openstack-cinder-volume.service target.service
systemctl restart openstack-cinder-volume.service target.service
Insert picture description here


Insert picture description here

3. View the volume list on the CT node

CT VM:192.168.10.101 NAT:192.168.221.101

openstack volume service list
Insert picture description here

summary

Cinder configuration ideas:
create management and docking users, passwords, services and endpoints.
Modify configuration files: the
main content is to keystone docking authentication and authorization, communication modules between components, configuration domains, etc.
Configure the volume used by the virtual machine in the computing node