Article directory
OpenStack - shared file service (Manila) service introduction and installation
OpenStack Shared File Service (Manila) is a component used to provide shared file storage. It allows users to create and manage shared file systems in OpenStack cloud environments for sharing data between multiple instances or virtual machines.
Manila is like a cloud storage service, you can think of it as a "shared folder". Its function is to allow you to create a folder in a cloud environment and allow multiple virtual machines or instances to access the files in this folder at the same time.
Using Manila, you can create a shared file system just like a folder on your computer. You can then choose to share this folder with other virtual machines or instances. In this way, these virtual machines or instances can connect to this shared file system through the network and read and write files in it. This realizes the need to share data between multiple virtual machines or instances.
The benefit of Manila is that it provides a flexible and convenient way to manage shared file systems. You can create, delete, and resize shared file systems as needed. At the same time, Manila also provides permission control and security functions to ensure that only authorized users can access the shared file system.
Install and configure (controller)
Prepare
Before installing and configuring the Shared File System service, you must create the database, service credentials, and API endpoints
(1)Create database
① Connect to the database in the operating system terminal
[root@controller ~]# mysql -u root -p000000
②Create manila database
MariaDB [(none)]> CREATE DATABASE manila;
③Authorization
MariaDB [(none)]> GRANT ALL PRIVILEGES ON manila.* TO 'manila'@'localhost' IDENTIFIED BY '000000' ;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON manila.* TO 'manila'@'%' IDENTIFIED BY '000000';
④Exit the database
(2) Load the environment variables of admin user
[root@controller ~]# source admin-openrc.sh
(3)Create service credentials
①Create manila
user
[root@controller ~]# openstack user create --domain default --password 000000 manila
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 2d6b2600158e430e8fdaaaab332e6203 |
| name | manila |
| options | {
} |
| password_expires_at | None |
+---------------------+----------------------------------+
②Add admin
roles to usersmanila
[root@controller ~]# openstack role add --project service --user manila admin
③Create manila
and manilav2
serve entities
[root@controller ~]# openstack service create --name manila --description "OpenStack Shared File Systems" share
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Shared File Systems |
| enabled | True |
| id | 132a4a9113af497cb65553f5eb75463d |
| name | manila |
| type | share |
+-------------+----------------------------------+
[root@controller ~]# openstack service create --name manilav2 --description "OpenStack Shared File Systems V2" sharev2
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Shared File Systems V2 |
| enabled | True |
| id | c52f309714a9410f833207442aebff09 |
| name | manilav2 |
| type | sharev2 |
+-------------+----------------------------------+
(4) Create shared file system service API endpoint
[root@controller ~]# openstack endpoint create --region RegionOne share public http://controller:8786/v1/%\(tenant_id\)s
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | e1a46d73168f45e3b0d6a4f5b55983ed |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 132a4a9113af497cb65553f5eb75463d |
| service_name | manila |
| service_type | share |
| url | http://:8786/v1/%(tenant_id)s |
+--------------+----------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne share internal http://controller:8786/v1/%\(tenant_id\)s
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 243bdc7db29b428080018957c6d79862 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 132a4a9113af497cb65553f5eb75463d |
| service_name | manila |
| service_type | share |
| url | http://:8786/v1/%(tenant_id)s |
+--------------+----------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne share admin http://controller:8786/v1/%\(tenant_id\)s
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 9816a474ae4a419fb8211cfc6d0f64da |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 132a4a9113af497cb65553f5eb75463d |
| service_name | manila |
| service_type | share |
| url | http://:8786/v1/%(tenant_id)s |
+--------------+----------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne sharev2 public http://controller:8786/v2/%\(tenant_id\)s
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | d19d550ddc944a529de9db9e25d8926c |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | c52f309714a9410f833207442aebff09 |
| service_name | manilav2 |
| service_type | sharev2 |
| url | http://:8786/v2/%(tenant_id)s |
+--------------+----------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne sharev2 internal http://controller:8786/v2
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | c8cacf15e72c443cb28b00bead4be4a4 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 36b06f7d3af54475ba0a2eed55dc33a4 |
| service_name | manilav2 |
| service_type | sharev2 |
| url | http://controller:8786/v2 |
+--------------+----------------------------------+
[root@controller ~]# openstack endpoint create --region RegionOne sharev2 admin http://controller:8786/v2
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | df0a6cb2995b4fac8fed4bc325c8cc92 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 36b06f7d3af54475ba0a2eed55dc33a4 |
| service_name | manilav2 |
| service_type | sharev2 |
| url | http://controller:8786/v2 |
+--------------+----------------------------------+
Install and configure components
(1)Install software package
[root@controller ~]# yum install -y openstack-manila python3-manilaclient
(2)Configuration file
Edit /etc/manila/manila.conf
the file and complete the following actions
①In [database]
the section, configure database access:
[root@controller ~]# vim /etc/manila/manila.conf
[database]
connection = mysql+pymysql://manila:000000@controller/manila
②In [DEFAULT]
the section, configure RabbitMQ
message queue access
[DEFAULT]
transport_url = rabbit://openstack:000000@controller
③In [DEFAULT]
the section, set the following configuration values:
[DEFAULT]
transport_url = rabbit://openstack:000000@controller
state_path = /var/lib/manila
default_share_type = default_share_type
share_name_template = share-%s
rootwrap_config = /etc/manila/rootwrap.conf
api_paste_config = /etc/manila/api-paste.ini
auth_strategy = keystone
my_ip = 192.168.200.10
④ In the [DEFAULT]
and [keystone_authtoken]
section, configure the identity service access
[DEFAULT]
auth_strategy = keystone
[keystone_authtoken]
memcached_servers = controller:11211
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = manila
password = 000000
⑤In [oslo_concurrency]
the section, configure the lock path
[oslo_concurrency]
lock_path = /var/lib/manila/manila
(3) Synchronize database
[root@controller ~]# su -s /bin/sh -c "manila-manage db sync" manila
finish installation
[root@controller ~]# systemctl enable openstack-manila-api.service openstack-manila-scheduler.service && systemctl restart openstack-manila-api.service openstack-manila-scheduler.service
Install and configure shared nodes (compute)
(1)Install software package
[root@compute ~]# yum -y install openstack-manila-share python2-PyMySQL libtalloc python-manilaclient MySQL-python
(2)Configuration file
Edit /etc/manila/manila.conf
the file and complete the following actions
①In [database]
part
[database]
connection = mysql+pymysql://manila:000000@controller/manila
② In the [DEFAULT]
and [keystone_authtoken]
section, configure the identity service access
[DEFAULT]
transport_url = rabbit://openstack:000000@controller
my_ip = 192.168.200.20
api_paste_config = /etc/manila/api-paste.ini
rootwrap_config = /etc/manila/rootwrap.conf
state_path = /var/lib/manila
auth_strategy = keystone
default_share_type = default_share_type
enabled_share_protocols = NFS,CIFS
③Part [keystone_authtoken]
_
[keystone_authtoken]
memcached_servers = controller:11211
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = manila
password = 000000
④ In [oslo_concurrency]
the section, configure the lock path
[oslo_concurrency]
lock_path = /var/lib/manila/tmp
⑤Create a directory and set the owner
[root@compute ~]# mkdir /var/lib/manila
[root@compute ~]# chown manila. /var/lib/manila
Two drive modes
Shared nodes can support two modes, with and without shared server processing. This mode depends on driver support
option one
Deploy services without driver support for shared server management. In this mode, the service does not perform any network-related operations. The operator must ensure the network connection between the instance and the server based on the NAS protocol.
This tutorial demonstrates how to set up an LVM driver that creates LVM volumes on a shared node and exports them with the help of an NFS server installed locally on the shared node. Therefore, it requires LVM and NFS packages and manila-share
additional disks for LVM volume groups.
Option two
Deploy services with shared server management driver support. In this mode, the service runs with a backend driver that creates and manages shared servers. This tutorial demonstrates how to set up Generic
the driver. This driver requires the compute service (nova), image service (glance), and network service (neutron) to create and manage shared servers; and the block storage service (cinder) for creating shares.
We choose the first one
(1)Install software package
[root@compute ~]# yum -y install lvm2 nfs-utils nfs4-acl-tools portmap targetcli
(2) Start LVM and set it to start automatically at boot
[root@compute ~]# systemctl enable lvm2-lvmetad.service target.service && systemctl restart lvm2-lvmetad.service target.service
(3) Create LVM physical volumes and volume groups
[root@compute ~]# pvcreate /dev/sdd
Physical volume "/dev/sdd" successfully created.
[root@compute ~]# vgcreate manila-volumes /dev/sdd
Volume group "manila-volumes" successfully created
(4)Configuration components
Edit /etc/manila/manila.conf
the file and complete the following actions
In [DEFAULT]
the section, enable the LVM driver
[root@compute ~]# vim /etc/manila/manila.conf
[DEFAULT]
enabled_share_backends = lvm
In [lvm]
the section, configure the LVM driver
[lvm]
share_backend_name = LVM
share_driver = manila.share.drivers.lvm.LVMShareDriver
driver_handles_share_servers = False
lvm_share_volume_group = manila-volumes
lvm_share_export_ips = 192.168.200.20
finish installation
[root@compute ~]# systemctl restart lvm2-lvmetad.service target.service openstack-manila-share nfs-server
verify
(1) Load environment variables
[root@controller ~]# source admin-openrc.sh
(2) List service components to verify that each process starts successfully
[root@controller ~]# manila service-list
+----+------------------+-------------+------+---------+-------+----------------------------+
| Id | Binary | Host | Zone | Status | State | Updated_at |
+----+------------------+-------------+------+---------+-------+----------------------------+
| 1 | manila-scheduler | controller | nova | enabled | up | 2023-07-02T08:51:58.000000 |
| 2 | manila-share | compute@lvm | nova | enabled | up | 2023-07-02T08:52:00.000000 |
+----+------------------+-------------+------+---------+-------+----------------------------+
Use of Manila
(1)Create a shared type
[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 | ed4ac5e1-55eb-459c-a859-00825b017049 |
| optional_extra_specs | |
| Description | None |
+----------------------+--------------------------------------+
[root@controller ~]# manila type-list
+--------------------------------------+--------------------+------------+------------+--------------------------------------+----------------------+-------------+
| ID | Name | visibility | is_default | required_extra_specs | optional_extra_specs | Description |
+--------------------------------------+--------------------+------------+------------+--------------------------------------+----------------------+-------------+
| ed4ac5e1-55eb-459c-a859-00825b017049 | default_share_type | public | YES | driver_handles_share_servers : False | | None |
+--------------------------------------+--------------------+------------+------------+--------------------------------------+----------------------+-------------+
(2)Create NFS share
[root@controller ~]# manila create NFS 2 --name test-nfs-csq
+---------------------------------------+--------------------------------------+
| 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 | b4ad1964-45a3-4fa7-9233-9cee3b24bb11 |
| size | 2 |
| source_share_group_snapshot_member_id | None |
| user_id | fef5f8c16d3d4b9d849bc1488bf50a21 |
| name | test-nfs-csq |
| share_type | ed4ac5e1-55eb-459c-a859-00825b017049 |
| has_replicas | False |
| replication_type | None |
| created_at | 2023-07-02T09:01:11.000000 |
| share_proto | NFS |
| mount_snapshot_support | False |
| project_id | 0769b940829c4078a4aa573e83d6520c |
| metadata | {
} |
+---------------------------------------+--------------------------------------+
(3) Check sharing status
Note that the shared status must be available
[root@controller ~]# manila list
+--------------------------------------+--------------+------+-------------+-----------+-----------+--------------------+-----------------------------+-------------------+
| ID | Name | Size | Share Proto | Status | Is Public | Share Type Name | Host | Availability Zone |
+--------------------------------------+--------------+------+-------------+-----------+-----------+--------------------+-----------------------------+-------------------+
| b4ad1964-45a3-4fa7-9233-9cee3b24bb11 | test-nfs-csq | 2 | NFS | available | False | default_share_type | compute@lvm#lvm-single-pool | nova |
+--------------------------------------+--------------+------+-------------+-----------+-----------+--------------------+-----------------------------+-------------------+
Determine the shared export IP address
[root@controller ~]# manila show test-nfs-csq
+---------------------------------------+--------------------------------------------------------------------------------------+
| Property | Value |
+---------------------------------------+--------------------------------------------------------------------------------------+
| status | available |
| share_type_name | default_share_type |
| description | None |
| availability_zone | nova |
| share_network_id | None |
| export_locations | |
| | path = 192.168.200.20:/var/lib/manila/mnt/share-90987ec8-8ec6-4a3f-bbd7-0ae2dd3c822e |
| | preferred = False |
| | is_admin_only = False |
| | id = cad5e351-2cd0-411e-bcfc-16f25bae35ff |
| | share_instance_id = 90987ec8-8ec6-4a3f-bbd7-0ae2dd3c822e |
| share_server_id | None |
| share_group_id | None |
| host | compute@lvm#lvm-single-pool |
| 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 | b4ad1964-45a3-4fa7-9233-9cee3b24bb11 |
| size | 2 |
| source_share_group_snapshot_member_id | None |
| user_id | fef5f8c16d3d4b9d849bc1488bf50a21 |
| name | test-nfs-csq |
| share_type | ed4ac5e1-55eb-459c-a859-00825b017049 |
| has_replicas | False |
| replication_type | None |
| created_at | 2023-07-02T09:01:11.000000 |
| share_proto | NFS |
| mount_snapshot_support | False |
| project_id | 0769b940829c4078a4aa573e83d6520c |
| metadata | {
} |
+---------------------------------------+--------------------------------------------------------------------------------------+
(4) Allow access to shares
[root@controller ~]# manila access-allow test-nfs-csq ip 192.168.200.0/24 --access-level rw
+--------------+--------------------------------------+
| Property | Value |
+--------------+--------------------------------------+
| access_key | None |
| share_id | b4ad1964-45a3-4fa7-9233-9cee3b24bb11 |
| created_at | 2023-07-02T09:04:03.000000 |
| updated_at | None |
| access_type | ip |
| access_to | 192.168.200.0/24 |
| access_level | rw |
| state | queued_to_apply |
| id | 7f82c995-5e67-465d-afce-6af62479b8dc |
| metadata | {
} |
+--------------+--------------------------------------+
[root@controller ~]# manila access-list test-nfs-csq
+--------------------------------------+-------------+------------------+--------------+--------+------------+----------------------------+------------+
| id | access_type | access_to | access_level | state | access_key | created_at | updated_at |
+--------------------------------------+-------------+------------------+--------------+--------+------------+----------------------------+------------+
| 7f82c995-5e67-465d-afce-6af62479b8dc | ip | 192.168.200.0/24 | rw | active | None | 2023-07-02T09:04:03.000000 | None |
+--------------------------------------+-------------+------------------+--------------+--------+------------+----------------------------+------------+
(5)Mount sharing
[root@controller ~]# mount -t nfs 192.168.200.20:/var/lib/manila/mnt/share-90987ec8-8ec6-4a3f-bbd7-0ae2dd3c822e /mnt/
[root@controller ~]# df -HT
文件系统 类型 容量 已用 可用 已用% 挂载点
devtmpfs devtmpfs 4.1G 0 4.1G 0% /dev
tmpfs tmpfs 4.1G 0 4.1G 0% /dev/shm
tmpfs tmpfs 4.1G 13M 4.1G 1% /run
tmpfs tmpfs 4.1G 0 4.1G 0% /sys/fs/cgroup
/dev/mapper/centos-root xfs 54G 3.6G 51G 7% /
/dev/mapper/centos-home xfs 45G 34M 45G 1% /home
/dev/sda1 xfs 1.1G 205M 860M 20% /boot
tmpfs tmpfs 819M 0 819M 0% /run/user/0
192.168.200.20:/var/lib/manila/mnt/share-90987ec8-8ec6-4a3f-bbd7-0ae2dd3c822e nfs4 2.1G 6.3M 2.0G 1% /mnt
(6) Create files in the mounted directory
[root@controller ~]# cd /mnt/
[root@controller mnt]# dd if=/dev/zero of=csq bs=1M count=20
记录了20+0 的读入
记录了20+0 的写出
20971520字节(21 MB)已复制,2.91808 秒,7.2 MB/秒
[root@controller mnt]# df -h
文件系统 容量 已用 可用 已用% 挂载点
devtmpfs 3.8G 0 3.8G 0% /dev
tmpfs 3.9G 0 3.9G 0% /dev/shm
tmpfs 3.9G 12M 3.8G 1% /run
tmpfs 3.9G 0 3.9G 0% /sys/fs/cgroup
/dev/mapper/centos-root 50G 3.3G 47G 7% /
/dev/mapper/centos-home 42G 33M 42G 1% /home
/dev/sda1 1014M 195M 820M 20% /boot
tmpfs 781M 0 781M 0% /run/user/0
192.168.200.20:/var/lib/manila/mnt/share-90987ec8-8ec6-4a3f-bbd7-0ae2dd3c822e 2.0G 26M 1.8G 2% /mnt
[root@controller ~]# umount /mnt/
[root@controller ~]# ls /mnt/
[root@controller ~]# mount -t nfs 192.168.200.20:/var/lib/manila/mnt/share-90987ec8-8ec6-4a3f-bbd7-0ae2dd3c822e /mnt/
[root@controller ~]# ls /mnt/
csq lost+found