当你的openstack主机没有可用空间了,而你又不能添加硬盘,或许nfs服务可以帮到你。
目标:
用nfs作为nove的后端存储。
过程:
运行一个可用的nfs服务:
[root@controller ~]# showmount -e 192.168.100.10
Export list for controller:
/nfs *
查看openstack当前nova的后端存储位置:
我修改了默认云主机存储路径
[root@node1 ~]# cat /etc/nova/nova.conf | grep instances_path | grep -v "#"
instances_path=/data/nova/instances
如果是下面这样:
[root@controller ~]# cat /etc/nova/nova.conf | grep "instances_path"
#instances_path=$state_path/instances
那么就是默认路径:/var/lib/nova/instances
找到了路径就简单了,挂载nfs到后端路径:
[root@node1 ~]# mount -t nfs 192.168.100.10:/nfs /data/nova/instances/
设置目录属性:
[root@node1 ~]# chown -R nova:nova /data/nova/instances/
验证:
重启openstack-nova-compute服务
创建一个虚拟机,查看ID:
[root@node1 ~]# nova boot --image cirros --flavor 1 --nic net-name=sharednet1 cirros
[root@node1 ~]# nova list
+--------------------------------------+--------+--------+------------+-------------+---------------------+
| ID | Name | Status | Task State | Power State | Networks |
+--------------------------------------+--------+--------+------------+-------------+---------------------+
| f684f8df-3526-4a6b-bc21-f9a67ed4b9f0 | cirros | ACTIVE | - | Running | sharednet1=10.0.0.9 |
+--------------------------------------+--------+--------+------------+-------------+---------------------+
查看云主机所在目录:
[root@node1 ~]# ll /data/nova/instances/
total 0
drwxr-xr-x. 2 nova nova 53 May 17 11:24 _base
drwxr-xr-x. 2 nova nova 69 May 17 11:36 f684f8df-3526-4a6b-bc21-f9a67ed4b9f0
drwxr-xr-x. 2 nova nova 58 May 17 11:24 locks
到nfs服务端查看:
[root@controller ~]# ll -d /nfs/
drwxr-xr-x. 6 nova nova 89 May 17 07:36 /nfs/
[root@controller ~]# ll /nfs/
total 0
drwxr-xr-x. 2 nova nova 53 May 17 07:24 _base
drwxr-xr-x. 2 nova nova 69 May 17 07:36 f684f8df-3526-4a6b-bc21-f9a67ed4b9f0
drwxr-xr-x. 2 nova nova 58 May 17 07:24 locks
成功!