一、Keystone服务运维

1.keystone运维命令

(1)创建用户

创建一个名为“alice”的账户,密码为“mypassword123”,邮箱为“alice@example.com”

  1. [root@controller ~]# source /etc/keystone/admin-openrc.sh
  2. [root@controller ~]# openstack user create --password mypassword123 --email alice@example.com --domain demo alice
  3. +-----------+----------------------------------+
  4. | Field | Value |
  5. +-----------+----------------------------------+
  6. | domain_id | 5cf2b1fbdc9e4f799187625e743a8be2 |
  7. | email | alice@example.com |
  8. | enabled | True |
  9. | id | a49a222f8e194342a5a113193897d915 |
  10. | name | alice |
  11. +-----------+----------------------------------+

创建用户的具体格式

  1. $openstack user create[--domain <domain>]
  2. [--password <password>]
  3. [--email <email-address>]
  4. [--enable | --disable]
  5. <name>

(2)创建项目

一个Project就是一个项目、团队或组织,当请求OpenStack服务时,必须定义一个项目。
创建一个名为“acme”项目。

  1. [root@controller ~]# openstack project create --domain demo acme
  2. +-------------+----------------------------------+
  3. | Field | Value |
  4. +-------------+----------------------------------+
  5. | description | |
  6. | domain_id | 5cf2b1fbdc9e4f799187625e743a8be2 |
  7. | enabled | True |
  8. | id | c6ddd5dfbd4b42ee8b2591681898faa1 |
  9. | is_domain | False |
  10. | name | acme |
  11. | parent_id | 5cf2b1fbdc9e4f799187625e743a8be2 |
  12. +-------------+----------------------------------+

创建项目的具体格式如下

  1. $ openstack project create [--domain <domain>]
  2. [--description <description>]
  3. [--enable | --disable]
  4. <project-name>

(3)创建角色

角色限定了用户的操作权限
创建一个角色“compute-user”

  1. [root@controller ~]# openstack role create compute-user
  2. +-----------+----------------------------------+
  3. | Field | Value |
  4. +-----------+----------------------------------+
  5. | domain_id | None |
  6. | id | a1f46d3cbe0d49c1bf619839bdb432e9 |
  7. | name | compute-user |
  8. +-----------+----------------------------------+

创建角色的具体格式如下

  1. $ openstack user create <name>

(4)绑定用户和项目权限

添加的用户需要分配一定的权限,这就需要把用户关联绑定到对应的项目和角色
给用户“alice”分配“acme”项目下的“compute-user”角色

  1. [root@controller ~]# openstack role add --user alice --project acme compute-user

具体格式如下

  1. $ openstack role add--user <user>--project <project><role>

2.Keystone基础查询命令

(1)用户列表查询

  1. [root@controller ~]# openstack user list
  2. +----------------------------------+---------+
  3. | ID | Name |
  4. +----------------------------------+---------+
  5. | 1ecbb92b750f4a1a99a917ee5cb802f4 | swift |
  6. | 32cb9c3c47f445f79108fcdfde214a8d | glance |
  7. | 501447f036f449f0885a0d85f457a6c1 | neutron |
  8. | 6119916d7a6f4b77b214ec5b8c712f4a | admin |
  9. | 68e98243b2a9431081957563a74dce74 | nova |
  10. | 7d1cfc1d4a2948b0a9b0261ba41fbc14 | demo |
  11. | 8d1508eed92e4cbebf09b13f343e24ce | cinder |
  12. | a49a222f8e194342a5a113193897d915 | alice |
  13. +----------------------------------+---------+

(2)项目列表查询

  1. [root@controller ~]# openstack project list
  2. +----------------------------------+---------+
  3. | ID | Name |
  4. +----------------------------------+---------+
  5. | 2d359a6bc6834d02946e6f1be3e4dd12 | service |
  6. | ad251afdba114cd2aa6e9a8ffcdf0d4b | demo |
  7. | c6ddd5dfbd4b42ee8b2591681898faa1 | acme |
  8. | f61a5380d7c04bfcb0a30e7e69d93c00 | admin |
  9. +----------------------------------+---------+

(3)角色列表查询

  1. [root@controller ~]# openstack role list
  2. +----------------------------------+--------------+
  3. | ID | Name |
  4. +----------------------------------+--------------+
  5. | 84a9ed8975a548e8ba62afab3a03abcf | user |
  6. | a1f46d3cbe0d49c1bf619839bdb432e9 | compute-user |
  7. | c44163d83f6c4b37a6f930bfbf36db55 | admin |
  8. +----------------------------------+--------------+

(4)端点地址查询

  1. [root@controller ~]# openstack endpoint list
  2. +----------------+-----------+--------------+--------------+---------+-----------+----------------+
  3. | ID | Region | Service Name | Service Type | Enabled | Interface | URL |
  4. +----------------+-----------+--------------+--------------+---------+-----------+----------------+
  5. | 049c92a079ee41 | RegionOne | keystone | identity | True | admin | http://control |
  6. | c68ab7e3c94d9b | | | | | | ler:35357/v3 |
  7. | b77e | | | | | | |
  8. | 0fea0c4b854b49 | RegionOne | keystone | identity | True | public | http://control |
  9. | 1496fb415834e5 | | | | | | ler:5000/v3 |
  10. | f571 | | | | | | |
  11. | 1e7751ba225f44 | RegionOne | swift | object-store | True | internal | http://control |
  12. | dcbe6098285bc1 | | | | | | ler:8080/v1/AU |
  13. | e0f9 | | | | | | TH_%(tenant_id |
  14. | | | | | | | )s |
  15. | 20984c6216b74d | RegionOne | cinder | volume | True | admin | http://control |
  16. | e8991ce3dd14e8 | | | | | | ler:8776/v1/%( |
  17. | 734f | | | | | | tenant_id)s |
  18. | 33f91a7199784e | RegionOne | cinderv2 | volumev2 | True | admin | http://control |
  19. | 7595d699e0a7a0 | | | | | | ler:8776/v2/%( |
  20. | a393 | | | | | | tenant_id)s |
  21. | 3614bba3510148 | RegionOne | glance | image | True | public | http://control |
  22. | 61a810408bde9c | | | | | | ler:9292 |
  23. | bc90 | | | | | | |
  24. | 3f16b05ebced4e | RegionOne | neutron | network | True | admin | http://control |
  25. | af8c216c47d390 | | | | | | ler:9696 |
  26. | a3a2 | | | | | | |
  27. | 548175fde11346 | RegionOne | glance | image | True | admin | http://control |
  28. | 92a9dab3f434b6 | | | | | | ler:9292 |
  29. | 3fa3 | | | | | | |
  30. | 5824767e3e0642 | RegionOne | swift | object-store | True | admin | http://control |
  31. | 4bbe68a76df53d | | | | | | ler:8080/v1 |
  32. | c17e | | | | | | |
  33. | 61737a88e7ed43 | RegionOne | cinderv2 | volumev2 | True | internal | http://control |
  34. | 7297441384fa27 | | | | | | ler:8776/v2/%( |
  35. | ea5c | | | | | | tenant_id)s |
  36. | 77da45a0ba3945 | RegionOne | cinder | volume | True | public | http://control |
  37. | 27a1c1bbfd6d86 | | | | | | ler:8776/v1/%( |
  38. | 0f5f | | | | | | tenant_id)s |
  39. | 78db13de098249 | RegionOne | keystone | identity | True | internal | http://control |
  40. | cabf1f83873d6e | | | | | | ler:5000/v3 |
  41. | f53e | | | | | | |
  42. | 80fd9b35795a42 | RegionOne | neutron | network | True | internal | http://control |
  43. | 3187ddf5f13036 | | | | | | ler:9696 |
  44. | bf84 | | | | | | |
  45. | 96cd56e2ceb941 | RegionOne | glance | image | True | internal | http://control |
  46. | 7a8437f81836ae | | | | | | ler:9292 |
  47. | 16d9 | | | | | | |
  48. | 9a3d69a68f2746 | RegionOne | nova | compute | True | admin | http://control |
  49. | 1dad32aa6bad0e | | | | | | ler:8774/v2.1/ |
  50. | 5c2b | | | | | | %(tenant_id)s |
  51. | 9d69c6ba14904e | RegionOne | nova | compute | True | public | http://control |
  52. | 9aa7b9a36ae59b | | | | | | ler:8774/v2.1/ |
  53. | b330 | | | | | | %(tenant_id)s |
  54. | 9e955b74718c47 | RegionOne | swift | object-store | True | public | http://control |
  55. | 038ca6188095bb | | | | | | ler:8080/v1/AU |
  56. | b138 | | | | | | TH_%(tenant_id |
  57. | | | | | | | )s |
  58. | bb4fa0bf376e49 | RegionOne | neutron | network | True | public | http://control |
  59. | 18b64c7f848455 | | | | | | ler:9696 |
  60. | b8c1 | | | | | | |
  61. | bde192873e8e4e | RegionOne | cinderv2 | volumev2 | True | public | http://control |
  62. | cd97449aa75f05 | | | | | | ler:8776/v2/%( |
  63. | 90bf | | | | | | tenant_id)s |
  64. | d9cd83c2ae9b47 | RegionOne | cinder | volume | True | internal | http://control |
  65. | 24827eccb78639 | | | | | | ler:8776/v1/%( |
  66. | 98b6 | | | | | | tenant_id)s |
  67. | ecca7332787144 | RegionOne | nova | compute | True | internal | http://control |
  68. | 5491b1c1d51528 | | | | | | ler:8774/v2.1/ |
  69. | 5ddc | | | | | | %(tenant_id)s |
  70. +----------------+-----------+--------------+--------------+---------+-----------+----------------+

二、Glance服务运维

1.Glance管理镜像

(1)创建镜像

创建一个名称为“cirros”镜像,镜像文件使用提供的“cirros-0.3.4-x86_64-disk.img”。

  1. [root@controller ~]# glance image-create --name "cirros" --disk-format qcow2 --container-format bare --progress < cirros-0.3.4-x86_64-disk.img
  2. [=============================>] 100%
  3. +------------------+--------------------------------------+
  4. | Property | Value |
  5. +------------------+--------------------------------------+
  6. | checksum | ee1eca47dc88f4879d8a229cc70a07c6 |
  7. | container_format | bare |
  8. | created_at | 2019-11-01T06:13:49Z |
  9. | disk_format | qcow2 |
  10. | id | bdd8d652-7d10-4a77-8a9b-b8563df42d5a |
  11. | min_disk | 0 |
  12. | min_ram | 0 |
  13. | name | cirros |
  14. | owner | f61a5380d7c04bfcb0a30e7e69d93c00 |
  15. | protected | False |
  16. | size | 13287936 |
  17. | status | active |
  18. | tags | [] |
  19. | updated_at | 2019-11-01T06:14:00Z |
  20. | virtual_size | None |
  21. | visibility | private |
  22. +------------------+--------------------------------------+

(2)查看镜像列表

  1. [root@controller ~]# glance image-list
  2. +--------------------------------------+-----------+
  3. | ID | Name |
  4. +--------------------------------------+-----------+
  5. | 81ec2073-4ae8-4bac-83ab-b84ca3d45f1d | centos7.2 |
  6. | bdd8d652-7d10-4a77-8a9b-b8563df42d5a | cirros |
  7. +--------------------------------------+-----------+

2.Glance镜像运维

(1)查看镜像详情

通过glance image-show命令查看镜像的详细信息

  1. # glance image-show bdd8d652-7d10-4a77-8a9b-b8563df42d5a

查询结果如下所示

  1. +------------------+--------------------------------------+
  2. | Property | Value |
  3. +------------------+--------------------------------------+
  4. | checksum | ee1eca47dc88f4879d8a229cc70a07c6 |
  5. | container_format | bare |
  6. | created_at | 2019-11-01T06:13:49Z |
  7. | disk_format | qcow2 |
  8. | id | bdd8d652-7d10-4a77-8a9b-b8563df42d5a |
  9. | min_disk | 0 |
  10. | min_ram | 0 |
  11. | name | cirros |
  12. | owner | f61a5380d7c04bfcb0a30e7e69d93c00 |
  13. | protected | False |
  14. | size | 13287936 |
  15. | status | active |
  16. | tags | [] |
  17. | updated_at | 2019-11-01T06:14:00Z |
  18. | virtual_size | None |
  19. | visibility | private |
  20. +------------------+--------------------------------------+

(2)更改镜像

可以使用glance image-update更新镜像信息,使用glance image-delete删除镜像信息。如果需要改变镜像启动硬盘最低要求值(min-disk)时,min-disk默认单位为G。使用glance image-update命令更新镜像信息

  1. # glance image-update --min-disk=1 bdd8d652-7d10-4a77-8a9b-b8563df42d5a

查询结果如下

  1. +------------------+--------------------------------------+
  2. | Property | Value |
  3. +------------------+--------------------------------------+
  4. | checksum | ee1eca47dc88f4879d8a229cc70a07c6 |
  5. | container_format | bare |
  6. | created_at | 2019-11-01T06:13:49Z |
  7. | disk_format | qcow2 |
  8. | id | bdd8d652-7d10-4a77-8a9b-b8563df42d5a |
  9. | min_disk | 1 |
  10. | min_ram | 0 |
  11. | name | cirros |
  12. | owner | f61a5380d7c04bfcb0a30e7e69d93c00 |
  13. | protected | False |
  14. | size | 13287936 |
  15. | status | active |
  16. | tags | [] |
  17. | updated_at | 2019-11-01T06:16:55Z |
  18. | virtual_size | None |
  19. | visibility | private |
  20. +------------------+--------------------------------------+

(3)删除镜像

  1. [root@controller ~]# glance image-delete bdd8d652-7d10-4a77-8a9b-b8563df42d5a
  2. [root@controller ~]# glance image-list
  3. +--------------------------------------+-----------+
  4. | ID | Name |
  5. +--------------------------------------+-----------+
  6. | 81ec2073-4ae8-4bac-83ab-b84ca3d45f1d | centos7.2 |
  7. +--------------------------------------+-----------+

三、Nova服务运维

1.Nova运维命令

(1)Nova安全组规则

  1. 安全组(security group)是一些规则的集合,用来对虚拟机的访问流量加以限制,这反映到底层,就是使用iptables,给虚拟机所在的宿主机添加iptables规则。可以定义n个安全组,每个安全组可以有n个规则,可以给每个实例绑定n个安全组。Nova中总是有一个default安全组,这个是不能被删除的。创建实例的时候,如果不指定安全组,会默认使用这个default安全组。现在Nova中安全组应该会移到Neutron中,并且会增加对虚拟机外出流量的控制。

注意:Nova中的安全组只是对进入虚拟机的流量加以控制,对虚拟机外出流量没有加以限制。
创建安全组

  1. # nova secgroup-create
  2. ##创建一个名为test的安全组,描述为'test the nova command about the rules'
  3. # nova secgroup-create test 'test the nova command about the rules'
  4. +--------------------------------------+------+---------------------------------------+
  5. | Id | Name | Description |
  6. +--------------------------------------+------+---------------------------------------+
  7. | d1ce4ef1-26c8-4b3d-958b-bc778bf283f3 | test | test the nova command about the rules |
  8. +--------------------------------------+------+---------------------------------------+

(2)Nova管理虚拟机类型

  1. #创建一个虚拟机类型
  2. # nova flavor-create
  3. #使用命令创建一个名为test,ID为6,内存为2048 MB,磁盘为20 GB,vCPU数量为2的云主机类型
  4. # nova flavor-create test 6 2048 20 2
  5. +----+------+-----------+------+-----------+------+-------+-------------+-----------+
  6. | ID | Name | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
  7. +----+------+-----------+------+-----------+------+-------+-------------+-----------+
  8. | 6 | test | 2048 | 20 | 0 | | 2 | 1.0 | True |
  9. +----+------+-----------+------+-----------+------+-------+-------------+-----------+

查看test云主机类型的详细信息

  1. # nova flavor-show test
  2. +----------------------------+-------+
  3. | Property | Value |
  4. +----------------------------+-------+
  5. | OS-FLV-DISABLED:disabled | False |
  6. | OS-FLV-EXT-DATA:ephemeral | 0 |
  7. | disk | 20 |
  8. | extra_specs | {} |
  9. | id | 6 |
  10. | name | test |
  11. | os-flavor-access:is_public | True |
  12. | ram | 2048 |
  13. | rxtx_factor | 1.0 |
  14. | swap | |
  15. | vcpus | 2 |
  16. +----------------------------+-------+

2.Nova管理

(1)启动实例

  1. # nova boot

(2)删除实例

  1. # nova delete

四、Neutron服务运维

1.Neutron查询

使用Neutron相关命令查询网络服务的列表信息中的“binary”一列

  1. [root@xiandian ~]# neutron agent-list -c binary
  2. +---------------------------+
  3. | binary |
  4. +---------------------------+
  5. | neutron-l3-agent |
  6. | neutron-openvswitch-agent |
  7. | neutron-dhcp-agent |
  8. | neutron-metadata-agent |
  9. +---------------------------+

2.查询网路详情

  1. [root@xiandian ~]# neutron net-list
  2. +--------------------------------------+------------+---------+
  3. | id | name | subnets |
  4. +--------------------------------------+------------+---------+
  5. | bd923693-d9b1-4094-bd5b-22a038c44827 | sharednet1 | |
  6. +--------------------------------------+------------+---------+
  7. # neutron net-show bd923693-d9b1-4094-bd5b-22a038c44827
  8. +---------------------------+--------------------------------------+
  9. | Field | Value |
  10. +---------------------------+--------------------------------------+
  11. | admin_state_up | True |
  12. | availability_zone_hints | |
  13. | availability_zones | |
  14. | created_at | 2017-02-23T04:58:17 |
  15. | description | |
  16. | id | bd923693-d9b1-4094-bd5b-22a038c44827 |
  17. | ipv4_address_scope | |
  18. | ipv6_address_scope | |
  19. | mtu | 1500 |
  20. | name | sharednet1 |
  21. | port_security_enabled | True |
  22. | provider:network_type | flat |
  23. | provider:physical_network | physnet1 |
  24. | provider:segmentation_id | |
  25. | router:external | False |
  26. | shared | True |
  27. | status | ACTIVE |
  28. | subnets | |
  29. | tags | |
  30. | tenant_id | 20b1ab08ea644670addb52f6d2f2ed61 |
  31. | updated_at | 2017-02-23T04:58:17 |
  32. +---------------------------+--------------------------------------+

3.查询Neutron相关组件服务

使用Neutron相关命令查询网络服务DHCP agent的详细信息(id为查询到DHCP agent服务对应id)

  1. [root@xiandian ~]# neutron agent-list
  2. +--------------------------------------+--------------------+----------+-------------------+-------+----------------+---------------------------+
  3. | id | agent_type | host | availability_zone | alive | admin_state_up | binary |
  4. +--------------------------------------+--------------------+----------+-------------------+-------+----------------+---------------------------+
  5. | 7dd3ea38-c6fc-4a73-a530-8b007afeb778 | L3 agent | xiandian | nova | :-) | True | neutron-l3-agent |
  6. | 8c0781e7-8b3e-4c9f-a8da-0d4cdc570afb | Open vSwitch agent | xiandian | | :-) | True | neutron-openvswitch-agent |
  7. | a3504292-e108-4ad1-ae86-42ca9ccfde78 | DHCP agent | xiandian | nova | :-) | True | neutron-dhcp-agent |
  8. | be17aa73-deba-411a-ac10-fd523079085d | Metadata agent | xiandian | | :-) | True | neutron-metadata-agent |
  9. +--------------------------------------+--------------------+----------+-------------------+-------+----------------+---------------------------+
  10. [root@xiandian ~]# neutron agent-show a3504292-e108-4ad1-ae86-42ca9ccfde78
  11. +---------------------+----------------------------------------------------------+
  12. | Field | Value |
  13. +---------------------+----------------------------------------------------------+
  14. | admin_state_up | True |
  15. | agent_type | DHCP agent |
  16. | alive | True |
  17. | availability_zone | nova |
  18. | binary | neutron-dhcp-agent |
  19. | configurations | { |
  20. | | "subnets": 1, |
  21. | | "dhcp_lease_duration": 86400, |
  22. | | "dhcp_driver": "neutron.agent.linux.dhcp.Dnsmasq", |
  23. | | "networks": 1, |
  24. | | "log_agent_heartbeats": false, |
  25. | | "ports": 2 |
  26. | | } |
  27. | created_at | 2017-02-23 04:57:05 |
  28. | description | |
  29. | heartbeat_timestamp | 2019-09-28 21:33:06 |
  30. | host | xiandian |
  31. | id | a3504292-e108-4ad1-ae86-42ca9ccfde78 |
  32. | started_at | 2017-02-23 04:57:05 |
  33. | topic | dhcp_agent |
  34. +---------------------+----------------------------------------------------------+

五、Cinder服务运维

1.创建云硬盘

创建一个2 GB的云硬盘extend-demo

  1. # cinder create --name cinder-volume-demo 2
  2. +--------------------------------+--------------------------------------+
  3. | Property | Value |
  4. +--------------------------------+--------------------------------------+
  5. | attachments | [] |
  6. | availability_zone | nova |
  7. | bootable | false |
  8. | consistencygroup_id | None |
  9. | created_at | 2019-09-28T18:59:13.000000 |
  10. | description | None |
  11. | encrypted | False |
  12. | id | 5df3295d-3c92-41f5-95af-c371a3e8b47f |
  13. | metadata | {} |
  14. | migration_status | None |
  15. | multiattach | False |
  16. | name | cinder-volume-demo |
  17. | os-vol-host-attr:host | xiandian@lvm#LVM |
  18. | os-vol-mig-status-attr:migstat | None |
  19. | os-vol-mig-status-attr:name_id | None |
  20. | os-vol-tenant-attr:tenant_id | 0ab2dbde4f754b699e22461426cd0774 |
  21. | replication_status | disabled |
  22. | size | 2 |
  23. | snapshot_id | None |
  24. | source_volid | None |
  25. | status | creating |
  26. | updated_at | 2019-09-28T18:59:14.000000 |
  27. | user_id | 53a1cf0ad2924532aa4b7b0750dec282 |
  28. | volume_type | None |
  29. +--------------------------------+--------------------------------------+

通过cinder-list查看云硬盘信息

  1. # cinder list
  2. +--------------------------------------+-----------+--------------------+------+-------------+----------+-------------+
  3. | ID | Status | Name | Size | Volume Type | Bootable | Attached to |
  4. +--------------------------------------+-----------+--------------------+------+-------------+----------+-------------+
  5. | 5df3295d-3c92-41f5-95af-c371a3e8b47f | available | cinder-volume-demo | 2 | - | false | |
  6. +--------------------------------------+-----------+--------------------+------+-------------+----------+-------------+

2.创建云硬盘卷类型

创建type标识的卷类型。
可以通过cinder type-create命令来创建卷类型,创建了一个名为“lvm”的卷类型

  1. # cinder type-create lvm
  2. +--------------------------------------+------+-------------+-----------+
  3. | ID | Name | Description | Is_Public |
  4. +--------------------------------------+------+-------------+-----------+
  5. | b247520f-84dd-41cb-a706-4437e7320fa8 | lvm | - | True |
  6. +--------------------------------------+------+-------------+-----------+

可以通过cinder type-list命令来查看现有的卷类型。

  1. # cinder type-list
  2. +--------------------------------------+------+-------------+-----------+
  3. | ID | Name | Description | Is_Public |
  4. +--------------------------------------+------+-------------+-----------+
  5. | b247520f-84dd-41cb-a706-4437e7320fa8 | lvm | - | True |
  6. +--------------------------------------+------+-------------+-----------+

3.创建带标识的云硬盘

以type标识为例,创建一块带“lvm”标识的云硬盘

  1. # cinder create --name type_test_demo --volume-type lvm 1
  2. +--------------------------------+--------------------------------------+
  3. | Property | Value |
  4. +--------------------------------+--------------------------------------+
  5. | attachments | [] |
  6. | availability_zone | nova |
  7. | bootable | false |
  8. | consistencygroup_id | None |
  9. | created_at | 2019-09-28T19:15:14.000000 |
  10. | description | None |
  11. | encrypted | False |
  12. | id | 12d09316-1c9f-43e1-93bd-24e54cbf7ef6 |
  13. | metadata | {} |
  14. | migration_status | None |
  15. | multiattach | False |
  16. | name | type_test_demo |
  17. | os-vol-host-attr:host | None |
  18. | os-vol-mig-status-attr:migstat | None |
  19. | os-vol-mig-status-attr:name_id | None |
  20. | os-vol-tenant-attr:tenant_id | 0ab2dbde4f754b699e22461426cd0774 |
  21. | replication_status | disabled |
  22. | size | 1 |
  23. | snapshot_id | None |
  24. | source_volid | None |
  25. | status | creating |
  26. | updated_at | None |
  27. | user_id | 53a1cf0ad2924532aa4b7b0750dec282 |
  28. | volume_type | lvm |
  29. +--------------------------------+--------------------------------------+

创建成功后可以通过命令查看结果,可以看到该卷的volume_type字段已修改为“lvm”

  1. # cinder show type_test_demo
  2. +--------------------------------+--------------------------------------+
  3. | Property | Value |
  4. +--------------------------------+--------------------------------------+
  5. | attachments | [] |
  6. | availability_zone | nova |
  7. | bootable | false |
  8. | consistencygroup_id | None |
  9. | created_at | 2019-09-28T19:15:14.000000 |
  10. | description | None |
  11. | encrypted | False |
  12. | id | 12d09316-1c9f-43e1-93bd-24e54cbf7ef6 |
  13. | metadata | {} |
  14. | migration_status | None |
  15. | multiattach | False |
  16. | name | type_test_demo |
  17. | os-vol-host-attr:host | xiandian@lvm#LVM |
  18. | os-vol-mig-status-attr:migstat | None |
  19. | os-vol-mig-status-attr:name_id | None |
  20. | os-vol-tenant-attr:tenant_id | 0ab2dbde4f754b699e22461426cd0774 |
  21. | replication_status | disabled |
  22. | size | 1 |
  23. | snapshot_id | None |
  24. | source_volid | None |
  25. | status | available |
  26. | updated_at | 2019-09-28T19:15:15.000000 |
  27. | user_id | 53a1cf0ad2924532aa4b7b0750dec282 |
  28. | volume_type | lvm |
  29. +--------------------------------+--------------------------------------+

删除指定的Cinder卷,可以通过命令“cinder delete [ …]”来删除一个或多个Cinder卷

  1. # cinder delete cinder-volume-demo
  2. Request to delete volume cinder-volume-demo has been accepted.

六、Swift服务运维

1.Swift查询命令

(1)创建容器

通过命令行实现对Swift上数据的操作,首先需要创建一个名称为“test”的容器

  1. # swift post test

(2)查询容器

  1. # swift list test

通过显示结果可以看出目前“test”容器里面的内容是空的,这时用户希望将本地的file目录内容递归上传到“test”容器内。首先创建file目录,并同时新建3个文件one.txt、two.doc和three.png。

  1. # mkdir file
  2. #touch one.txt
  3. # touch two.doc
  4. # touch three.png

2.Swift上传和下载

(1)上传文件至容器

上传时首先需要上传一个空白的“file”目录

  1. # swift upload test file/

将one.txt文件上传到“test”容器内file目录内

  1. # swift upload test/file one.txt

换一种方式将剩下的two.doc和three.png递归上传到“test”容器下的file目录内

  1. # mv two.doc three.png file/
  2. # swift upload test file/
  3. file/three.png
  4. file/two.doc

(2)从容器中下载文件

数据在Swift集群内保存,随时供用户下载使用,现在下载three.png文件

  1. # swift download test file/three.png
  2. file/three.png [auth 0.445s, headers 0.870s, total 0.871s, 0.000 MB/s]

(3)从容器中删除文件

目前磁盘容量有限,需要删除一些相对价值低的数据,空出更多的空间。这时已经将three.png下载到本地,所以暂时将three.png从对象存储服务器中删除

  1. # swift delete test file/three.png
  2. file/three.png

(4)查看容器服务状态

用户还可以通过swift stat命令来查看整个Account账户下Swift状态

  1. # swift stat
  2. Account: AUTH_0ab2dbde4f754b699e22461426cd0774
  3. Containers: 1
  4. Objects: 3
  5. Bytes: 0
  6. Containers in policy "policy-0": 1
  7. Objects in policy "policy-0": 3
  8. Bytes in policy "policy-0": 0
  9. X-Account-Project-Domain-Id: 3ac89594c8e944a9b5bb567fca4e75aa
  10. X-Timestamp: 1569699525.96576
  11. X-Trans-Id: txe80d8e2c7285497895340-005d8fc0fb
  12. Content-Type: text/plain; charset=utf-8
  13. Accept-Ranges: bytes