linux 后端存储,配置NFS网络存储作为cinder的后端存储

安装cinder和nfs

yum install -y openstack-cinder

yum install cifs-utils

在controller节点配置nfs

[[email protected] ~]# mkdir -p /data/nfs #创建一个共享挂载资源的目录

[[email protected] ~]# cat /etc/exports

/data/nfs *(rw,sync,root_squash) #NFS服务程序的配置文件为/etc/exports sync 同时将数据写入到内存与硬盘中,保证不丢失数据 rw 读写 no_root_squash 当NFS客户端以root管理员访问时,映射为NFS服务器的root管理员

启动和启用NFS服务程序。由于在使用NFS服务进行文件共享之前,需要使用RPC(Remote Procedure Call,远程过程调用)服务将NFS服务器的IP地址和端口号等信息发送给客户端。因此,在启动NFS服务之前,还需要顺带重启并启用rpcbind服务程序,并将这两个服务一并加入开机启动项中

[[email protected] ~]# systemctl resatrt rpcbind

[[email protected] ~]# systemctl enable rpcbind

[[email protected] ~]# systemctl start nfs-server

[[email protected] ~]# systemctl enable nfs-server

使用showmount命令查询NFS服务器的远程共享信息

[[email protected] ~]# showmount -e 192.168.100.10

Export list for 192.168.100.10:

/data/nfs *

测试挂载

[[email protected] ~]# mount 192.168.100.10:/data/nfs /mnt/

192.168.100.10:/data/nfs nfs4 197G 19G 169G 10% /mnt

#挂载成功

[[email protected] ~]# umount /mnt/

[[email protected] ~]# df -Th

Filesystem Type Size Used Avail Use% Mounted on

/dev/mapper/centos-root ext4 2.9T 1.8G 2.8T 1% /

devtmpfs devtmpfs 7.8G 0 7.8G 0% /dev

tmpfs tmpfs 7.8G 0 7.8G 0% /dev/shm

tmpfs tmpfs 7.8G 17M 7.8G 1% /run

tmpfs tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup

/dev/md126p2 xfs 495M 129M 367M 27% /boot

tmpfs tmpfs 1.6G 0 1.6G 0% /run/user/0

配置nfs作为cinder后端存储

[[email protected] ~]# vi /etc/cinder/cinder.conf

[DEFAULT]

volume_driver = cinder.volume.drivers.nfs.NfsDriver

nfs_shares_config = /etc/cinder/nfs.conf

去创建/etc/cinder/nfs.conf这个文件

[[email protected] ~]# vi /etc/cinder/nfs.conf

192.168.100.10:/data/nfs

重启服务nfs后端存储自动挂载

[[email protected] ~]# systemctl restart openstack-cinder-api.service

[[email protected] ~]# systemctl restart openstack-cinder-volume.service

[[email protected] ~]# systemctl restart openstack-cinder-scheduler.service

[[email protected] ~]# df -Th

Filesystem Type Size Used Avail Use% Mounted on

/dev/mapper/centos-root ext4 197G 19G 169G 10% /

devtmpfs devtmpfs 7.8G 0 7.8G 0% /dev

tmpfs tmpfs 7.8G 0 7.8G 0% /dev/shm

tmpfs tmpfs 7.8G 8.7M 7.8G 1% /run

tmpfs tmpfs 7.8G 0 7.8G 0% /sys/fs/cgroup

/dev/sda1 xfs 494M 126M 368M 26% /boot

/dev/loop0 iso9660 4.1G 4.1G 0 100% /opt/centos

/dev/loop1 iso9660 2.7G 2.7G 0 100% /opt/iaas

tmpfs tmpfs 1.6G 0 1.6G 0% /run/user/0

192.168.100.10:/data/nfs nfs4 197G 19G 169G 10% /var/lib/cinder/mnt/cfee723fff086429eb82121076ac5407

创建volume测试

[[email protected] ~]# cinder create --display-name ‘volume‘ 1

+--------------------------------+--------------------------------------+

| Property | Value |

+--------------------------------+--------------------------------------+

| attachments | [] |

| availability_zone | nova |

| bootable | false |

| consistencygroup_id | None |

| created_at | 2019-04-24T15:36:11.000000 |

| description | None |

| encrypted | False |

| id | d259218e-45ec-4d31-a97c-b7e006cf957e |

| metadata | {} |

| migration_status | None |

| multiattach | False |

| name | volume |

| os-vol-host-attr:host | None |

| os-vol-mig-status-attr:migstat | None |

| os-vol-mig-status-attr:name_id | None |

| os-vol-tenant-attr:tenant_id | 89b7ee9ffd73479b9446a3bf296bacbb |

| replication_status | disabled |

| size | 1 |

| snapshot_id | None |

| source_volid | None |

| status | creating |

| updated_at | None |

| user_id | 3469ea43ec3345d2a29606c4566cd43a |

| volume_type | None |

+--------------------------------+--------------------------------------+

[[email protected] ~]# openstack volume list

+--------------------------------------+--------------+--------+------+-------------+

| ID | Display Name | Status | Size | Attached to |

+--------------------------------------+--------------+--------+------+-------------+

| d259218e-45ec-4d31-a97c-b7e006cf957e | volume | error | 1 | |

+--------------------------------------+--------------+--------+------+-------------+

#volume状态erros 去查看日志

[[email protected] cinder]# tail -f volume.log

2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher File "/usr/lib/python2.7/site-packages/cinder/utils.py", line 148, in execute

2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher return processutils.execute(*cmd, **kwargs)

2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher File "/usr/lib/python2.7/site-packages/oslo_concurrency/processutils.py", line 389, in execute

2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher cmd=sanitized_cmd)

2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher ProcessExecutionError: Unexpected error while running command.

2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher Command: truncate -s 1G /var/lib/cinder/mnt/cfee723fff086429eb82121076ac5407/volume-d259218e-45ec-4d31-a97c-b7e006cf957e

2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher Exit code: 1

2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher Stdout: u‘‘

2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher Stderr: ‘truncate: cannot open \xe2\x80\x98/var/lib/cinder/mnt/cfee723fff086429eb82121076ac5407/volume-d259218e-45ec-4d31-a97c-b7e006cf957e\xe2\x80\x99 for writing: Permission denied\n‘

2019-04-24 11:36:13.359 461 ERROR oslo_messaging.rpc.dispatcher

失败原因没有权限

[[email protected] ~]# ls /data/nfs/ -ld

drwxr-xr-x. 2 root root 4096 Apr 24 10:19 /data/nfs/

[[email protected] ~]# chmod o+w /data/nfs/

[[email protected] ~]# ls /data/nfs/ -ld

drwxr-xrwx. 2 root root 4096 Apr 24 10:19 /data/nfs/

重新创建volume测试

[[email protected] ~]# cinder create --display-name ‘volume‘ 1

+--------------------------------+--------------------------------------+

| Property | Value |

+--------------------------------+--------------------------------------+

| attachments | [] |

| availability_zone | nova |

| bootable | false |

| consistencygroup_id | None |

| created_at | 2019-04-24T15:41:56.000000 |

| description | None |

| encrypted | False |

| id | 16b0c969-c71f-47e0-b898-1c2098e41338 |

| metadata | {} |

| migration_status | None |

| multiattach | False |

| name | volume |

| os-vol-host-attr:host | None |

| os-vol-mig-status-attr:migstat | None |

| os-vol-mig-status-attr:name_id | None |

| os-vol-tenant-attr:tenant_id | 89b7ee9ffd73479b9446a3bf296bacbb |

| replication_status | disabled |

| size | 1 |

| snapshot_id | None |

| source_volid | None |

| status | creating |

| updated_at | None |

| user_id | 3469ea43ec3345d2a29606c4566cd43a |

| volume_type | None |

+--------------------------------+--------------------------------------+

[[email protected] ~]# cinder list

+--------------------------------------+-----------+--------+------+-------------+----------+-------------+

| ID | Status | Name | Size | Volume Type | Bootable | Attached to |

+--------------------------------------+-----------+--------+------+-------------+----------+-------------+

| 16b0c969-c71f-47e0-b898-1c2098e41338 | available | volume | 1 | - | false | |

+--------------------------------------+-----------+--------+------+-------------+----------+-------------+

volume状态可用

[[email protected] ~]# ls /data/nfs/

volume-16b0c969-c71f-47e0-b898-1c2098e41338

#volume被写入nfs作为后端存储

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值