kolla-ansible安装cinder
LVM后端
环境拓扑
节点 | IP | 主机名 |
---|---|---|
Controller/Network/Apollo | 92.0.0.11 | anode |
Compute/Storage | 92.0.0.12 | bnode |
multinode配置如下
[control]
92.0.0.11
[network]
92.0.0.11
[compute]
92.0.0.12
[monitoring]
92.0.0.11
[storage]
92.0.0.12
[apollo]
92.0.0.11
[extend]
92.0.0.10
Storage节点配置
新增磁盘(虚拟机直接添加磁盘、物理机使用losetup模拟),然后创建物理卷PV
# 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"
部署
# kolla-ansible -i multinode bootstrap-servers
# kolla-ansible -i multinode deploy
流程
### 创建卷流程
- cinder-volume服务使用"sudo cinder-rootwrap /etc/cinder/rootwrap.conf env LC_ALL=C lvcreate -n volume-03753745-933c-4f53-9e36-e90f13963aa5 cinder-volumes -L 1g"命令在cinder-volumes卷组上创建一个逻辑卷LV
### 卷挂载流程
- cinder-volume服务首先创建卷的iscsi target配置文件"/var/lib/cinder/volumes/volume-03753745-933c-4f53-9e36-e90f13963aa5",文件内如如下:
<target iqn.2010-10.org.openstack:volume-03753745-933c-4f53-9e36-e90f13963aa5>
backing-store /dev/cinder-volumes/volume-03753745-933c-4f53-9e36-e90f13963aa5
driver iscsi
incominguser VbUHhzgSqYxDEdo8rtU5 hxsbZiw3HaSWc55h
write-cache on
</target>
- 然后cinder-volume服务使用"sudo cinder-rootwrap /etc/cinder/rootwrap.conf tgt-admin --update iqn.2010-10.org.openstack:volume-03753745-933c-4f53-9e36-e90f13963aa5"命令创建iscsi target(服务端配置完成)
- 首先nova-libvirt服务使用iscsi客户端命令"iscsiadm -m node -T iqn.2010-10.org.openstack:volume-03753745-933c-4f53-9e36-e90f13963aa5 -p 92.0.0.12:3260 --interface default --op new"创建iscsi node(连接目标)
- 然后使用如下命令设置连接验证
- "iscsiadm -m node -T iqn.2010-10.org.openstack:volume-03753745-933c-4f53-9e36-e90f13963aa5 -p 92.0.0.12:3260 --op update -n node.session.auth.authmethod -v CHAP"
- "iscsiadm -m node -T iqn.2010-10.org.openstack:volume-03753745-933c-4f53-9e36-e90f13963aa5 -p 92.0.0.12:3260 --op update -n node.session.auth.username -v VbUHhzgSqYxDEdo8rtU5"
- "iscsiadm -m node -T iqn.2010-10.org.openstack:volume-03753745-933c-4f53-9e36-e90f13963aa5 -p 92.0.0.12:3260 --op update -n node.session.auth.password -v ***"
- 接着使用"iscsiadm -m node -T iqn.2010-10.org.openstack:volume-03753745-933c-4f53-9e36-e90f13963aa5 -p 92.0.0.12:3260 --login"命令连接iscsi target(客户端配置完成)
- 最后生成"attach device xml",然后使用virsh命令添加磁盘,xml文件内容如下:
<disk type="block" device="disk">
<driver name="qemu" type="raw" cache="none" io="native"/>
<source dev="/dev/disk/by-path/ip-92.0.0.12:3260-iscsi-iqn.2010-10.org.openstack:volume-03753745-933c-4f53-9e36-e90f13963aa5-lun-1"/>
<target bus="virtio" dev="vdb"/>
<serial>03753745-933c-4f53-9e36-e90f13963aa5</serial>
</disk>
问题处理
- 卷挂载失败
### nova-compute.log日志报错
2018-02-10 20:37:26.158 5 ERROR oslo_messaging.rpc.server File "/var/lib/kolla/venv/lib/python2.7/site-packages/os_brick/initiator/connectors/iscsi.py", line 405, in connect_volume
2018-02-10 20:37:26.158 5 ERROR oslo_messaging.rpc.server connection_properties)
2018-02-10 20:37:26.158 5 ERROR oslo_messaging.rpc.server File "/var/lib/kolla/venv/lib/python2.7/site-packages/os_brick/initiator/connectors/iscsi.py", line 236, in _get_potential_volume_paths
2018-02-10 20:37:26.158 5 ERROR oslo_messaging.rpc.server raise exception.FailedISCSITargetPortalLogin(message=msg)
2018-02-10 20:37:26.158 5 ERROR oslo_messaging.rpc.server FailedISCSITargetPortalLogin: Could not login to any iSCSI portal.
进到nova_compute容器,执行iscsiadm -m discovery -t sendtargets -p 92.0.0.12
命令无法发现目标,且发现iscsid容器服务异常,所以先验证下iscsi target服务是否有异常,停掉iscsid和nova_compute容器,然后在宿主机器上安装iscsi客户端
# yum install iscsi-initiator-utils.x86_64 -y
发现并连接iscsi target
# iscsiadm -m discovery -t sendtargets -p 92.0.0.12
# iscsiadm -m node -T iqn.2010-10.org.openstack:volume-17876f1f-d28d-4ecb-aa86-ec0b7545e20b -p 92.0.0.12 -l
发现是可以正常连接的,说明服务端不存在问题,然后我们来验证下客户端,首先启动iscsid容器,然后在容器中执行下面操作
# iscsiadm -m discovery -t sendtargets -p 92.0.0.12
# iscsiadm -m node -T iqn.2010-10.org.openstack:volume-17876f1f-d28d-4ecb-aa86-ec0b7545e20b -p 92.0.0.12 -l
发现也是没有问题的,我们再把nova_compute容器启动起来,然后在nova_compute容器中执行下面操作
# iscsiadm -m discovery -t sendtargets -p 92.0.0.12
会发现命令卡住,无显示结果,这个时候我们还没发断定是iscsid容器的问题,还是nova-compute容器的问题,所以先停掉iscsid容器,然后在宿主机上启动iscsid服务(放在前端运行,方便看日志输出),然后继续在nova_compute容器中执行下面命令
# iscsiadm -m discovery -t sendtargets -p 92.0.0.12
会发现iscsid服务发生异常,同时nova_compute容器中执行的命令再次卡住,这时候说明nova_compute容器存在问题,最后发现nova-compute容器的iscsi客户端很久没有更新,而iscsid容器的客户端是最新的,怀疑是版本问题导致的异常,更新nova-compute容器的iscsi客户端版本后异常得到解决
NFS后端
环境拓扑
节点 | IP | 主机名 |
---|---|---|
Controller/Network/Apollo | 92.0.0.11 | anode |
Compute/Storage | 92.0.0.12 | bnode |
NFS | 92.0.0.13 | cnode |
multinode配置如下
[control]
92.0.0.11
[network]
92.0.0.11
[compute]
92.0.0.12
[monitoring]
92.0.0.11
[storage]
92.0.0.12
[apollo]
92.0.0.11
[extend]
92.0.0.10
NFS节点配置
安装服务
# yum install nfs-utils -y
设置配置文件
### 注意不能使用root用户创建的目录,否则后面cinder-volume创建卷时会出现Permission denied
$ mkdir -p /home/kolla/nfs
# tee /etc/exports << EOF
/home/kolla/nfs 92.0.0.0/24(rw,sync,insecure,no_root_squash)
EOF
启动服务
# systemctl enable nfs
# systemctl start nfs
验证NFS系统
# showmount -e 92.0.0.13
Export list for 92.0.0.13:
/kolla_nfs 92.0.0.0/24
Kolla-ansible配置
设置配置文件
# mkdir -p /etc/kolla/config
# tee /etc/kolla/config/nfs_shares.j2 << EOF
92.0.0.13:/home/kolla/nfs
EOF
# vim /etc/kolla/globals.yml
enable_cinder: "yes"
enable_cinder_backend_nfs: "yes"
部署
# kolla-ansible -i multinode bootstrap-servers
# kolla-ansible -i multinode deploy
流程
### 挂载流程
- cinder-volume服务会在/var/lib/cinder下创建一个目录用来挂载
- 读取/etc/cinder/nfs_shares中的nfs服务器信息,然后使用"sudo cinder-rootwrap /etc/cinder/rootwrap.conf mount -t nfs -o vers=4,minorversion=1 92.0.0.13:/home/kolla/nfs /var/lib/cinder/mnt/dd5f51c5ed990be3eb68a9e9b6099eb4"命令将其挂载到上面的目录
### 创建卷流程
- 使用"sudo cinder-rootwrap /etc/cinder/rootwrap.conf truncate -s 1G /var/lib/cinder/mnt/dd5f51c5ed990be3eb68a9e9b6099eb4/volume-cd53f360-1a42-480d-a059-424ebeac6509"命令创建对应大小的文件
### 卷挂载流程
- nova-libvirt根据创建的卷文件生成"attach device xml",然后使用virsh命令添加磁盘,xml文件内容如下:
<disk type="file" device="disk">
<driver name="qemu" type="raw" cache="none" io="native"/>
<source file="/var/lib/nova/mnt/dd5f51c5ed990be3eb68a9e9b6099eb4/volume-cd53f360-1a42-480d-a059-424ebeac6509"/>
<target bus="virtio" dev="vdb"/>
<serial>cd53f360-1a42-480d-a059-424ebeac6509</serial>
</disk>
问题处理
- 卷创建失败
### 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配置文件,并重启容器即可解决问题
ISCSI后端
目前仅支持Hitachi storage volume driver