搭建 OpenStack(Q 版)Manila 组件

简介

  • 基于 Ubuntu/CentOS 系统,搭建 OpenStack(Q 版)Manila 组件

在 Controller 节点

数据库

  • 进入数据库
1
$ mysql -u root -p
  • 创建数据库
1
MariaDB [(none)]> CREATE DATABASE manila;
  • 赋予数据库权限
1
2
3
4
5
# <MANILA_DBPASS>为自定义密码
MariaDB [(none)]> GRANT ALL PRIVILEGES ON manila.* TO 'manila'@'localhost' \
  IDENTIFIED BY 'MANILA_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON manila.* TO 'manila'@'%' \
  IDENTIFIED BY 'MANILA_DBPASS';
  • 退出数据库
1
MariaDB [(none)]> exit

安装 Manila 组件

CentOS/Ubuntu 系统

  • 重新加载 admin 用户的管理凭据
1
$ source /openstack/admin-openrc
  • 创建 manila 用户
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
$ openstack user create --domain default --password-prompt manila
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| domain_id           | e0353a670a9e496da891347c589539e9 |
| enabled             | True                             |
| id                  | 83a3990fc2144100ba0e2e23886d8acc |
| name                | manila                           |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+
  • 为项目 service 与用户 manila 添加角色 admin
1
$ openstack role add --project service --user manila admin
  • 创建 compute 服务实体

共享文件系统服务需要两个服务实体。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
$ openstack service create --name manila \
  --description "OpenStack Shared File Systems" share
  +-------------+----------------------------------+
  | Field       | Value                            |
  +-------------+----------------------------------+
  | description | OpenStack Shared File Systems    |
  | enabled     | True                             |
  | id          | 82378b5a16b340aa9cc790cdd46a03ba |
  | name        | manila                           |
  | type        | share                            |
  +-------------+----------------------------------+
  
$ openstack service create --name manilav2 \
  --description "OpenStack Shared File Systems V2" sharev2
  +-------------+----------------------------------+
  | Field       | Value                            |
  +-------------+----------------------------------+
  | description | OpenStack Shared File Systems V2 |
  | enabled     | True                             |
  | id          | 30d92a97a81a4e5d8fd97a32bafd7b88 |
  | name        | manilav2                         |
  | type        | sharev2                          |
  +-------------+----------------------------------+
  • 创建 compute 服务的访问端点 endpoint

共享文件系统服务每个服务实体都需要 endpoint。

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
$ openstack endpoint create --region RegionOne \
  share public http://controller:8786/v1/%\(tenant_id\)s
  +--------------+-----------------------------------------+
  | Field        | Value                                   |
  +--------------+-----------------------------------------+
  | enabled      | True                                    |
  | id           | 0bd2bbf8d28b433aaea56a254c69f69d        |
  | interface    | public                                  |
  | region       | RegionOne                               |
  | region_id    | RegionOne                               |
  | service_id   | 82378b5a16b340aa9cc790cdd46a03ba        |
  | service_name | manila                                  |
  | service_type | share                                   |
  | url          | http://controller:8786/v1/%(tenant_id)s |
  +--------------+-----------------------------------------+

$ openstack endpoint create --region RegionOne \
  share internal http://controller:8786/v1/%\(tenant_id\)s
  +--------------+-----------------------------------------+
  | Field        | Value                                   |
  +--------------+-----------------------------------------+
  | enabled      | True                                    |
  | id           | a2859b5732cc48b5b083dd36dafb6fd9        |
  | interface    | internal                                |
  | region       | RegionOne                               |
  | region_id    | RegionOne                               |
  | service_id   | 82378b5a16b340aa9cc790cdd46a03ba        |
  | service_name | manila                                  |
  | service_type | share                                   |
  | url          | http://controller:8786/v1/%(tenant_id)s |
  +--------------+-----------------------------------------+

$ openstack endpoint create --region RegionOne \
  share admin http://controller:8786/v1/%\(tenant_id\)s
  +--------------+-----------------------------------------+
  | Field        | Value                                   |
  +--------------+-----------------------------------------+
  | enabled      | True                                    |
  | id           | f7f46df93a374cc49c0121bef41da03c        |
  | interface    | admin                                   |
  | region       | RegionOne                               |
  | region_id    | RegionOne                               |
  | service_id   | 82378b5a16b340aa9cc790cdd46a03ba        |
  | service_name | manila                                  |
  | service_type | share                                   |
  | url          | http://controller:8786/v1/%(tenant_id)s |
  +--------------+-----------------------------------------+
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
$ openstack endpoint create --region RegionOne \
  sharev2 public http://controller:8786/v2/%\(tenant_id\)s
  +--------------+-----------------------------------------+
  | Field        | Value                                   |
  +--------------+-----------------------------------------+
  | enabled      | True                                    |
  | id           | d63cc0d358da4ea680178657291eddc1        |
  | interface    | public                                  |
  | region       | RegionOne                               |
  | region_id    | RegionOne                               |
  | service_id   | 30d92a97a81a4e5d8fd97a32bafd7b88        |
  | service_name | manilav2                                |
  | service_type | sharev2                                 |
  | url          | http://controller:8786/v2/%(tenant_id)s |
  +--------------+-----------------------------------------+

$ openstack endpoint create --region RegionOne \
  sharev2 internal http://controller:8786/v2/%\(tenant_id\)s
  +--------------+-----------------------------------------+
  | Field        | Value                                   |
  +--------------+-----------------------------------------+
  | enabled      | True                                    |
  | id           | afc86e5f50804008add349dba605da54        |
  | interface    | internal                                |
  | region       | RegionOne                               |
  | region_id    | RegionOne                               |
  | service_id   | 30d92a97a81a4e5d8fd97a32bafd7b88        |
  | service_name | manilav2                                |
  | service_type | sharev2                                 |
  | url          | http://controller:8786/v2/%(tenant_id)s |
  +--------------+-----------------------------------------+

$ openstack endpoint create --region RegionOne \
  sharev2 admin http://controller:8786/v2/%\(tenant_id\)s
  +--------------+-----------------------------------------+
  | Field        | Value                                   |
  +--------------+-----------------------------------------+
  | enabled      | True                                    |
  | id           | e814a0cec40546e98cf0c25a82498483        |
  | interface    | admin                                   |
  | region       | RegionOne                               |
  | region_id    | RegionOne                               |
  | service_id   | 30d92a97a81a4e5d8fd97a32bafd7b88        |
  | service_name | manilav2                                |
  | service_type | sharev2                                 |
  | url          | http://controller:8786/v2/%(tenant_id)s |
  +--------------+-----------------------------------------+

Ubuntu 系统

  • 安装软件包
1
# apt-get install manila-api manila-scheduler python-manilaclient

CentOS 系统

  • 安装软件包
1
# yum install openstack-manila python-manilaclient

CentOS/Ubuntu 系统

  • 配置 Manila 服务
1
$ vim /etc/manila/manila.conf
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
[DEFAULT]
# 配置 RabbitMQ 消息队列访问,<RABBIT_PASS>为 RabbitMQ 的密码
transport_url = rabbit://openstack:RABBIT_PASS@controller
# Controller 节点的 IP 地址
my_ip = <IP 地址>
auth_strategy = keystone
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

[database]
## <MANILA_DBPASS>为 manila 数据库的密码
connection = mysql+pymysql://manila:MANILA_DBPASS@controller/manila

[keystone_authtoken]
# <MANILA_PASS>为 manila 用户的密码
memcached_servers = controller:11211
auth_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 = MANILA_PASS

[oslo_concurrency]
lock_path = /var/lock/manila
  • 同步数据库
1
# su -s /bin/sh -c "manila-manage db sync" manila

Ubuntu 系统

  • 重启 Manila 服务
1
2
# service manila-scheduler restart
# service manila-api restart
  • 默认情况下,Ubuntu 会创建一个 SQLite 数据库。由于上面配置使用的是 MySQL 数据库服务器,因此可以删除自动生成的 SQLite 数据库文件
1
# rm -f /var/lib/manila/manila.sqlite

CentOS 系统

  • 重启 Manila 服务并设置开机自启
1
2
# systemctl enable openstack-manila-api.service openstack-manila-scheduler.service
# systemctl start openstack-manila-api.service openstack-manila-scheduler.service

在 Share 节点

安装 Manila 组件

Ubuntu 系统

  • 安装软件包
1
# apt-get install manila-share python-pymysql

CentOS 系统

  • 安装软件包
1
# yum install openstack-manila-share python2-PyMySQL

CentOS/Ubuntu 系统

配置 Manila
  • 配置 Manila 服务
1
$ vim /etc/manila/manila.conf
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
[DEFAULT]
# <RABBIT_PASS>为 RabbitMQ 的密码
transport_url = rabbit://openstack:RABBIT_PASS@controller
# Compute 节点的 IP 地址
my_ip = MANAGEMENT_INTERFACE_IP_ADDRESS
auth_strategy = keystone
default_share_type = default_share_type
rootwrap_config = /etc/manila/rootwrap.conf

[database]
## <MANILA_DBPASS>为 manila 数据库的密码
connection = mysql://manila:MANILA_DBPASS@controller/manila

[keystone_authtoken]
# <MANILA_PASS>为 manila 用户的密码
memcached_servers = controller:11211
auth_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 = MANILA_PASS

[oslo_concurrency]
lock_path = /var/lib/manila/tmp
  • 配置 Manila share 后端存储
1
$ vim /etc/manila/manila.conf
 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
[DEFAULT]
# 在 [DEFAULT]下的 enabled_share_protocols 中加入需要的共享协议,如要使用 Ceph native 驱动就加入 CEPHFS
enabled_share_protocols = NFS,CIFS,CEPHFS
# 在 [DEFAULT]下的 enabled_share_backends 中加入需要使用的驱动
enabled_share_backends = cephfsnfs

[cephfsnfs]
driver_handles_share_servers = False
share_backend_name = CEPHFSNFS
share_driver = manila.share.drivers.cephfs.driver.CephFSDriver
cephfs_protocol_helper_type = NFS
cephfs_conf_path = /etc/ceph/ceph.conf
cephfs_auth_id = manila
cephfs_cluster_name = ceph
cephfs_enable_snapshots = True
cephfs_ganesha_server_is_remote= True
cephfs_ganesha_server_ip = GANESHA_IP
cephfs_ganesha_server_username = root
cephfs_ganesha_server_password = GANESHA_PASS
  • 设置 driver_handles_share_servers 为 False,因为驱动程序不管理共享服务器的生命周期

  • 设置 cephfs_protocol_helper_type 为 NFS 允许 NFS 协议访问 CephFS 支持的共享

  • cephfs_auth_id 转换为授权驱动程序与 Ceph 通信时创建的 Ceph 身份

  • 如果 NFS-ganesha 服务器与 manila-share 服务位于同一位置,cephfs_ganesha_server_is_remote 的值则为 False,如果 NFS-ganesha 服务器是远程的,则为 True,并且要再添加cephfs_ganesha_server_ip, cephfs_ganesha_server_usernamecephfs_ganesha_server_password 选项(或者是 cephfs_ganesha_path_to_private_key 选项)

  • cephfs_ganesha_server_ip 是 NFS-ganesha 服务器的 ip 地址,即使 ganesha 服务器与 manila-share 服务位于同一位置,也建议设置此选项

  • 每次修改配置后都需要重启 manila-share 服务才能生效

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
>   # centos
>   # systemctl restart openstack-manila-share.service
>   
>   # ubuntu
>   # service manila-share restart
>   ```

##### 创建共享

- 首先创建一个 CephFS NFS 共享类型

  ```bash
  manila type-create cephfsnfstype false
  manila type-key cephfsnfstype set vendor_name=Ceph storage_protocol=NFS
  • 然后创建一个共享
1
  manila create --share-type cephfsnfstype --name cephnfsshare1 nfs 1
  • 查看共享的导出位置
1
  manila share-export-location-list cephnfsshare1

共享的导出位置包含 NFS-Ganesha 服务器的 IP 地址和要挂载的路径,形如 {NFS-Ganesha server address}:{path to be mounted}

访问许可
  • 允许访客使用 ip 访问类型访问共享
1
  manila access-allow cephnfsshare1 ip 172.24.4.225
  • 查看可访问列表
1
  manila access-list cephnfsshare1
挂载共享
  • 在 guest 虚拟机中,使用 NFS 客户端挂载共享
1
  sudo mount -t nfs 172.24.4.3:/volumes/_nogroup/6732900b-32c1-4816-a529-4d6d3f15811e /mnt/nfs/
卸载共享

可使用以下命令进行共享的卸载

1
sudo umount mountpoint

Ubuntu 系统

  • 重启 Manila 服务
1
# service manila-share restart
  • 默认情况下,Ubuntu 会创建一个 SQLite 数据库。由于上面配置使用的是 MySQL 数据库服务器,因此可以删除自动生成的 SQLite 数据库文件
1
# rm -f /var/lib/manila/manila.sqlite

CentOS 系统

  • 启动 Manila 服务并设置开机自启
1
2
# systemctl enable openstack-manila-share.service
# systemctl start openstack-manila-share.service

参考链接