首页 > 网络 > 云计算 >

OpenstackManila使用初探(Packstack)

2016-09-07

OpenstackManila使用初探(Packstack)。使用Packstack (All in one) 安装好Openstack之后, 研究一下Manila组件的使用。

使用Packstack (All in one) 安装好Openstack之后, 研究一下Manila组件的使用.

主机名: cloud (192.168.31.233).

1. manila.conf

1.1 配置文件分析

Packstack的配置文件packstack-answers-20160830-020456.txt中涉及到manila.conf的一些配置选项如下:

# Password to use for the Compute service to authenticate with the
# Identity service.
CONFIG_NOVA_KS_PW=f65dfe2cbbdd487e
# Tenant to use when OpenStack Database-as-a-Service connects to the
# Compute service.
CONFIG_TROVE_NOVA_TENANT=services

首先贴上manila的配置文件. 关于每一个配置选项的功能详见 Manila.conf 官方文档 (Liberty版).

[DEFAULT]
osapi_share_listen=0.0.0.0
api_paste_config=/etc/manila/api-paste.ini
state_path=/var/lib/manila
glance_host=192.168.31.233 #
storage_availability_zone=nova
rootwrap_config=/etc/manila/rootwrap.conf
auth_strategy=keystone # 使用keystone进行用户身份认证
enabled_share_backends=generic # 可用的backends, 每一个backend都对应着后面的一个section

nova_catalog_info=compute:nova:publicURL # 在服务目录寻找nova服务时用的字符串
nova_catalog_admin_info=compute:nova:adminURL # 在服务目录寻找nova服务时用的字符串
nova_api_insecure=False # 不允许使用不安全的SSL请求nova服务
nova_admin_username=nova # 访问nova服务的用户名
nova_admin_password=f65dfe2cbbdd487e # 访问nova服务的密码
nova_admin_tenant_name=services # nova服务所在的租户 ???
nova_admin_auth_url=http://localhost:5000/v2.0

debug=False # 日志信息级别不设为debug. 详细程度: debug>INFO>warning.
verbose=True # 默认日志级别为warning, 改为INFO级别
use_stderr=True # 日志输出到stderr
log_dir=/var/log/manila # 日志信息输出位置
use_syslog=False
syslog_log_facility=LOG_USER
rpc_backend=rabbit
control_exchange=openstack
notification_driver=messaging

network_api_class=manila.network.neutron.neutron_network_plugin.NeutronNetworkPlugin
neutron_api_insecure=False
neutron_auth_strategy=keystone
neutron_admin_tenant_name=services
neutron_url=http://127.0.0.1:9696
neutron_admin_password=33e10dfa6ae44b9d
neutron_admin_username=neutron
neutron_admin_auth_url=http://localhost:5000/v2.0
neutron_url_timeout=30

cinder_catalog_info=volume:cinder:publicURL
cinder_admin_username=cinder
cinder_admin_password=7ec1a0f6b6834dd7
cinder_cross_az_attach=True
cinder_api_insecure=False
cinder_admin_auth_url=http://localhost:5000/v2.0
cinder_http_retries=3
cinder_admin_tenant_name=services

[generic]
volume_name_template=manila-share-%s
share_mount_path=/shares # 共享在共享实例中的位置
max_time_to_create_volume=180
delete_share_server_with_last_share=False
service_instance_smb_config_path=$share_mount_path/smb.conf
volume_snapshot_name_template=manila-snapshot-%s
automatic_share_server_cleanup=True
share_backend_name=generic
smb_template_config_path=$state_path/smb.conf
driver_handles_share_servers=True
share_driver=manila.share.drivers.generic.GenericShareDriver
unmanage_remove_access_rules=False
max_time_to_attach=120
share_helpers=CIFS=manila.share.drivers.generic.CIFSHelper,NFS=manila.share.drivers.generic.NFSHelper
path_to_private_key=~/.ssh/id_rsa
service_network_division_mask=28
service_instance_network_helper_type=neutron
max_time_to_build_instance=300 # 创建共享实例的最大等待时间
manila_service_keypair_name=manila-service
service_network_name=manila_service_network # manila服务网络名, 只和Neutron配置使用, neutron net-list可以查看
interface_driver=manila.network.linux.interface.OVSInterfaceDriver
service_network_cidr=10.254.0.0/16 # 共享实例所在的网络
service_instance_flavor_id=66 # 共享实例所使用的flavor ID. nova flavor-list可以查看
path_to_public_key=~/.ssh/id_rsa.pub
service_image_name=manila-service-image # 镜像文件名, glance image-list可以查看
service_instance_name_template=manila_service_instance_%s
service_instance_user=manila # 镜像系统登录的用户名
service_instance_password=manila # # 镜像系统登录的密码
share_volume_fstype=ext4
service_instance_security_group=manila-service
connect_share_server_to_tenant_network=False

[oslo_messaging_rabbit]
rabbit_ha_queues=False
rabbit_userid=guest
rabbit_password=guest
rabbit_port=5672
rabbit_use_ssl=False
rabbit_virtual_host=/
amqp_durable_queues=False
rabbit_host=192.168.31.233
rabbit_hosts=192.168.31.233:5672

[oslo_messaging_amqp]
container_name=guest
trace=False
group_request_prefix=unicast
idle_timeout=0
allow_insecure_clients=False
server_request_prefix=exclusive
broadcast_prefix=broadcast

[oslo_concurrency]
lock_path=/tmp/manila/manila_locks

[database]
max_overflow=20
max_retries=10
min_pool_size=1
max_pool_size=10
retry_interval=10
idle_timeout=3600
connection=mysql+pymysql://manila:38ef69950ba54354@192.168.31.233/manila

1.2 配置文件信息验证

(1) 镜像

我们使用的manila镜像是: manila-ubuntu-core.qcow2.

[root@cloud ~(keystone_demo)]# glance image-list
+--------------------------------------+----------------------+
| ID                                   | Name                 |
+--------------------------------------+----------------------+
| 251fc231-d77e-41f5-95d1-53ccb4885713 | cirros               |
| 78321fb8-4623-4430-a864-cd7b91e34d5d | manila-service-image |
+--------------------------------------+----------------------+
[root@cloud ~(keystone_demo)]# glance image-show 78321fb8-4623-4430-a864-cd7b91e34d5d
+------------------+--------------------------------------+
| Property         | Value                                |
+------------------+--------------------------------------+
| checksum         | de7487de25edef01bb19752113bb4935     |
| container_format | bare                                 |
| created_at       | 2016-08-29T18:55:26Z                 |
| disk_format      | qcow2                                |
| id               | 78321fb8-4623-4430-a864-cd7b91e34d5d |
| min_disk         | 0                                    |
| min_ram          | 0                                    |
| name             | manila-service-image                 |
| owner            | 7f529277e5304729a3c476852ed9cd89     |
| protected        | False                                |
| size             | 312999936                            |
| status           | active                               |
| tags             | []                                   |
| updated_at       | 2016-08-29T18:55:53Z                 |
| virtual_size     | None                                 |
| visibility       | public                               |
+------------------+--------------------------------------+

(2) Backend

查看可用的Backend:

[root@cloud ~(keystone_admin)]# manila pool-list
+-----------------------+-------+---------+---------+
| Name                  | Host  | Backend | Pool    |
+-----------------------+-------+---------+---------+
| cloud@generic#generic | cloud | generic | generic |
+-----------------------+-------+---------+---------+
[root@cloud ~(keystone_admin)]# manila service-list
+----+------------------+---------------+------+---------+-------+----------------------------+
| Id | Binary           | Host          | Zone | Status  | State | Updated_at                 |
+----+------------------+---------------+------+---------+-------+----------------------------+
| 1  | manila-scheduler | cloud         | nova | enabled | up    | 2016-08-29T21:59:07.000000 |
| 2  | manila-share     | cloud@generic | nova | enabled | up    | 2016-08-29T21:59:07.000000 |
+----+------------------+---------------+------+---------+-------+----------------------------+
[root@cloud ~(keystone_demo)]# manila type-list
+--------------------------------------+--------------------+------------+------------+-------------------------------------+-------------------------+
| ID                                   | Name               | Visibility | is_default | required_extra_specs                | optional_extra_specs    |
+--------------------------------------+--------------------+------------+------------+-------------------------------------+-------------------------+
| d364b6d5-9897-4296-8e8f-348ddc87a33e | generic_share_type | public     | -          | driver_handles_share_servers : True | snapshot_support : True |
+--------------------------------------+--------------------+------------+------------+-------------------------------------+-------------------------+
[root@cloud ~(keystone_admin)]# manila api-version
+------+-----------+---------+-----------------+
| ID   | Status    | Version | Minimum Version |
+------+-----------+---------+-----------------+
| v1.0 | SUPPORTED |         |                 |
| v2.0 | CURRENT   | 2.6     | 2.0             |
+------+-----------+---------+-----------------+

(3) 网络

[root@cloud ~(keystone_admin)]# neutron net-list
+--------------------------------------+------------------------+------------------------------------------------------+
| id                                   | name                   | subnets                                              |
+--------------------------------------+------------------------+------------------------------------------------------+
| 4017a406-4ce5-4feb-85e4-346093364fd2 | manila_service_network | ed45bdbb-465b-431b-93b2-5efccc8b46eb 10.254.0.0/28   |
| 622eec1e-7660-4538-987d-9792618e9454 | private                | 3fb61cc7-cdb3-49f8-998b-c43861d2684e 10.0.0.0/24     |
| c84e5733-51aa-43a5-ba2f-4501547506cb | public                 | 69a3cc0f-318e-411d-bbaf-21655df9a78a 172.24.4.224/28 |
+--------------------------------------+------------------------+------------------------------------------------------+
[root@cloud ~(keystone_admin)]# neutron net-show manila_service_network
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| id                        | 4017a406-4ce5-4feb-85e4-346093364fd2 |
| mtu                       | 0                                    |
| name                      | manila_service_network               |
| provider:network_type     | vxlan                                |
| provider:physical_network |                                      |
| provider:segmentation_id  | 64                                   |
| router:external           | False                                |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   | ed45bdbb-465b-431b-93b2-5efccc8b46eb |
| tenant_id                 | 7f529277e5304729a3c476852ed9cd89     |
+---------------------------+--------------------------------------+

[root@cloud ~(keystone_demo)]# neutron net-list
+————————————–+———+————————————————–+
| id | name | subnets |
+————————————–+———+————————————————–+
| c84e5733-51aa-43a5-ba2f-4501547506cb | public | 69a3cc0f-318e-411d-bbaf-21655df9a78a |
| 622eec1e-7660-4538-987d-9792618e9454 | private | 3fb61cc7-cdb3-49f8-998b-c43861d2684e 10.0.0.0/24 |
+————————————–+———+————————————————–+

使用demo用户创建共享网络:

[root@cloud ~(keystone_demo)]# neutron net-list
+--------------------------------------+---------+--------------------------------------------------+
| id                                   | name    | subnets                                          |
+--------------------------------------+---------+--------------------------------------------------+
| c84e5733-51aa-43a5-ba2f-4501547506cb | public  | 69a3cc0f-318e-411d-bbaf-21655df9a78a             |
| 622eec1e-7660-4538-987d-9792618e9454 | private | 3fb61cc7-cdb3-49f8-998b-c43861d2684e 10.0.0.0/24 |
+--------------------------------------+---------+--------------------------------------------------+
[root@cloud ~(keystone_demo)]# manila share-network-create --name share-network-1 --neutron-net-id 622eec1e-7660-4538-987d-9792618e9454 --neutron-subnet-id 3fb61cc7-cdb3-49f8-998b-c43861d2684e
+-------------------+--------------------------------------+
| Property          | Value                                |
+-------------------+--------------------------------------+
| name              | share-network-1                      |
| segmentation_id   | None                                 |
| created_at        | 2016-08-29T23:06:41.122040           |
| neutron_subnet_id | 3fb61cc7-cdb3-49f8-998b-c43861d2684e |
| updated_at        | None                                 |
| network_type      | None                                 |
| neutron_net_id    | 622eec1e-7660-4538-987d-9792618e9454 |
| ip_version        | None                                 |
| nova_net_id       | None                                 |
| cidr              | None                                 |
| project_id        | d6f01b3c735a4055ab7d8bbc3a3081e5     |
| id                | e17542de-cd48-4f58-91e9-83a184c2388c |
| description       | None                                 |
+-------------------+--------------------------------------+
[root@cloud ~(keystone_demo)]# neutron net-list
+--------------------------------------+---------+--------------------------------------------------+
| id                                   | name    | subnets                                          |
+--------------------------------------+---------+--------------------------------------------------+
| 622eec1e-7660-4538-987d-9792618e9454 | private | 3fb61cc7-cdb3-49f8-998b-c43861d2684e 10.0.0.0/24 |
| c84e5733-51aa-43a5-ba2f-4501547506cb | public  | 69a3cc0f-318e-411d-bbaf-21655df9a78a             |
+--------------------------------------+---------+--------------------------------------------------+

注意到, 这个共享网络share-network-1并不在demo的neutron net-list中. 同时admin的manila share-network-list和neturon net-list也是看不到share-network-1的.

(4) flavor

[root@cloud ~(keystone_demo)]# nova flavor-list
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
| 1  | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      |
......
| 66 | m1.manila | 512       | 0    | 0         |      | 1     | 1.0         | True      |
+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+

2. manila上手体验

2.1 创建并挂载manila共享

创建manila共享

[root@cloud ~(keystone_demo)]# manila create NFS 1 --name share1 --share-network share-network-1 --share-type generic_share_type
+-----------------------------+--------------------------------------+
| Property                    | Value                                |
+-----------------------------+--------------------------------------+
| status                      | None                                 |
| share_type_name             | generic_share_type                   |
| description                 | None                                 |
| availability_zone           | None                                 |
| share_network_id            | None                                 |
| export_locations            | []                                   |
| host                        | None                                 |
| snapshot_id                 | None                                 |
| is_public                   | False                                |
| task_state                  | None                                 |
| snapshot_support            | True                                 |
| id                          | c26852a6-3274-4312-9343-d4d503f838e6 |
| size                        | 1                                    |
| name                        | share1                               |
| share_type                  | d364b6d5-9897-4296-8e8f-348ddc87a33e |
| created_at                  | 2016-08-29T23:16:01.301535           |
| export_location             | None                                 |
| share_proto                 | NFS                                  |
| consistency_group_id        | None                                 |
| source_cgsnapshot_member_id | None                                 |
| project_id                  | d6f01b3c735a4055ab7d8bbc3a3081e5     |
| metadata                    | {}                                   |
+-----------------------------+--------------------------------------+

查看share状态, 已经是availiable, 同时获得它的位置: 10.254.0.6:/shares/share-47a89d70-7d04-4656-a279-b1d550cef98a.

[root@cloud ~(keystone_demo)]# manila list
+--------------------------------------+--------+------+-------------+-----------+-----------+--------------------------------------+---------------------------------------------------------------+-----------------------+-------------------+
| ID                                   | Name   | Size | Share Proto | Status    | Is Public | Share Type                           | Export location                                               | Host                  | Availability Zone |
+--------------------------------------+--------+------+-------------+-----------+-----------+--------------------------------------+---------------------------------------------------------------+-----------------------+-------------------+
| c26852a6-3274-4312-9343-d4d503f838e6 | share1 | 1    | NFS         | available | False     | d364b6d5-9897-4296-8e8f-348ddc87a33e | 10.254.0.6:/shares/share-47a89d70-7d04-4656-a279-b1d550cef98a | cloud@generic#generic | nova              |
+--------------------------------------+--------+------+-------------+-----------+-----------+--------------------------------------+---------------------------------------------------------------+-----------------------+-------------------+

此时查看admin用户的实例发现, 多了一个共享实例. 但是这个共享实例demo用户是看不到的. 如下图所示:
这里写图片描述
这里写图片描述
允许manila-instance访问这个共享实例:

[root@cloud network-scripts(keystone_demo)]# manila access-allow share1 ip 10.0.0.4
+--------------+--------------------------------------+
| Property     | Value                                |
+--------------+--------------------------------------+
| share_id     | c26852a6-3274-4312-9343-d4d503f838e6 |
| access_type  | ip                                   |
| access_to    | 10.0.0.4                             |
| access_level | rw                                   |
| state        | new                                  |
| id           | ba8aac94-20c8-4a40-8057-078863e90069 |
+--------------+--------------------------------------+

通过dashboard的nonvc进入到manila-instance中, 将共享挂载到manila-instance上.

manila@localhost:~$ sudo mount -t nfs 10.254.0.6:/shares/share-47a89d70-7d04-4656-a279-b1d550cef98a /home/share1

通过manila-instance在共享目录上创建文件file_by_manila-instance, 如下图所示:
这里写图片描述

根据之前manila.conf的配置, 这个共享文件夹应该位于共享实例的/shares目录下. 为了验证, 我们登录共享实例, 如下图所示:
这里写图片描述

从上图中可以看出, 我们所创建的manila共享其实就对应着共享实例主机上/shares目录下的一个文件夹. 这里有一个问题, 什么情况下会创建新的共享实例主机. 还是说所有的share都只放在一个共享实例上???

另外, 实际上manila access-allow的过程, 就是在共享实例的/etc/exports文件中创建了一条记录而已. 相应地, manila access-deny的过程就是删除了一条记录.

反过来, 对/etc/exports文件的修改也会影响manila共享的权限. 如, 手动删除10.0.0.4这个IP的访问权限并更新, 如下图所示:
这里写图片描述

此时manila-instance就无法访问这个共享文件夹了, 如下图所示:
这里写图片描述
但是此时manila access-list中仍然有这条记录, 但是显然它已经不起作用了, 真正决定访问权限的是共享实例上的/etc/exports文件.
这里写图片描述

另外, 当共享实例死机时, 对该主机的操作就会卡住, 如下图所示, 共享实例正在重启, 此时我们进行了[root@cloud network-scripts(keystone_demo)]# manila access-deny share1 4a31c008-358b-4087-81b2-e9f9d55e474e操作, 这个操作就会一直处于ing状态.
这里写图片描述

2.2 挂载已有的manila共享

[root@cloud ~(keystone_admin)]# manila manage cloud@generic#generic nfs 10.0.0.4:/home/shareFolder_in_client --share_type generic_share_type
+-----------------------------+--------------------------------------+
| Property                    | Value                                |
+-----------------------------+--------------------------------------+
| status                      | manage_starting                      |
| share_type_name             | generic_share_type                   |
| description                 | None                                 |
| availability_zone           | None                                 |
| share_network_id            | None                                 |
| export_locations            | []                                   |
| share_server_id             | None                                 |
| host                        | cloud@generic#generic                |
| snapshot_id                 | None                                 |
| is_public                   | False                                |
| task_state                  | None                                 |
| snapshot_support            | True                                 |
| id                          | 78144b33-0d10-46ad-9f90-5a7c157ed6b3 |
| size                        | None                                 |
| name                        | None                                 |
| share_type                  | d364b6d5-9897-4296-8e8f-348ddc87a33e |
| created_at                  | 2016-08-30T02:11:23.000000           |
| export_location             | 10.0.0.4:/home/shareFolder_in_client |
| share_proto                 | NFS                                  |
| consistency_group_id        | None                                 |
| source_cgsnapshot_member_id | None                                 |
| project_id                  | 6b527d01bf8d4f5d8b1ccbc63dc49bc7     |
| metadata                    | {}                                   |
+-----------------------------+--------------------------------------+

出错:
这里写图片描述

[root@cloud manila(keystone_admin)]# manila manage cloud@generic#generic nfs 10.0.0.4:/home/shareFolder_in_client --share_type manage_share_type
+-----------------------------+--------------------------------------+
| Property                    | Value                                |
+-----------------------------+--------------------------------------+
| status                      | manage_starting                      |
| share_type_name             | manage_share_type                    |
| description                 | None                                 |
| availability_zone           | None                                 |
| share_network_id            | None                                 |
| export_locations            | []                                   |
| share_server_id             | None                                 |
| host                        | cloud@generic#generic                |
| snapshot_id                 | None                                 |
| is_public                   | False                                |
| task_state                  | None                                 |
| snapshot_support            | True                                 |
| id                          | 78144b33-0d10-46ad-9f90-5a7c157ed6b3 |
| size                        | 1                                    |
| name                        | None                                 |
| share_type                  | 5781440e-bfe5-44e9-937f-1761fd09f265 |
| created_at                  | 2016-08-30T02:11:23.000000           |
| export_location             | 10.0.0.4:/home/shareFolder_in_client |
| share_proto                 | NFS                                  |
| consistency_group_id        | None                                 |
| source_cgsnapshot_member_id | None                                 |
| project_id                  | 6b527d01bf8d4f5d8b1ccbc63dc49bc7     |
| metadata                    | {}                                   |
+-----------------------------+--------------------------------------+

应该是driver的配置问题, 这两天重新看看官方文档, 试着解决一下这个问题.

相关文章
最新文章
热点推荐