zoukankan      html  css  js  c++  java
  • openstack常用命令

    rabbitmq

    1、 查看rabbitmq 队列:rabbitmqctl list_queues

    [root@controller controller]# rabbitmqctl list_queues
    Listing queues ...
    conductor.controller    0
    cinder-scheduler_fanout_fbf3025e62be4f9aa7ad841eeeb1eb34        0
    l3_agent_fanout_81a584687c544976b6d6a847f8283cd6        0
    compute.computer        0
    q-agent-notifier-security_group-update_fanout_64677a2b82bf4d0bbafe4ef71a2b8b19  0
    q-plugin.controller     0
    q-agent-notifier-network-update.controller      0
    dhcp_agent.controller   0
    cinder-backup.block     0
    

      

    keystone

    查询

    1、查看keystone的用户:keystone user-list |K版之后使用openstack user list

    [root@controller controller]# openstack user list
    +----------------------------------+-----------+
    | ID                               | Name      |
    +----------------------------------+-----------+
    | 4016dee2a6444913947d62bdab109fb7 | demo      |
    | 61b3749275004c8fa557d717b1fb4266 | placement |
    | 6b2a753b9eb040eca477b72450526537 | cinder    |
    | 75ce1a9257654a1ca49a2d3bc26f60d8 | admin     |
    | a212b354b6f14c9595d72daab4de6974 | glance    |
    | bf4ed6138bff47d6aa427f08b0686c36 | nova      |
    | fb05722f414148b9b1d19c2a460eaa6b | neutron   |
    +----------------------------------+-----------+
    

    2、查看keystone endpoint:keystone endpoint-list | K版之后使用openstack endpoint list

    [root@controller controller]# openstack endpoint list
    +----------------------------------+-----------+--------------+--------------+---------+-----------+------------------------------------------+
    | ID                               | Region    | Service Name | Service Type | Enabled | Interface | URL                                      |
    +----------------------------------+-----------+--------------+--------------+---------+-----------+------------------------------------------+
    | 18b6b59223f64b4aab665cdf30db7c10 | RegionOne | neutron      | network      | True    | admin     | http://controller:9696                   |
    | 2d2452383f114e498ddd81f8d47e19d0 | RegionOne | glance       | image        | True    | admin     | http://controller:9292                   |
    | 30c918539ab044e385934ea285c5a4a0 | RegionOne | nova         | compute      | True    | admin     | http://controller:8774/v2.1              |
    | 47536e2c669e4a79a970fab381958852 | RegionOne | neutron      | network      | True    | public    | http://controller:9696                   |
    | 47a7a309498f4069b38112362ffa6419 | RegionOne | keystone     | identity     | True    | internal  | http://controller:5000/v3/               |
    | 5b99ba77f8f74470bccb67f338d5a96f | RegionOne | keystone     | identity     | True    | public    | http://controller:5000/v3/               |
    | 661833489ce74d559dd59cf5dd3a1357 | RegionOne | keystone     | identity     | True    | admin     | http://controller:35357/v3/              |
    | 66916e9294d14ae682a88be353a89cc7 | RegionOne | cinderv2     | volumev2     | True    | public    | http://controller:8776/v2/%(project_id)s |
    | 792cf9ab92844c7da3d522c048196dc8 | RegionOne | cinderv3     | volumev3     | True    | admin     | http://controller:8776/v3/%(project_id)s |
    | 7b211bace9644bde807a7a8c5fa2c476 | RegionOne | cinderv2     | volumev2     | True    | admin     | http://controller:8776/v2/%(project_id)s |
    | 881292b76223418e81f18706ee26a747 | RegionOne | nova         | compute      | True    | internal  | http://controller:8774/v2.1              |
    | a8047fe59ea44d239f5449d210490dee | RegionOne | nova         | compute      | True    | public    | http://controller:8774/v2.1              |
    | a9f6d5440cf24a8385d16762296dcde2 | RegionOne | glance       | image        | True    | public    | http://controller:9292                   |
    | b34474f6c6e543afb5c34a22a9c0cbc4 | RegionOne | placement    | placement    | True    | public    | http://controller:8778                   |
    | bbe0b6186a3d497b9f79def57e720eae | RegionOne | cinderv3     | volumev3     | True    | internal  | http://controller:8776/v3/%(project_id)s |
    | bde6dff3a8c6476f802208a196797b4a | RegionOne | cinderv3     | volumev3     | True    | public    | http://controller:8776/v3/%(project_id)s |
    | c8c8abe53ae44956be66fe9620e0f066 | RegionOne | glance       | image        | True    | internal  | http://controller:9292                   |
    | e57e51a705654e569adcc8ed9370bd2b | RegionOne | placement    | placement    | True    | internal  | http://controller:8778                   |
    | e8ac8483b8bb48faa1c05a28cbe9d952 | RegionOne | placement    | placement    | True    | admin     | http://controller:8778                   |
    | eaecb628fd2347da898e42fc271757ce | RegionOne | neutron      | network      | True    | internal  | http://controller:9696                   |
    | f6cee08fe2774ae5aeda9f4ddee0cfd0 | RegionOne | cinderv2     | volumev2     | True    | internal  | http://controller:8776/v2/%(project_id)s |
    +----------------------------------+-----------+--------------+--------------+---------+-----------+------------------------------------------+
    

    3、 查看keystone的role:keystone role-list | K版之后使用openstack role list

    [root@controller controller]# openstack role list
    +----------------------------------+-------+
    | ID                               | Name  |
    +----------------------------------+-------+
    | 230051a829764e6ba24e6318e8fe29d6 | admin |
    | 9667ade202aa4574911160cba2e514b2 | user  |
    +----------------------------------+-------+
    

    4、查看keystone 服务:keystone service-list | K版之后使用openstack service list

    [root@controller controller]# openstack service list
    +----------------------------------+-----------+-----------+
    | ID                               | Name      | Type      |
    +----------------------------------+-----------+-----------+
    | 01f5a2549c234ead96bc8ed6be41749e | neutron   | network   |
    | 021783702d5e405aaee5d1c829932fe7 | nova      | compute   |
    | 44cabeb23fdf42feb6c66bfbd8d915c8 | cinderv3  | volumev3  |
    | 5f784d8201c6400ca7ac568eec3b9e34 | placement | placement |
    | 8f461e94fc384d4b8fd03b261fa218a5 | keystone  | identity  |
    | 9de7b8bc712349018d4302e77d5ba695 | cinderv2  | volumev2  |
    | a5cbdf33358742b999d9502d7b246bb4 | glance    | image     |
    +----------------------------------+-----------+-----------+
    

    5、查看keystone租户:keystone tenant-list | K版之后使用openstack project list

    [root@controller controller]# openstack project list
    +----------------------------------+---------+
    | ID                               | Name    |
    +----------------------------------+---------+
    | b8b90ff18dc94d93a93e97af7dcc9fa8 | admin   |
    | ce0f09bc91d543a0b5917c3712a4de7a | demo    |
    | f18c49067ce34aa8943e8189757c8bf9 | service |
    +----------------------------------+---------+
    

    6、查看租户情况:keystone tenant-get 用户ID/用户名 | K版之后使用openstack project show 用户ID/用户名

    [root@controller controller]# openstack project show admin
    +-------------+-----------------------------------------------+
    | Field       | Value                                         |
    +-------------+-----------------------------------------------+
    | description | Bootstrap project for initializing the cloud. |
    | domain_id   | default                                       |
    | enabled     | True                                          |
    | id          | b8b90ff18dc94d93a93e97af7dcc9fa8              |
    | is_domain   | False                                         |
    | name        | admin                                         |
    | parent_id   | default                                       |
    | tags        | []                                            |
    +-------------+-----------------------------------------------+
    

     

    增加

    1、创建域 。openstack project –domain 域 –description “描述” 项目名

    [root@controller openstack]# openstack domain create --description "Test Domain" test
    +-------------+----------------------------------+
    | Field       | Value                            |
    +-------------+----------------------------------+
    | description | Test Domain                      |
    | enabled     | True                             |
    | id          | 2df857d76a6a45618fb7f44df7f4bf30 |
    | name        | test                             |
    +-------------+----------------------------------+
    

     2、创建项目(租户)。openstack project –domain 域 –description “描述” 项目名

    [root@controller openstack]# openstack project create --domain test --description "Test Project" projectTest
    +-------------+----------------------------------+
    | Field       | Value                            |
    +-------------+----------------------------------+
    | description | Test Project                     |
    | domain_id   | 2df857d76a6a45618fb7f44df7f4bf30 |
    | enabled     | True                             |
    | id          | e8a9be8ed46c42a5b2ec4af4e3ea84b0 |
    | is_domain   | False                            |
    | name        | projectTest                      |
    | parent_id   | 2df857d76a6a45618fb7f44df7f4bf30 |
    +-------------+----------------------------------+
    

     3、创建用户。openstack user create –domain 域 –password-prompt 用户名

    [root@controller openstack]# openstack user create --domain test --password-prompt admin
    User Password:
    Repeat User Password:
    +-----------+----------------------------------+
    | Field     | Value                            |
    +-----------+----------------------------------+
    | domain_id | 2df857d76a6a45618fb7f44df7f4bf30 |
    | enabled   | True                             |
    | id        | 954e3d42d4414f69875867e8cab1c0a8 |
    | name      | admin                            |
    +-----------+----------------------------------+
    

      4、创建角色。 openstack role create 角色名

    [root@controller openstack]# openstack role create Admin1
    +-----------+----------------------------------+
    | Field     | Value                            |
    +-----------+----------------------------------+
    | domain_id | None                             |
    | id        | e638fe3a771844bc9b51fd704e60ccb1 |
    | name      | Admin1                           |
    +-----------+----------------------------------+
    

     5、为某项目中的某用户指定角色。openstack role add –project 项目 –user 角色名用户ID 项目名项目ID

          [root@controller openstack]# openstack role add --project projectTest --user admin Admin1

    其他组件的keystone配置

    1、为组件创建用户。openstack user create –domain 域 –password-prompt 组件用户名

    [root@controller openstack]# openstack user create --domain test --password-prompt admin
    User Password:
    Repeat User Password:
    +-----------+----------------------------------+
    | Field     | Value                            |
    +-----------+----------------------------------+
    | domain_id | 2df857d76a6a45618fb7f44df7f4bf30 |
    | enabled   | True                             |
    | id        | 954e3d42d4414f69875867e8cab1c0a8 |
    | name      | admin                            |
    +-----------+----------------------------------+
    

      2、 将组件用户添加到service项目的admin角色中。

    openstack role add --project service --user 组件用户名 admin
    

      3、 为组件创建服务实体。openstack service create –name 服务名 –description “服务描述” 类型

    [root@controller openstack]#   openstack service create  --name serviceTest --description "service test" type
    +-------------+----------------------------------+
    | Field       | Value                            |
    +-------------+----------------------------------+
    | description | service test                     |
    | enabled     | True                             |
    | id          | 2776eda9d859402aa3e969b0b4611073 |
    | name        | serviceTest                      |
    | type        | type                             |
    +-------------+----------------------------------+
    

      

    删除

    1、删除服务。 openstack service delete 服务名服务ID 
    2、删除某用户的某角色 。 openstack role remove –project 项目名ID –user 用户名ID 角色名ID

    openstack role remove  --project projectTest --user admin Admin1

    3、删除某角色。 openstack role delete 角色名ID 

    4、删除某用户 。openstack user delete 用户名ID 
    5、删除某项目。 openstack project delete 项目名ID 

    6、删除域。

    [root@controller openstack]# openstack domain set --disable  test
    [root@controller openstack]# openstack domain delete test
    [root@controller openstack]# openstack domain list
    +----------------------------------+---------+---------+----------------+
    | ID                               | Name    | Enabled | Description    |
    +----------------------------------+---------+---------+----------------+
    | ab355ba21130434bbe54adcf0723713d | default | True    | Default Domain |
    +----------------------------------+---------+---------+----------------+
    

      

    错误检测

    1、查看keystone进程:ps -ef | grep -i keystone 
    2、查看日志是否有错误:grep ERROR /var/log/keystone/keystone.log

    glance

    1上传镜像

    openstack image create "cirros" 
    
    --file /root/cirros-0.3.4-x86_64-disk.img 
    
    --disk-format qcow2 --container-format bare 
    
    --public
    

      

    查询

    1、查看image:glance image-list 、openstack image list、nova image-list

    [root@controller openstack]# nova image-list
    +--------------------------------------+--------+--------+--------+
    | ID                                   | Name   | Status | Server |
    +--------------------------------------+--------+--------+--------+
    | c4d5f159-e1d9-4033-9e11-f9d1b63a777a | cirros | ACTIVE |        |
    +--------------------------------------+--------+--------+--------+
    [root@controller openstack]# glance image-list
    +--------------------------------------+--------+
    | ID                                   | Name   |
    +--------------------------------------+--------+
    | c4d5f159-e1d9-4033-9e11-f9d1b63a777a | cirros |
    +--------------------------------------+--------+
    [root@controller openstack]# openstack image list
    +--------------------------------------+--------+--------+
    | ID                                   | Name   | Status |
    +--------------------------------------+--------+--------+
    | c4d5f159-e1d9-4033-9e11-f9d1b63a777a | cirros | active |
    +--------------------------------------+--------+--------+
    

      2、查看image具体信息:openstack image show ID

    [root@controller openstack]# openstack image show c4d5f159-e1d9-4033-9e11-f9d1b63a777a 
    +------------------+------------------------------------------------------+
    | Field            | Value                                                |
    +------------------+------------------------------------------------------+
    | checksum         | ee1eca47dc88f4879d8a229cc70a07c6                     |
    | container_format | bare                                                 |
    | created_at       | 2017-08-16T02:52:58Z                                 |
    | disk_format      | qcow2                                                |
    | file             | /v2/images/c4d5f159-e1d9-4033-9e11-f9d1b63a777a/file |
    | id               | c4d5f159-e1d9-4033-9e11-f9d1b63a777a                 |
    | min_disk         | 0                                                    |
    | min_ram          | 0                                                    |
    | name             | cirros                                               |
    | owner            | f2c087c678a446929110f5fe67b456ee                     |
    | protected        | False                                                |
    | schema           | /v2/schemas/image                                    |
    | size             | 13287936                                             |
    | status           | active                                               |
    | tags             |                                                      |
    | updated_at       | 2017-08-16T02:52:59Z                                 |
    | virtual_size     | None                                                 |
    | visibility       | public                                               |
    +------------------+------------------------------------------------------+
    

      

    错误检测

    1、镜像上传后存放在/var/lib/glance/images中

    nova

    查看

    1、查看nova 服务:nova-manage service list、openstack compute service list

    [root@controller openstack]# nova-manage service list
    DEPRECATED: Use the nova service-* commands from python-novaclient instead or the os-services REST resource. The service subcommand will be removed in the 14.0 release.
    Binary           Host                                 Zone             Status     State Updated_At
    nova-scheduler   controller                           internal         enabled    :-)   2017-08-25 09:13:25
    nova-conductor   controller                           internal         enabled    :-)   2017-08-25 09:13:24
    nova-consoleauth controller                           internal         enabled    :-)   2017-08-25 09:13:25
    nova-osapi_compute 0.0.0.0                              internal         enabled    XXX   None      
    nova-metadata    0.0.0.0                              internal         enabled    XXX   None      
    nova-compute     compute1                             nova             enabled    :-)   2017-08-25 09:13:22
    [root@controller openstack]# openstack compute service list
    +----+------------------+------------+----------+---------+-------+----------------------------+
    | Id | Binary           | Host       | Zone     | Status  | State | Updated At                 |
    +----+------------------+------------+----------+---------+-------+----------------------------+
    |  1 | nova-scheduler   | controller | internal | enabled | up    | 2017-08-25T09:16:55.000000 |
    |  2 | nova-conductor   | controller | internal | enabled | up    | 2017-08-25T09:16:54.000000 |
    |  8 | nova-consoleauth | controller | internal | enabled | up    | 2017-08-25T09:16:55.000000 |
    | 18 | nova-compute     | compute1   | nova     | enabled | up    | 2017-08-25T09:16:52.000000 |
    +----+------------------+------------+----------+---------+-------+----------------------------+
    

      

    2、设置安全组规则 
    设置默认安全组虚拟机能ssh:

    • nova secgroup-add-rule default tcp 22 22 0.0.0.0/0
    • openstack security group rule create –proto tcp –dst-port 22 default

    设置虚拟机能ping icmp包

    • nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0
    • openstack security group rule create –proto icmp default

    3、显示安全组列表nova secgroup-list、openstack security group list

     [root@controller openstack]# openstack security group list
    +--------------------------------------+---------+------------------------+----------------------------------+
    | ID                                   | Name    | Description            | Project                          |
    +--------------------------------------+---------+------------------------+----------------------------------+
    | 403d6083-a10f-469e-89ea-bf6247ebdf36 | default | Default security group | f2c087c678a446929110f5fe67b456ee |
    +--------------------------------------+---------+------------------------+----------------------------------+
    [root@controller openstack]# nova secgroup-list
    +--------------------------------------+---------+------------------------+
    | Id                                   | Name    | Description            |
    +--------------------------------------+---------+------------------------+
    | 403d6083-a10f-469e-89ea-bf6247ebdf36 | default | Default security group |
    +--------------------------------------+---------+------------------------+ 
    

      4、显示安全组规则 
    nova secgroup-list-rules default

    [root@controller openstack]# nova secgroup-list-rules default
    +-------------+-----------+---------+-----------+--------------+
    | IP Protocol | From Port | To Port | IP Range  | Source Group |
    +-------------+-----------+---------+-----------+--------------+
    |             |           |         |           | default      |
    | tcp         | 22        | 22      | 0.0.0.0/0 |              |
    | icmp        | -1        | -1      | 0.0.0.0/0 |              |
    |             |           |         |           | default      |
    +-------------+-----------+---------+-----------+--------------+
    

      5、查看虚拟机配置种类:nova flavor-list

    [root@controller openstack]# nova flavor-list、openstack flavor list
    +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
    | ID | Name      | Memory_MB | Disk | Ephemeral | Swap | VCPUs | RXTX_Factor | Is_Public |
    +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
    | 0  | m1.nano   | 64        | 1    | 0         |      | 1     | 1.0         | True      |
    | 1  | m1.tiny   | 512       | 1    | 0         |      | 1     | 1.0         | True      |
    | 2  | m1.small  | 2048      | 20   | 0         |      | 1     | 1.0         | True      |
    | 3  | m1.medium | 4096      | 40   | 0         |      | 2     | 1.0         | True      |
    | 4  | m1.large  | 8192      | 80   | 0         |      | 4     | 1.0         | True      |
    | 5  | m1.xlarge | 16384     | 160  | 0         |      | 8     | 1.0         | True      |
    +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
    [root@controller openstack]# openstack flavor list
    +----+-----------+-------+------+-----------+-------+-----------+
    | ID | Name      |   RAM | Disk | Ephemeral | VCPUs | Is Public |
    +----+-----------+-------+------+-----------+-------+-----------+
    | 0  | m1.nano   |    64 |    1 |         0 |     1 | True      |
    | 1  | m1.tiny   |   512 |    1 |         0 |     1 | True      |
    | 2  | m1.small  |  2048 |   20 |         0 |     1 | True      |
    | 3  | m1.medium |  4096 |   40 |         0 |     2 | True      |
    | 4  | m1.large  |  8192 |   80 |         0 |     4 | True      |
    | 5  | m1.xlarge | 16384 |  160 |         0 |     8 | True      |
    +----+-----------+-------+------+-----------+-------+-----------+
    

      6、查看云系统中有哪些服务器 nova-manage service list |sort

    [root@controller openstack]# nova-manage service list|sort
    Binary           Host                                 Zone             Status     State Updated_At
    nova-compute     compute1                             nova             enabled    :-)   2017-08-30 02:42:47
    nova-conductor   controller                           internal         enabled    :-)   2017-08-30 02:42:45
    nova-consoleauth controller                           internal         enabled    :-)   2017-08-30 02:42:46
    nova-metadata    0.0.0.0                              internal         enabled    XXX   None      
    nova-osapi_compute 0.0.0.0                              internal         enabled    XXX   None      
    nova-scheduler   controller                           internal         enabled    :-)   2017-08-30 02:42:46
    

      7、查看nova版本 nova-manage –version

    nova-manage --version 
    13.1.4
    

      

    虚拟机控制命令

    1、查看虚拟机:nova list、openstack server list

    [root@controller openstack]# nova list
    +--------------------------------------+-------------------+---------+------------+-------------+------------------------+
    | ID                                   | Name              | Status  | Task State | Power State | Networks               |
    +--------------------------------------+-------------------+---------+------------+-------------+------------------------+
    | 3724c84e-ef2d-48eb-a130-eb078d7622fe | provider-instance | ERROR   | -          | NOSTATE     | provider=192.168.1.102 |
    | 84cd0fc6-3704-4756-9f27-27bbe43bb980 | provider-instance | SHUTOFF | -          | Shutdown    | provider=192.168.1.105 |
    +--------------------------------------+-------------------+---------+------------+-------------+------------------------+
    [root@controller openstack]# openstack server list
    +--------------------------------------+-------------------+---------+------------------------+
    | ID                                   | Name              | Status  | Networks               |
    +--------------------------------------+-------------------+---------+------------------------+
    | 84cd0fc6-3704-4756-9f27-27bbe43bb980 | provider-instance | SHUTOFF | provider=192.168.1.105 |
    | 3724c84e-ef2d-48eb-a130-eb078d7622fe | provider-instance | ERROR   | provider=192.168.1.102 |
    +--------------------------------------+-------------------+---------+------------------------+
    

      2、删除虚拟机:nova delete ID、openstack server delete ID

    +--------------------------------------+-------------------+---------+------------------------+
    | ID                                   | Name              | Status  | Networks               |
    +--------------------------------------+-------------------+---------+------------------------+
    | 84cd0fc6-3704-4756-9f27-27bbe43bb980 | provider-instance | SHUTOFF | provider=192.168.1.105 |
    | 3724c84e-ef2d-48eb-a130-eb078d7622fe | provider-instance | ERROR   | provider=192.168.1.102 |
    +--------------------------------------+-------------------+---------+------------------------+
    [root@controller openstack]# openstack server delete 3724c84e-ef2d-48eb-a130-eb078d7622fe 
    [root@controller openstack]# openstack server list
    +--------------------------------------+-------------------+---------+------------------------+
    | ID                                   | Name              | Status  | Networks               |
    +--------------------------------------+-------------------+---------+------------------------+
    | 84cd0fc6-3704-4756-9f27-27bbe43bb980 | provider-instance | SHUTOFF | provider=192.168.1.105 |
    +--------------------------------------+-------------------+---------+------------------------+
    

      3、创建snapshot nova image-create 7eb1d4b3-13fa-4e39-be17-3a27eb0db218 “snapshot 1”

    [root@controller openstack]# nova image-list
    +--------------------------------------+-----------+--------+--------------------------------------+
    | ID                                   | Name      | Status | Server                               |
    +--------------------------------------+-----------+--------+--------------------------------------+
    | c4d5f159-e1d9-4033-9e11-f9d1b63a777a | cirros    | ACTIVE |                                      |
    | 4ee5c4be-3edf-431f-bc74-46d38ae7ebff | snapshot1 | ACTIVE | 84cd0fc6-3704-4756-9f27-27bbe43bb980 |
    +--------------------------------------+-----------+--------+--------------------------------------+
    [root@controller openstack]# openstack server list
    +--------------------------------------+-------------------+---------+------------------------+
    | ID                                   | Name              | Status  | Networks               |
    +--------------------------------------+-------------------+---------+------------------------+
    | 84cd0fc6-3704-4756-9f27-27bbe43bb980 | provider-instance | SHUTOFF | provider=192.168.1.105 |
    +--------------------------------------+-------------------+---------+------------------------+
    [root@controller openstack]# nova image-create  84cd0fc6-3704-4756-9f27-27bbe43bb980  "snapshot 2"
    [root@controller openstack]# openstack image list
    +--------------------------------------+------------+--------+
    | ID                                   | Name       | Status |
    +--------------------------------------+------------+--------+
    | 6ff0c7eb-4214-43ce-a07c-b111beb6e90a | snapshot 2 | active |
    | 4ee5c4be-3edf-431f-bc74-46d38ae7ebff | snapshot1  | active |
    | c4d5f159-e1d9-4033-9e11-f9d1b63a777a | cirros     | active |
    +--------------------------------------+------------+--------+
    

      

    4、虚拟机重启,停止:

    • nova suspend 84cd0fc6-3704-4756-9f27-27bbe43bb980
    • nova resume 84cd0fc6-3704-4756-9f27-27bbe43bb980
    • nova reboot 84cd0fc6-3704-4756-9f27-27bbe43bb980

    • openstack server suspend 84cd0fc6-3704-4756-9f27-27bbe43bb980

    • openstack server resume 84cd0fc6-3704-4756-9f27-27bbe43bb980
    • openstack server reboot 84cd0fc6-3704-4756-9f27-27bbe43bb980

     

    openstack server  start 84cd0fc6-3704-4756-9f27-27bbe43bb980
    [root@controller openstack]# openstack server list
    +--------------------------------------+-------------------+--------+------------------------+
    | ID                                   | Name              | Status | Networks               |
    +--------------------------------------+-------------------+--------+------------------------+
    | 84cd0fc6-3704-4756-9f27-27bbe43bb980 | provider-instance | ACTIVE | provider=192.168.1.105 |
    +--------------------------------------+-------------------+--------+------------------------+
    

      5、获取实例的CPU、内存、磁盘I/O等信息。 nova diagnostics serverID

    nova diagnostics a55aeb82-303c-4bdc-92d2-280573a2ff8d 
    +---------------------------+---------------+
    | Property                  | Value         |
    +---------------------------+---------------+
    | cpu0_time                 | 5613600000000 |
    | memory                    | 524288        |
    | memory-actual             | 524288        |
    | memory-rss                | 72672         |
    | tapefb0d3f7-56_rx         | 90            |
    | tapefb0d3f7-56_rx_drop    | 0             |
    | tapefb0d3f7-56_rx_errors  | 0             |
    | tapefb0d3f7-56_rx_packets | 1             |
    | tapefb0d3f7-56_tx         | 0             |
    | tapefb0d3f7-56_tx_drop    | 0             |
    | tapefb0d3f7-56_tx_errors  | 0             |
    | tapefb0d3f7-56_tx_packets | 0             |
    | vda_errors                | -1            |
    | vda_read                  | 1024          |
    | vda_read_req              | 2             |
    | vda_write                 | 0             |
    | vda_write_req             | 0             |
    +---------------------------+---------------+
    

      

    6、查询实例的创建信息 nova show serverID

    [root@controller openstack]# nova show   a55aeb82-303c-4bdc-92d2-280573a2ff8d 
    +--------------------------------------+----------------------------------------------------------+
    | Property                             | Value                                                    |
    +--------------------------------------+----------------------------------------------------------+
    | OS-DCF:diskConfig                    | MANUAL                                                   |
    | OS-EXT-AZ:availability_zone          | nova                                                     |
    | OS-EXT-SRV-ATTR:host                 | compute1                                                 |
    | OS-EXT-SRV-ATTR:hostname             | provider-instance                                        |
    | OS-EXT-SRV-ATTR:hypervisor_hostname  | compute1                                                 |
    | OS-EXT-SRV-ATTR:instance_name        | instance-00000003                                        |
    | OS-EXT-SRV-ATTR:kernel_id            |                                                          |
    | OS-EXT-SRV-ATTR:launch_index         | 0                                                        |
    | OS-EXT-SRV-ATTR:ramdisk_id           |                                                          |
    | OS-EXT-SRV-ATTR:reservation_id       | r-b60qsvae                                               |
    | OS-EXT-SRV-ATTR:root_device_name     | /dev/vda                                                 |
    | OS-EXT-SRV-ATTR:user_data            | -                                                        |
    | OS-EXT-STS:power_state               | 1                                                        |
    | OS-EXT-STS:task_state                | -                                                        |
    | OS-EXT-STS:vm_state                  | active                                                   |
    | OS-SRV-USG:launched_at               | 2017-08-30T03:16:57.000000                               |
    | OS-SRV-USG:terminated_at             | -                                                        |
    | accessIPv4                           |                                                          |
    | accessIPv6                           |                                                          |
    | config_drive                         |                                                          |
    | created                              | 2017-08-30T03:16:44Z                                     |
    | description                          | provider-instance                                        |
    | flavor                               | m1.tiny (1)                                              |
    | hostId                               | 313f16dfa039b6343dadaa99f596545021ce67260dc5b91e2fe9bcc2 |
    | host_status                          | UP                                                       |
    | id                                   | a55aeb82-303c-4bdc-92d2-280573a2ff8d                     |
    | image                                | cirros (c4d5f159-e1d9-4033-9e11-f9d1b63a777a)            |
    | key_name                             | mykey                                                    |
    | locked                               | False                                                    |
    | metadata                             | {}                                                       |
    | name                                 | provider-instance                                        |
    | os-extended-volumes:volumes_attached | []                                                       |
    | progress                             | 0                                                        |
    | provider network                     | 192.168.1.106                                            |
    | security_groups                      | default                                                  |
    | status                               | ACTIVE                                                   |
    | tenant_id                            | f2c087c678a446929110f5fe67b456ee                         |
    | updated                              | 2017-08-30T03:16:57Z                                     |
    | user_id                              | cd4defe69232424e864726ebd078c010                         |
    +--------------------------------------+----------------------------------------------------------+
    [root@controller openstack]# openstack server show  serverID 
    +--------------------------------------+----------------------------------------------------------+
    | Field                                | Value                                                    |
    +--------------------------------------+----------------------------------------------------------+
    | OS-DCF:diskConfig                    | MANUAL                                                   |
    | OS-EXT-AZ:availability_zone          | nova                                                     |
    | OS-EXT-SRV-ATTR:host                 | compute1                                                 |
    | OS-EXT-SRV-ATTR:hypervisor_hostname  | compute1                                                 |
    | OS-EXT-SRV-ATTR:instance_name        | instance-00000003                                        |
    | OS-EXT-STS:power_state               | 1                                                        |
    | OS-EXT-STS:task_state                | None                                                     |
    | OS-EXT-STS:vm_state                  | active                                                   |
    | OS-SRV-USG:launched_at               | 2017-08-30T03:16:57.000000                               |
    | OS-SRV-USG:terminated_at             | None                                                     |
    | accessIPv4                           |                                                          |
    | accessIPv6                           |                                                          |
    | addresses                            | provider=192.168.1.106                                   |
    | config_drive                         |                                                          |
    | created                              | 2017-08-30T03:16:44Z                                     |
    | flavor                               | m1.tiny (1)                                              |
    | hostId                               | 313f16dfa039b6343dadaa99f596545021ce67260dc5b91e2fe9bcc2 |
    | id                                   | a55aeb82-303c-4bdc-92d2-280573a2ff8d                     |
    | image                                | cirros (c4d5f159-e1d9-4033-9e11-f9d1b63a777a)            |
    | key_name                             | mykey                                                    |
    | name                                 | provider-instance                                        |
    | os-extended-volumes:volumes_attached | []                                                       |
    | progress                             | 0                                                        |
    | project_id                           | f2c087c678a446929110f5fe67b456ee                         |
    | properties                           |                                                          |
    | security_groups                      | [{u'name': u'default'}]                                  |
    | status                               | ACTIVE                                                   |
    | updated                              | 2017-08-30T03:16:57Z                                     |
    | user_id                              | cd4defe69232424e864726ebd078c010                         |
    +--------------------------------------+----------------------------------------------------------+
    

      

    neutron

    1、列出当前租户所有的网络:neutron net-list、openstack network list

    [root@controller openstack]# neutron net-list
    +--------------------------------------+----------+-----------------------------------------------------+
    | id                                   | name     | subnets                                             |
    +--------------------------------------+----------+-----------------------------------------------------+
    | 701a839d-6a57-42cc-8278-e7dcdb7af216 | provider | e820c8ae-d020-430b-9b26-46f046e647a7 192.168.1.0/24 |
    +--------------------------------------+----------+-----------------------------------------------------+
    

      2、列出所有租户的所有网络:neutron net-list –all-tenants

    [root@controller openstack]# neutron net-list --all-tenants
    +--------------------------------------+----------+-----------------------------------------------------+
    | id                                   | name     | subnets                                             |
    +--------------------------------------+----------+-----------------------------------------------------+
    | 701a839d-6a57-42cc-8278-e7dcdb7af216 | provider | e820c8ae-d020-430b-9b26-46f046e647a7 192.168.1.0/24 |
    +--------------------------------------+----------+-----------------------------------------------------+
    

      3、创建一个网络:neutron net-create –shared(所有项目共享网络) –provider:physical_network(物理网络) public(物理网络的名称) –provider:network_type(创建的网络类型为flat,单一扁平网络)flat public-net(自定义一个名称)

    $ neutron net-create --shared --provider:physical_network provider 
      --provider:network_type flat provider
    Created a new network:
    +---------------------------+--------------------------------------+
    | Field                     | Value                                |
    +---------------------------+--------------------------------------+
    | admin_state_up            | True                                 |
    | id                        | 0e62efcd-8cee-46c7-b163-d8df05c3c5ad |
    | mtu                       | 1500                                 |
    | name                      | provider                             |
    | port_security_enabled     | True                                 |
    | provider:network_type     | flat                                 |
    | provider:physical_network | provider                             |
    | provider:segmentation_id  |                                      |
    | router:external           | False                                |
    | shared                    | True                                 |
    | status                    | ACTIVE                               |
    | subnets                   |                                      |
    | tenant_id                 | d84313397390425c8ed50b2f6e18d092     |
    +---------------------------+--------------------------------------+
    

      4、查看一个网络的详细信息:neutron net-show

    [root@controller openstack]# neutron net-show provider
    +-------------------------+--------------------------------------+
    | Field                   | Value                                |
    +-------------------------+--------------------------------------+
    | admin_state_up          | True                                 |
    | availability_zone_hints |                                      |
    | availability_zones      | nova                                 |
    | created_at              | 2017-08-23T08:46:56                  |
    | description             |                                      |
    | id                      | 701a839d-6a57-42cc-8278-e7dcdb7af216 |
    | ipv4_address_scope      |                                      |
    | ipv6_address_scope      |                                      |
    | mtu                     | 1500                                 |
    | name                    | provider                             |
    | port_security_enabled   | True                                 |
    | router:external         | False                                |
    | shared                  | True                                 |
    | status                  | ACTIVE                               |
    | subnets                 | e820c8ae-d020-430b-9b26-46f046e647a7 |
    | tags                    |                                      |
    | tenant_id               | f2c087c678a446929110f5fe67b456ee     |
    | updated_at              | 2017-08-23T08:46:56                  |
    +-------------------------+--------------------------------------+
    

    5、删除一个网络:neutron net-delete 
    6、创建一个子网:neutron subnet-create –name (子网名)–allocation-pool start=开始地址 ,end=结束地址 –dns-nameserver DNS服务器 –gateway网关 网络名 子网IP

    [root@controller openstack]# neutron subnet-create --name provider-subnet --allocation-pool start=192.168.1.100,end=192.168.1.200  --dns-nameserver 223.5.5.5 --gateway 192.168.1.1 provider 192.168.1.0/24
    Created a new subnet:
    +-------------------+----------------------------------------------------+
    | Field             | Value                                              |
    +-------------------+----------------------------------------------------+
    | allocation_pools  | {"start": "192.168.1.100", "end": "192.168.1.200"} |
    | cidr              | 192.168.1.0/24                                     |
    | created_at        | 2017-08-28T07:11:53                                |
    | description       |                                                    |
    | dns_nameservers   | 223.5.5.5                                          |
    | enable_dhcp       | True                                               |
    | gateway_ip        | 192.168.1.1                                        |
    | host_routes       |                                                    |
    | id                | 6360600b-9df0-4009-989d-ca1f17e17d6a               |
    | ip_version        | 4                                                  |
    | ipv6_address_mode |                                                    |
    | ipv6_ra_mode      |                                                    |
    | name              | provider-subnet                                    |
    | network_id        | d687404b-4f96-46c1-9b7d-557cd5dcfd24               |
    | subnetpool_id     |                                                    |
    | tenant_id         | f2c087c678a446929110f5fe67b456ee                   |
    | updated_at        | 2017-08-28T07:11:53                                |
    +-------------------+----------------------------------------------------+
    

    7、列出所有的agent 。neutron agent-list

    [root@controller openstack]# neutron agent-list
    +--------------------------------------+--------------------+------------+-------------------+-------+----------------+---------------------------+
    | id                                   | agent_type         | host       | availability_zone | alive | admin_state_up | binary                    |
    +--------------------------------------+--------------------+------------+-------------------+-------+----------------+---------------------------+
    | a6209814-6df3-4af2-9083-839947338347 | Linux bridge agent | controller |                   | :-)   | True           | neutron-linuxbridge-agent |
    | aa5068d0-8d37-45a7-a936-97bd7c6bf1cb | DHCP agent         | controller | nova              | :-)   | True           | neutron-dhcp-agent        |
    | c34a7b5e-f04c-4e03-96f9-c47dd3465e21 | Metadata agent     | controller |                   | :-)   | True           | neutron-metadata-agent    |
    | d5e0b85c-138d-4d83-a3b0-cc4c7269171b | Linux bridge agent | compute1   |                   | :-)   | True           | neutron-linuxbridge-agent |
    +--------------------------------------+--------------------+------------+-------------------+-------+----------------+---------------------------+
    

    cinder

    查询

    1、查看服务器服务 cinder-manage host list |sort

    [root@controller openstack]# cinder-manage host list|sort
    block1@lvm                  nova           
    controller                  nova           
    host                        zone  
    
    #结合nova-manage service list|sort 就可以知道云系统中有哪些服务器和服务
    

      

    keystone

     

     

  • 相关阅读:
    ruby
    快捷键_命令行
    Babylon
    遇见的一些关于js冲突的问题
    js中出生年月日的使用,以及性别的判断
    js中iframe的使用
    js中ul与li的使用
    jQuery,ajax,for循环使用典型案例
    Easy | LeetCode 118. 杨辉三角
    Easy | LeetCode 461. 汉明距离 | 位运算
  • 原文地址:https://www.cnblogs.com/heitaoq/p/8717121.html
Copyright © 2011-2022 走看看