OpenStack实战十四——Cinder与不同存储类型集成

1. 环境准备

1.1 安装NFS软件包

[root@linux-node2 ~]# yum install -y nfs-utils rpcbind

1.2 配置NFS

创建NFS目录并配置

[root@linux-node2 ~]# mkdir -p /data/nfs        
[root@linux-node2 ~]# cat /etc/exports      
/data/nfs *(rw,no_root_squash)

1.3 启动NFS服务

[root@linux-node2 ~]# systemctl restart rpcbind
[root@linux-node2 ~]# systemctl restart nfs

                                        

2. Cinder配置NFS存储

2.1 编辑/etc/cinder/cinder.conf添加NFS配置

[root@linux-node2 ~]# grep enabled_backends /etc/cinder/cinder.conf
enabled_backends = lvm,nfs      #添加nfs支持

[nfs]
volume_driver = cinder.volume.drivers.nfs.NfsDriver
nfs_shares_config = /etc/cinder/nfs_shares  #配置NFS目录地址
nfs_mount_point_base = /data/mnt        #配置NFS挂载点,默认挂载点在/var/lib/cinder/mnt目录下
volume_backend_name=NFS-Storage         #命名

#NFS驱动位置
[root@linux-node2 ~]# grep -w "NfsDriver" /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)
    super(NfsDriver, self)._update_volume_stats()

#查看NFS挂载
[root@linux-node2 ~]# mount |grep nfs
sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
nfsd on /proc/fs/nfsd type nfsd (rw,relatime)
192.168.56.12:/data/nfs on /data/mnt/58567ffce11e4e19b172d02380b7eb4d type nfs4 (rw,relatime,vers=4.1,rsize=1048576,wsize=1048576,namlen=255,hard,proto=tcp,port=0,timeo=600,retrans=2,sec=sys,clientaddr=192.168.56.12,local_lock=none,addr=192.168.56.12)

2.2 查看cinder卷服务

[root@linux-node1 ~]# cinder service-list
+------------------+-----------------------------+------+---------+-------+----------------------------+-----------------+
|      Binary      |             Host            | Zone |  Status | State |         Updated_at         | Disabled Reason |
+------------------+-----------------------------+------+---------+-------+----------------------------+-----------------+
| cinder-scheduler |   linux-node1.example.com   | nova | enabled |   up  | 2017-04-29T07:14:34.000000 |        -        |
|  cinder-volume   |   linux-node1.example.com   | nova | enabled |  down | 2017-04-29T06:18:38.000000 |        -        |
|  cinder-volume   | linux-node2.example.com@lvm | nova | enabled |   up  | 2017-04-29T07:14:35.000000 |        -        |
|  cinder-volume   | linux-node2.example.com@nfs | nova | enabled |   up  | 2017-04-29T07:14:36.000000 |        -        |
+------------------+-----------------------------+------+---------+-------+----------------------------+-----------------+

2.3 Cinder创建卷类型

  • 创建lvm、nfs卷类型

    [root@linux-node1 ~]# cinder type-create lvm
    +--------------------------------------+------+-------------+-----------+
    |                  ID                  | Name | Description | Is_Public |
    +--------------------------------------+------+-------------+-----------+
    | 43444617-70d4-48b9-bc7a-3eb769e7b46c | lvm  |      -      |    True   |
    +--------------------------------------+------+-------------+-----------+
    [root@linux-node1 ~]# cinder type-create nfs
    +--------------------------------------+------+-------------+-----------+
    |                  ID                  | Name | Description | Is_Public |
    +--------------------------------------+------+-------------+-----------+
    | 55eed16c-0fda-4369-9b87-8b81058b7dea | nfs  |      -      |    True   |
    +--------------------------------------+------+-------------+-----------+
  • 关联卷类型(通过volume_backend_name)

    [root@linux-node1 ~]# cinder type-key lvm set volume_backend_name=iSCSI-Storage
    [root@linux-node1 ~]# cinder type-key nfs set volume_backend_name=NFS-Storage

2.4 添加NFS云硬盘

  • 查看云硬盘源文件

    [root@linux-node2 ~]# cd /data/nfs/
    [root@linux-node2 nfs]# ls
    volume-a1a514d8-5ed9-49ad-90b0-ed6aa7139477
    [root@linux-node2 nfs]# qemu-img info volume-a1a514d8-5ed9-49ad-90b0-ed6aa7139477
    image: volume-a1a514d8-5ed9-49ad-90b0-ed6aa7139477
    file format: raw
    virtual size: 1.0G (1073741824 bytes)
    disk size: 0
  • 查看云硬盘挂载文件

    [root@linux-node2 mnt]# cd /data/mnt/ && ls -lh
    total 0
    drwxr-xr-x 2 root root 56 Apr 29 15:30 58567ffce11e4e19b172d02380b7eb4d
  • 登陆云主机查看挂载的NFS盘

OpenStack实战十四——Cinder与不同存储类型集成

OpenStack实战十四——Cinder与不同存储类型集成

OpenStack实战十四——Cinder与不同存储类型集成

OpenStack实战十四——Cinder与不同存储类型集成                                                                

3. Cinder与多种后端技术集成(Ceph、GlusterFS)

参考:https://wiki.openstack.org/wiki/Howtodeploy_cinderwithNFS


anzhihe 安志合个人博客,版权所有 丨 如未注明,均为原创 丨 转载请注明转自:https://chegva.com/2122.html | ☆★★每天进步一点点,加油!★★☆ | 

您可能还感兴趣的文章!

5 评论

  1. 你好,我参考你的配置实用nfs作为cinder卷,日志有如下报错:
    May 25 02:15:07 linux-node2 cinder-volume: 2017-05-25 02:15:07.426 2361 ERROR cinder.volume.manager File "/usr/lib/python2.7/site-packages/cinder/volume/drivers/nfs.py", line 340, in set_nas_security_options
    May 25 02:15:09 linux-node2 cinder-volume: 2017-05-25 02:15:09.686 2361 ERROR cinder.volume.drivers.nfs [req-34b272e3-cd6c-45d2-9ec7-543137c8ecca - - - - -] Mount failure for 192.168.80.130:/data/nfs after 3 attempts.
    May 25 02:15:09 linux-node2 cinder-volume: 2017-05-25 02:15:09.902 2361 ERROR oslo_service.service File "/usr/lib/python2.7/site-packages/cinder/volume/drivers/nfs.py", line 432, in _update_volume_stats
    May 25 02:17:17 linux-node2 kernel: FS-Cache: Netfs 'nfs' registered for caching
    May 25 02:45:48 linux-node2 kernel: Installing knfsd (copyright (C) 1996 okir@monad.swb.de).
    May 25 02:46:13 linux-node2 cinder-volume: 2017-05-25 02:46:13.136 1178 INFO cinder.volume.manager [req-c5d186eb-3199-4d45-8c18-425b73fab1a1 - - - - -] Image-volume cache disabled for host linux-node2@nfs.
    May 25 02:46:15 linux-node2 cinder-volume: 2017-05-25 02:46:15.610 2368 ERROR cinder.volume.drivers.nfs [req-9a6c59ad-70b6-409a-affe-df7756e27870 - - - - -] Mount failure for 192.168.80.130:/data/nfs after 3 attempts.
    May 25 02:46:15 linux-node2 cinder-volume: 2017-05-25 02:46:15.616 2368 ERROR cinder.volume.manager File "/usr/lib/python2.7/site-packages/cinder/volume/drivers/nfs.py", line 142, in do_setup
    May 25 02:46:15 linux-node2 cinder-volume: 2017-05-25 02:46:15.616 2368 ERROR cinder.volume.manager File "/usr/lib/python2.7/site-packages/cinder/volume/drivers/nfs.py", line 340, in set_nas_security_options
    May 25 02:46:17 linux-node2 cinder-volume: 2017-05-25 02:46:17.824 2368 ERROR cinder.volume.drivers.nfs [req-9a6c59ad-70b6-409a-affe-df7756e27870 - - - - -] Mount failure for 192.168.80.130:/data/nfs after 3 attempts.
    May 25 02:46:18 linux-node2 cinder-volume: 2017-05-25 02:46:18.031 2368 ERROR oslo_service.service File "/usr/lib/python2.7/site-packages/cinder/volume/drivers/nfs.py", line 432, in _update_volume_stats
    [root@linux-node2 ~]# mount.nfs4: an incorrect mount option was specified
    -bash: mount.nfs4:: command not found
    [root@linux-node2 ~]#

    说明:linux-node2(192.168.80.129)上运行cinder-volume,作为nfs客户端,linux-node3(192.168.80.130)作为nfs服务器。在linux-node2上手动挂载是需指定版本为vers3才能手动挂载上,不知道博主是否有遇到类似问题,希望博主给出一些建议。
    [root@linux-node2 ~]# mount -t nfs -o vers=3 192.168.80.130:/data/nfs /data/mnt/
    [root@linux-node2 ~]# mount | grep nfs
    nfsd on /proc/fs/nfsd type nfsd (rw,relatime)
    sunrpc on /var/lib/nfs/rpc_pipefs type rpc_pipefs (rw,relatime)
    192.168.80.130:/data/nfs on /data/mnt type nfs (rw,relatime,vers=3,rsize=524288,wsize=524288,namlen=255,hard,proto=tcp,timeo=600,retrans=2,sec=sys,mountaddr=192.168.80.130,mountvers=3,mountport=20048,mountproto=udp,local_lock=none,addr=192.168.80.130)
    [root@linux-node2 ~]# umount /data/mnt/
    [root@linux-node2 ~]# mount -t nfs4 192.168.80.130:/data/nfs /data/mnt
    mount.nfs4: an incorrect mount option was specified
    [root@linux-node2 ~]#
    OS版本号:
    [root@linux-node2 ~]# cat /etc/redhat-release
    CentOS Linux release 7.0.1406 (Core)

      1. @anzhihe nfs4尝试了很多办法还是挂载不上,可能是这个nfs版本的bug,找到一种nfs v3的替代方案了:
        [root@linux-node2 /]# cat /etc/cinder/nfs_shares
        192.168.80.130:/data/nfs -t nfs -o vers=3
        在nfs_shares文件中指定使用v3版本去挂载。

发表评论

电子邮件地址不会被公开。 必填项已用*标注