Openstack入門篇(十八)之Cinder服務-->使用NFS作為后端存儲


  • 1.安裝cinder-volume組件以及nfs

[root@linux-node2 ~]# yum install -y openstack-cinder python-keystone
[root@linux-node2 ~]# yum install -y nfs-utils rpcbind
[root@linux-node2 ~]# mkdir -p /data/nfs
[root@linux-node2 ~]# vim /etc/exports
/data/nfs *(rw,no_root_squash)
[root@linux-node2 ~]# systemctl start rpcbind
[root@linux-node2 ~]# systemctl start nfs
  • 2.配置cinder使用nfs

[root@linux-node1 ~]# scp /etc/cinder/cinder.conf 192.168.56.12:/etc/cinder
[root@linux-node2 ~]# vim /etc/cinder/cinder.conf
刪除[lvm]的內容
[default]
enabled_backends = nfs

[nfs]
volume_driver = cinder.volume.drivers.nfs.NfsDriver
nfs_shares_config=/etc/cinder/nfs_shares
nfs_mount_point_base=$state_path/mnt
驅動查找:
查看在此文件:/usr/lib/pythone.27/site-packages/cinder/volume/drivers/nfs.py內是否有這樣的類

 [root@linux-node2 ~]# vim /etc/cinder/nfs_shares
192.168.56.12:/data/nfs
  • 3.修改配置文件的權限,否則cinder服務無法讀取

[root@linux-node2 ~]# chown root.cinder /etc/cinder/nfs_shares
[root@linux-node2 ~]# chmod 640 /etc/cinder/nfs_shares
  • 4.啟動openstack-cinder-volume服務

[root@linux-node2 ~]# systemctl enable openstack-cinder-volume
[root@linux-node2 ~]# systemctl start openstack-cinder-volume
  • 5.查看volume服務

[root@linux-node1 ~]# source admin-openstack
[root@linux-node1 ~]# openstack volume service list
+------------------+-----------------+------+---------+-------+----------------------------+
| Binary            | Host           | Zone | Status  | State | Updated At                 |
+------------------+-----------------+------+---------+-------+----------------------------+
| cinder-scheduler | linux-node1     | nova | enabled | up    | 2017-12-11T06:28:29.000000 |
| cinder-volume    | linux-node1@lvm | nova | enabled | up    | 2017-12-11T06:28:28.000000 |
| cinder-volume    | linux-node2@nfs | nova | enabled | up    | 2017-12-11T06:28:26.000000 |
+------------------+-----------------+------+---------+-------+----------------------------+
  • 6.創建雲硬盤類型NFS和ISCSI

[root@linux-node1 ~]# cinder type-create NFS
[root@linux-node1 ~]# cinder type-create ISCSI
  • 7.將后端存儲和雲硬盤類型關聯

[root@linux-node1 ~]# vim /etc/cinder/cinder.conf
使用lvm本地存儲就需要在[lvm]加入
[lvm]
volume_backend_name = ISCSI-Storage

[root@linux-node1 ~]# systemctl restart openstack-cinder-volume
[root@linux-node2 ~]# vim /etc/cinder/cinder.conf
使用NFS網絡存儲就需要在[nfs]加入
[nfs]
volume_backend_name = NFS-Storage

[root@linux-node2 ~]# systemctl restart openstack-cinder-volume

在配置文件cinder.conf加入volume_backend_name可以實現多類型的雲硬盤掛載,如ISCSI,NFS

[root@linux-node1 ~]# cinder type-key NFS set volume_backend_name=NFS-Storage
[root@linux-node1 ~]# cinder type-key ISCSI set volume_backend_name=ISCSI-Storage
  • 8.創建卷

"卷"-->"管理連接"-->"連接雲主機"-->在雲主機內fdisk -l進行查看

 小結:

cinder后端存儲步驟:
(1)把存儲准備好,如NFS,ISCSI
(2)安裝cinder-volume
(3)vim /etc/cinder/cinder.conf
[xxx]
volume_driver=xxx
......
volume_backend_name=xxx-Storage
(4)創建類型:cinder type-create xxx
(5)關聯類型:cinder type-key xxx set volume_backend_name=xxx-Storage

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM