标签:centos openstack cinder nfs device drive-virtio-
NFS是Network File System的缩写,即网络文件系统。一种使用于分散式文件系统的协定,由Sun公司开发,于1984年向外公布。功能是通过网络让不同的机器、不同的操 作系统能够彼此分享个别的数据,让应用程序在客户端通过网络访问位于服务器磁盘中的数据,是在类Unix系统间实现磁盘文件共享的一种方法。
NFS的基本原则是“容许不同的客户端及服务端通过一组RPC分享相同的文件系统”,它是独立于操作系统,容许不同硬件及操作系统的系统共同进行文件的分享。
NFS在文件传送或信息传送过程中依赖于RPC协议。RPC,远程过程调用(Remote Procedure Call) 是能使客户端执行其他系统中程序的一种机制。NFS本身是没有提供信息传输的协议和功能的,但NFS却能让我们通过网络进行资料的分享,这是因为NFS使 用了一些其它的传输协议。而这些传输协议用到这个RPC功能的。可以说NFS本身就是使用RPC的一个程序。或者说NFS也是一个RPC SERVER。所以只要用到NFS的地方都要启动RPC服务,不论是NFS SERVER或者NFS CLIENT。这样SERVER和CLIENT才能通过RPC来实现PROGRAM PORT的对应。可以这么理解RPC和NFS的关系:NFS是一个文件系统,而RPC是负责负责信息的传输。
yum -y install rpcbind nfs-utils
NFS服务器端的配置比较简单,基本只涉及/etc/exports文件的修改,配置内容如下:
/nfs/shared192.168.40.0/255.255.255.0(rw,sync)
以上配置标示"192.168.40.0/255.255.255.0"这个网段的用户可以挂载NFS服务器上的/nfs/shared目录,挂载后具有读写权限,由于没有指定压缩用户权限的方式,所以就算以root身份登录,也会被降级为nobody
service rpcbind start service nfs start service nfslock start chkconfig rpcbind on chkconfig nfs on chkconfig nfslock on
服务器端使用showmount命令查询NFS的共享状态
# showmount-e //默认查看自己共享的服务,前提是要DNS能解析自己,不然容易报错 # showmount-a //显示已经与客户端连接上的目录信息
客户端使用showmount命令查询NFS的共享状态
# showmount -e NFS服务器IP
/etc/exports NFS服务的主要配置文件
/usr/sbin/exportfs NFS服务的管理命令
/usr/sbin/showmount 客户端的查看命令
/var/lib/nfs/etab 记录NFS分享出来的目录的完整权限设定值
/var/lib/nfs/xtab 记录曾经登录过的客户端信息
如果我们在启动了NFS之后又修改了/etc/exports,是不是还要重新启动nfs呢?这个时候我们就可以用exportfs命令来使改动立刻生效
exportfs -arv
yum install rpcbindnfs-utils
servicerpcbind start servicenfslock start chkconfigrpcbind on chkconfignfs on chkconfignfslock on
NFS服务器的IP为192.168.40.107
[root@controllernodeimages(keystone_admin)]# showmount -e 192.168.40.107 Exportlist for 192.168.40.107: /nfs/shared192.168.40.0/255.255.255.0
cd /root mkdir nfsshare mount -tnfs 192.168.40.107:/nfs/shared /root/nfsshare/
[root@controllernode~(keystone_admin)]# df -h Filesystem Size Used Avail Use% Mounted on /dev/sda1 97G 4.8G 87G 6% / tmpfs 3.9G 4.0K 3.9G 1% /dev/shm /srv/loopback-device/swift_loopback 1.9G 67M 1.8G 4% /srv/node/swift_loopback 192.168.40.107:/nfs/shared 444G 1.4G 420G 1% /root/nfsshare
需要注意的是,如果此时NFS服务器出现故障,或者是客户端不能连接到服务端,由于该命令要等待文件系统查找超时后才返回结果,所以该操作会变的很慢,该原理是用于所有针对文件系统的命令,例如 df,ls,cp等
192.168.40.107:/home/nfsshare
[root@controllernode~]# chown root:cinder /etc/cinder/nfsshares [root@controllernode~]# chmod 0640 /etc/cinder/nfsshares
修改/etc/cinder/cinder.conf中的值为/etc/cinder/nfsshares,可执行下面的命令
openstack-config --set /etc/cinder/cinder.conf DEFAULT nfs_shares_config /etc/cinder/nfsshares
openstack-config --set /etc/cinder/cinder.conf DEFAULT volume_driver cinder.volume.drivers.nfs.NfsDriver
service openstack-cinder-volume restart<span style="font-size:14px;"> </span>
添加了最后一条记录
控制台:
虚拟机:
先使用下面的命令格式化
mkfs.ext4 /dev/vdb
挂载的过程中,nova/compute.log中出现以下异常
2014-10-2312:23:28.193 1747 INFO urllib3.connectionpool [-] Starting new HTTP connection(1): 192.168.40.248 2014-10-2312:23:28.395 1747 WARNING nova.virt.libvirt.utils[req-5bf92b88-6d15-4c41-8ed7-3325fdea0dcf 5832a2295dc14de79522ee8b42e7daac9207105ae2ac4ef3bdf5dfe40d99fd8d] systool is not installed 2014-10-2312:23:28.449 1747 WARNING nova.virt.libvirt.utils[req-5bf92b88-6d15-4c41-8ed7-3325fdea0dcf 5832a2295dc14de79522ee8b42e7daac9207105ae2ac4ef3bdf5dfe40d99fd8d] systool is not installed 2014-10-2312:23:28.451 1747 INFO urllib3.connectionpool [-] Starting new HTTP connection(1): 192.168.40.248 2014-10-2312:23:28.960 1747 ERROR nova.virt.block_device[req-5bf92b88-6d15-4c41-8ed7-3325fdea0dcf 5832a2295dc14de79522ee8b42e7daac9207105ae2ac4ef3bdf5dfe40d99fd8d] [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] Driver failed to attach volume a1862c54-0671-4cc5-9fce-5e5f8485c21fat /dev/vdb 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] Traceback (most recent call last): 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] File"/usr/lib/python2.6/site-packages/nova/virt/block_device.py", line239, in attach 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] device_type=self['device_type'], encryption=encryption) 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] File"/usr/lib/python2.6/site-packages/nova/virt/libvirt/driver.py", line1267, in attach_volume 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] disk_dev) 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] File"/usr/lib/python2.6/site-packages/nova/openstack/common/excutils.py",line 68, in __exit__ 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] six.reraise(self.type_, self.value, self.tb) 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] File"/usr/lib/python2.6/site-packages/nova/virt/libvirt/driver.py", line1254, in attach_volume 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] virt_dom.attachDeviceFlags(conf.to_xml(), flags) 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] File "/usr/lib/python2.6/site-packages/eventlet/tpool.py",line 183, in doit 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] result = proxy_call(self._autowrap, f, *args, **kwargs) 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] File "/usr/lib/python2.6/site-packages/eventlet/tpool.py",line 141, in proxy_call 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] rv = execute(f, *args, **kwargs) 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] File "/usr/lib/python2.6/site-packages/eventlet/tpool.py",line 122, in execute 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] six.reraise(c, e, tb) 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] File "/usr/lib/python2.6/site-packages/eventlet/tpool.py",line 80, in tworker 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] rv = meth(*args, **kwargs) 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] File "/usr/lib64/python2.6/site-packages/libvirt.py", line419, in attachDeviceFlags 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] if ret == -1: raise libvirtError ('virDomainAttachDeviceFlags() failed',dom=self) 2014-10-2312:23:28.960 1747 TRACE nova.virt.block_device [instance:eb1742c6-1e73-4656-b646-ca8442519e7a] libvirtError: internal error unable toexecute QEMU command '__com.redhat_drive_add': Device 'drive-virtio-disk1'could not be initialized
这个错来自libvirt,做以下设置即可,先察看virt_use_nfs是off还是on
/usr/sbin/getseboolvirt_use_nfs
如果是off,做以下设置
/usr/sbin/setsebool -P virt_use_nfs on
Openstack存储总结之:详解如何使用NFS作为Cinder的后端存储
标签:centos openstack cinder nfs device drive-virtio-
原文地址:http://blog.csdn.net/eric_sunah/article/details/40395101