创建3个卷p_w_picpathsvolumesinstances分别对接openstackglancecindernova组件

p_w_picpaths卷用于存放OpenStack镜像

volumes卷用于存放OpenStack硬盘

instances卷用于存放OpenStack云主机

1、  创建卷

gluster volume create p_w_picpaths replica 3 \
controller1:/data/brick1/p_w_picpath  controller2:/data/brick1/p_w_picpath  compute01:/data/brick1/p_w_picpath \
controller1:/data/brick2/p_w_picpath  controller2:/data/brick2/p_w_picpath  compute01:/data/brick2/p_w_picpath \
controller1:/data/brick3/p_w_picpath  controller2:/data/brick3/p_w_picpath  compute01:/data/brick3/p_w_picpath
 
gluster volume create volumes replica 3 \
controller1:/data/brick1/volume  controller2:/data/brick1/volume  compute01:/data/brick1/volume \
controller1:/data/brick2/volume  controller2:/data/brick2/volume  compute01:/data/brick2/volume \
controller1:/data/brick3/volume  controller2:/data/brick3/volume  compute01:/data/brick3/volume
 
gluster volume create instances replica 3 \
controller1:/data/brick1/instance  controller2:/data/brick1/instance  compute01:/data/brick1/instance \
controller1:/data/brick2/instance  controller2:/data/brick2/instance  compute01:/data/brick2/instance \
controller1:/data/brick3/instance  controller2:/data/brick3/instance  compute01:/data/brick3/instance

2、  启动卷

gluster volume start p_w_picpaths
gluster volume start volumes
gluster volume start instances

3、  添加p_w_picpathsinstancesfstab自动挂载

controller1:/p_w_picpaths   /var/lib/glance/p_w_picpaths   glusterfs  defaults,_netdev,backupvolfile-server=controller2,backupvolfile-server=compute01   0 0
controller1:/instances   /var/lib/nova/instances   glusterfs  defaults,_netdev,backupvolfile-server=controller2,backupvolfile-server=compute01   0 0

GlusterFS作为OpenStack后端存储_第1张图片

mount  -a 挂载

上述挂载方式使用backupvolfile起到了高可用性,避免单点故障

novaglance节点要挂载到instancesp_w_picpaths的相关目录,根据实际服务部署情况调整,cinder不太一样,下边会说到。

 4、  设置相关权限

chown -R nova.nova /var/lib/nova/instances
chown -R glance.glance/var/lib/glance/p_w_picpaths
chown -R nova:nova /data/brick1/instance
chown -R nova:nova /data/brick2/instance
chown -R nova:nova /data/brick3/instance
chown -R glance:glance /data/brick1/p_w_picpath
chown -R glance:glance /data/brick2/p_w_picpath
chown -R glance:glance /data/brick3/p_w_picpath
chown -R cinder:cinder /data/brick1/volume
chown -R cinder:cinder /data/brick2/volume
chown -R cinder:cinder /data/brick3/volume

nova要有instancecinder要有volumeglance要有p_w_picpath的读写权限,根据节点上的服务,给相应的权限。

5、  配置cinder

cp /etc/cinder/cinder.conf{,.bak}
openstack-config --set/etc/cinder/cinder.conf DEFAULT volume_drivercinder.volume.drivers.glusterfs.GlusterfsDriver
openstack-config --set/etc/cinder/cinder.conf DEFAULT glusterfs_shares_config /etc/cinder/shares.conf
openstack-config --set /etc/cinder/cinder.confDEFAULT glusterfs_mount_point_base /var/lib/cinder/volumes

touch /etc/cinder/shares.conf
vim /etc/cinder/shares.conf  #添加以下内容
controller1:/volumes
controller2:/volumes
compute01:/volumes

#设置相关权限

chown -R cinder.cinder/etc/cinder/shares.conf
chown -R cinder:cinder /var/lib/cinder/*

6、  重启openstack相关服务

openstack-service restart nova
openstack-service restart cinder
openstack-service restart glance

7、  验证cinder

GlusterFS作为OpenStack后端存储_第2张图片