openstack配置nfs作为cinder后端存储 2019-
2019-05-17 本文已影响3人
我是布谷鸟
目标:
更改cinder后端存储为nfs:
过程:
nfs服务端配置:
[root@controller ~]# cat /etc/exports
/nfs *(rw,no_root_squash,insecure)
查看nfs驱动名称:
class后面的NfsDriver便是。
[root@controller ~]# grep Nfs /usr/lib/python2.7/site-packages/cinder/volume/drivers/nfs.py
class NfsDriver(driver.ExtendVD, remotefs.RemoteFSDriver):
super(NfsDriver, self).__init__(*args, **kwargs)
super(NfsDriver, self).do_setup(context)
raise exception.NfsException(msg)
raise exception.NfsException(msg)
raise exception.NfsException(msg)
raise exception.NfsException(six.text_type(e))
raise exception.NfsNoSharesMounted()
raise exception.NfsNoSuitableShareFound(
raise exception.NfsNoSharesMounted()
super(NfsDriver, self)._update_volume_stats()
修改cinder配置文件:
[root@node1 ~]# vi /etc/cinder/cinder.conf
[DEFAULT]
rpc_backend = rabbit
auth_strategy = keystone
my_ip = 127.0.0.1
enabled_backends = nfs(原来是lvm)
glance_api_servers = http://node1:9292
添加以下内容:
[nfs]
volume_driver = cinder.volume.drivers.nfs.NfsDriver(nfs驱动:cinder/volume/drivers/nfs.py NfsDriver)
nfs_shares_config = /etc/cinder/nfs_shares(nfs配置文件)
nfs_mount_point_base = $state_path/mnt
[root@node1 ~]# cat /etc/cinder/nfs_shares
192.168.100.10:/nfs
[root@node1 ~]# ll /etc/cinder/nfs_shares
-rw-r-----. 1 root cinder 20 May 18 06:07 /etc/cinder/nfs_shares
重启服务:
[root@node1 ~]# systemctl restart openstack-cinder-volume
验证
cinder服务列表:
[root@node1 ~]# cinder service-list
+------------------+--------------+------+---------+-------+----------------------------+-----------------+
| Binary | Host | Zone | Status | State | Updated_at | Disabled Reason |
+------------------+--------------+------+---------+-------+----------------------------+-----------------+
| cinder-scheduler | node1 | nova | enabled | up | 2019-05-18T06:16:07.000000 | - |
| cinder-volume | node1@lvm | nova | enabled | down | 2019-05-18T05:58:43.000000 | - |
| cinder-volume | node1@nfs | nova | enabled | up | 2019-05-18T06:16:12.000000 | - |
+------------------+--------------+------+---------+-------+----------------------------+-----------------+
测试
创建的云硬盘:
[root@node1 ~]# cinder list
+--------------------------------------+-----------+------+------+-------------+----------+-------------+
| ID | Status | Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+------+------+-------------+----------+-------------+
| 6c80d19a-eda5-4719-b1eb-704e04ccdde1 | available | test | 1 | - | false | |
+--------------------------------------+-----------+------+------+-------------+----------+-------------+
[root@node1 ~]# df -hT
Filesystem Type Size Used Avail Use% Mounted on
/dev/vda1 xfs 41G 2.4G 39G 6% /
devtmpfs devtmpfs 3.9G 0 3.9G 0% /dev
tmpfs tmpfs 3.9G 4.0K 3.9G 1% /dev/shm
tmpfs tmpfs 3.9G 17M 3.9G 1% /run
tmpfs tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/loop0 xfs 2.8G 33M 2.8G 2% /swift/node
tmpfs tmpfs 799M 0 799M 0% /run/user/0
192.168.100.10:/nfs nfs4 250G 47G 204G 19% /var/lib/cinder/mnt/9721d8468baf04c147d34d153e1e77b2
成功