一、Cinder控制节点
1、创建Cinder数据库
mysql> CREATE DATABASE cinder;
mysql> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'localhost' \
IDENTIFIED BY 'cinder';
mysql> GRANT ALL PRIVILEGES ON cinder.* TO 'cinder'@'%' \
IDENTIFIED BY 'cinder';
mysql> flush privileges;
2、安装配置cinder
yum install openstack-cinder python-cinderclient nfs-utils
vim /etc/cinder/cinder.conf
[DEFAULT]
my_ip = 192.168.100.100
auth_strategy = keystone
log_dir = /var/log/cinder
state_path = /var/lib/cinder
glance_api_servers = http://controller:9292
transport_url = rabbit://openstack:openstack@controller
enabled_backends = lvm,nfs
[database]
connection = mysql+pymysql://cinder:cinder@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
[oslo_concurrency]
lock_path = /var/lib/cinder/tmp
[nfs]
nfs_shares_config=/etc/cinder/nfs_shares
nfs_mount_point_base = $state_path/mnt
nfs_sparsed_volumes=true
volume_driver=cinder.volume.drivers.nfs.NfsDriver
volume_backend_name=nfs01
vim /etc/nova/nova.conf
[cinder]
os_region_name = RegionOne
3、同步数据库:
su -s /bin/sh -c "cinder-manage db sync" cinder
4、创建Cinder的项目,角色,用户,注册Cinder的三种API
openstack user create --domain default --password=cinder cinder
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
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
5、启动服务:
systemctl restart openstack-nova-api.service #前面修改了nova配置文件要重启下nova-api
systemctl enable openstack-cinder-api.service openstack-cinder-scheduler.service
systemctl start openstack-cinder-api.service openstack-cinder-scheduler.service
二、Cinder存储节点
本示例在一台服务器上
1、安装配置LVM
yum install -y lvm2
systemctl enable lvm2-lvmetad.service
systemctl start lvm2-lvmetad.service
参考资料:https://www.mykernel.cn/archives/499
https://www.cnblogs.com/ssslinppp/p/5853312.html
2、nfs安装配置
yum install -y nfs-utils rpcbind
nfs-utils :包括基本的NFS命令与监控程序
rpcbind或portmap:支持安全NFS RPC服务的连接
lvcreate -L 50G -n cindervg cl #建lv
mkfs.xfs -f /dev/cl/cindervg #格式化
mkdir /cinder/data
mount /dev/cl/cindervg /cinder/data
vim /etc/fstab
配置NFS目录的访问权限、用户映射
vim /etc/exports
/cinder/data *(rw,no_root_squash)
chown cinder:cinder /cinder/data
chmod 777 /cinder/data
3、启动服务
systemctl enable rpcbind
systemctl enable nfs
systemctl restart rpcbind
systemctl restart nfs
4、配置
在/etc/cinder/nfs_shares文件中配置路径
vim /etc/cinder/nfs_shares
master:/cinder/data
权限设置
chown root:cinder /etc/cinder/nfs_shares
vim /etc/cinder/cinder.conf,在上面已经配置
[nfs]
nfs_shares_config=/etc/cinder/nfs_shares
nfs_sparsed_volumes=true
volume_driver=cinder.volume.drivers.nfs.NfsDriver
volume_backend_name=nfs
启动Cinder卷服务
systemctl enable openstack-cinder-volume.service target.service
systemctl restart openstack-cinder-api.service openstack-cinder-scheduler.service openstack-cinder-volume.service target.service