# pvcreate /dev/sda
# pvdisplay
--- Physical volume ---
PV Name /dev/vda2
VG Name centos
PV Size 99.51 GiB / not usable 3.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 25474
Free PE 16
Allocated PE 25458
PV UUID riLhOd-VTF3-soV7-2mqC-Epk9-zAM6-zQZHqg
--- Physical volume ---
PV Name /dev/sda
VG Name cinder-volumes
PV Size 10.00 GiB / not usable 4.00 MiB
Allocatable yes
PE Size 4.00 MiB
Total PE 2559
Free PE 2559
Allocated PE 0
PV UUID qs5MVX-c567-Kl7w-59uQ-1f7l-ufxv-mOBy8n
在新创建的物理卷上创建cinder-volume卷组
# vgcreate cinder-volumes /dev/sda
# vgdisplay
--- Volume group ---
VG Name centos
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 4
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 3
Open LV 3
Max PV 0
Cur PV 1
Act PV 1
VG Size 99.51 GiB
PE Size 4.00 MiB
Total PE 25474
Alloc PE / Size 25458 / 99.45 GiB
Free PE / Size 16 / 64.00 MiB
VG UUID neZcsa-uyAa-Qh1U-0RST-vMKw-fizT-9mhdlC
--- Volume group ---
VG Name cinder-volumes
System ID
Format lvm2
Metadata Areas 1
Metadata Sequence No 20
VG Access read/write
VG Status resizable
MAX LV 0
Cur LV 0
Open LV 0
Max PV 0
Cur PV 1
Act PV 1
VG Size 10.00 GiB
PE Size 4.00 MiB
Total PE 2559
Alloc PE / Size 0 / 0
Free PE / Size 2559 / 10.00 GiB
VG UUID nVNcsk-SU7J-vmfo-4blS-HiHS-mdeU-22ukmP
Kolla-ansible配置
设置配置文件
# vim /etc/kolla/globals.yml
enable_cinder: "yes"
enable_cinder_backend_lvm: "yes"
### cinder-volume.log日志报错
"/usr/bin/truncate: cannot open `/var/lib/cinder/mnt/dd5f51c5ed990be3eb68a9e9b6099eb4/volume-e3e2c8e1-66fa-4dda-a7a7-9c68514d596a' for writing: Permission denied\n"
查看下目录权限
# docker exec -it cinder_volume bash
$ ls -la /var/lib/cinder/mnt
total 0
drwxr-xr-x 3 cinder kolla 45 Mar 1 04:52 .
drwxrwsr-x 5 cinder kolla 109 Mar 1 05:06 ..
drwxr-xr-x 2 root root 56 Mar 1 05:04 dd5f51c5ed990be3eb68a9e9b6099eb4
### 发现目录是root权限,所以`truncate`命令会执行失败,这边产生的原因是我之前的nfs服务器的配置文件内容是:/kolla_nfs 92.0.0.0/24(rw,sync,no_root_squash),并且这个目录是使用root用户创建的,使用普通用户创建,然后修改配置文件,重启nfs服务,并修改cinder-volume对应的nfs_shares配置文件,并重启容器即可解决问题
Given a sorted linked list, delete all nodes that have duplicate numbers, leaving only distinct numbers from the original list.
For example,Given 1->2->3->3->4->4->5,