OpenStack共享服务介绍 OpenStack共享文件系统服务(manila)提供对共享或分布式文件系统的协调访问。供应和使用共享的方法由共享文件系统驱动程序或多后端配置情况下的驱动程序确定。
OpenStack共享服务介绍
OpenStack共享文件系统服务(manila)提供对共享或分布式文件系统的协调访问。供应和使用共享的方法由共享文件系统驱动程序或多后端配置情况下的驱动程序确定。有多种驱动程序也支持NFS、CIFS、HDFS、GlusterFS、CEPHFS、MAPRFS和其他协议。
共享文件系统API和调度程序服务通常在控制器节点上运行。根据使用的驱动程序,共享服务可以在控制器、计算节点或存储节点上运行。
使用命令编辑/etc/openstack/openrc.sh配置文件,添加Manila环境变量参数,SHARE_DISK为存储分区名称
##--------------------Manila Config----------------##
##Password for Mysql Manila user. exmaple:000000
MANILA_DBPASS=000000
##Password for Keystore Manila user. exmaple:000000
MANILA_PASS=000000
#The NODE Object Disk for Manila. example:md126p5.
SHARE_DISK=vdb3
使用CRT等远程连接工具,连接至172.30.17.14控制节点,执行iaas-install-manila-controller.sh安装脚本
[root@controller ~]# iaas-install-manila-controller.sh
使用CRT等远程连接工具,连接至172.30.17.5计算节点,执行iaas-install-manila-compute.sh安装脚本
[root@compute ~]# iaas-install-manila-compute.sh
使用Manila命令创建default_share_type共享类型
[root@controller ~]# source /etc/keystone/admin-openrc.sh
[root@controller ~]# manila type-create default_share_type False
+----------------------+--------------------------------------+
| Property | Value |
+----------------------+--------------------------------------+
| required_extra_specs | driver_handles_share_servers : False |
| Name | default_share_type |
| Visibility | public |
| is_default | YES |
| ID | 0fec7bca-f1a1-4e92-8d4b-aaf02147571a |
| optional_extra_specs | |
| Description | None |
+----------------------+--------------------------------------+
使用Manila命令查询类型列表信息
[root@controller ~]# manila type-list
+--------------------------------------+--------------------+------------+------------+--------------------------------------+----------------------+-------------+
| ID | Name | visibility | is_default | required_extra_specs | optional_extra_specs | Description |
+--------------------------------------+--------------------+------------+------------+--------------------------------------+----------------------+-------------+
| 0fec7bca-f1a1-4e92-8d4b-aaf02147571a | default_share_type | public | YES | driver_handles_share_servers : False | | None |
+--------------------------------------+--------------------+------------+------------+--------------------------------------+----------------------+-------------+
创建共享文件目录
使用Manila命令创建目录大小为2G的共享目录share-test
[root@controller ~]# manila create NFS 2 --name share-test
+---------------------------------------+--------------------------------------+
| Property | Value |
+---------------------------------------+--------------------------------------+
| status | creating |
| share_type_name | default_share_type |
| description | None |
| availability_zone | None |
| share_network_id | None |
| share_server_id | None |
| share_group_id | None |
| host | |
| revert_to_snapshot_support | False |
| access_rules_status | active |
| snapshot_id | None |
| create_share_from_snapshot_support | False |
| is_public | False |
| task_state | None |
| snapshot_support | False |
| id | a4b2a4f1-421f-4de3-8fca-d2ee8a5f4bb9 |
| size | 2 |
| source_share_group_snapshot_member_id | None |
| user_id | 89f8027475294689ae6c0183fa35bf5a |
| name | share-test |
| share_type | 0fec7bca-f1a1-4e92-8d4b-aaf02147571a |
| has_replicas | False |
| replication_type | None |
| created_at | 2022-05-06T11:24:02.000000 |
| share_proto | NFS |
| mount_snapshot_support | False |
| project_id | 0b6f2d0be1d342e09edc31dc841db7a5 |
| metadata | {} |
+---------------------------------------+--------------------------------------+
用Manila命令查询所创建的共享目录列表信息
[root@controller ~]# manila list
+--------------------------------------+------------+------+-------------+-----------+-----------+--------------------+--------------------------------+-------------------+
| ID | Name | Size | Share Proto | Status | Is Public | Share Type Name | Host | Availability Zone |
+--------------------------------------+------------+------+-------------+-----------+-----------+--------------------+--------------------------------+-------------------+
| a4b2a4f1-421f-4de3-8fca-d2ee8a5f4bb9 | share-test | 2 | NFS | available | False | default_share_type | controller@lvm#lvm-single-pool | nova |
+--------------------------------------+------------+------+-------------+-----------+-----------+--------------------+--------------------------------+-------------------+
挂载共享目录
使用Manila命令开放share-test目录对OpenStack管理网段使用权限
[root@controller ~]# manila access-allow share-test ip 10.24.195.0/24 --access-level rw
+--------------+--------------------------------------+
| Property | Value |
+--------------+--------------------------------------+
| access_key | None |
| share_id | a4b2a4f1-421f-4de3-8fca-d2ee8a5f4bb9 |
| created_at | 2022-05-06T11:27:19.000000 |
| updated_at | None |
| access_type | ip |
| access_to | 10.24.195.0/24 |
| access_level | rw |
| state | queued_to_apply |
| id | 9813f7f2-d15f-46cf-ad2d-062ce6ce3264 |
| metadata | {} |
+--------------+--------------------------------------+
查看share-test目录共享目录权限及开放网段
[root@controller ~]# manila access-list share-test
+--------------------------------------+-------------+----------------+--------------+--------+------------+----------------------------+------------+
| id | access_type | access_to | access_level | state | access_key | created_at | updated_at |
+--------------------------------------+-------------+----------------+--------------+--------+------------+----------------------------+------------+
| 9813f7f2-d15f-46cf-ad2d-062ce6ce3264 | ip | 10.24.195.0/24 | rw | active | None | 2022-05-06T11:27:19.000000 | None |
+--------------------------------------+-------------+----------------+--------------+--------+------------+----------------------------+------------+
查看share-test共享文件目录的访问路径
[root@controller ~]# manila show share-test | grep path | cut -d'|' -f3
path = 127.0.0.1:/var/lib/manila/mnt/share-55f94a46-9ac0-4b7e-8981-d83ac6fce8d7
在OpenStack控制节点将share-test共享目录挂载至/mnt目录下
[root@controller ~]# mount -t nfs 172.30.17.5:/var/lib/manila/mnt/share-c3f5a9fc-a8e7-40a6-a43b-56cfd1738724 /mnt/
在控制节点查询挂载信息,可以看到share01共享路径挂载至/mnt目录下
[root@controller ~]# df -th
文件系统 类型 容量 已用 可用 已用% 挂载点
devtmpfs devtmpfs 5.8G 0 5.8G 0% /dev
tmpfs tmpfs 5.8G 68K 5.8G 1% /dev/shm
tmpfs tmpfs 5.8G 592M 5.3G 10% /run
tmpfs tmpfs 5.8G 0 5.8G 0% /sys/fs/cgroup
/dev/vda1 xfs 50G 8.1G 42G 17% /
tmpfs tmpfs 1.2G 0 1.2G 0% /run/user/0
172.30.17.5:/var/lib/manila/mnt/share-c3f5a9fc-a8e7-40a6-a43b-56cfd1738724 nfs4 2.0G 6.0M 1.8G 1% /mnt