且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

openstack i版常用命令

更新时间:2022-09-28 10:28:36

查看openstack的运行状态 

    nova节点 nova service-list (nova-scheduler、nova-conductor、nova-cert、nova-consoleauth)监控服务状态时除nova-consoleauth中有一台作为准备down状态外其余为up

    neutron节点 neutron agent-list (Metadata agent、DHCP agent、Open vSwitch agent) 监控状态时非:-)时为异常

     cinder节点  cinder service-list (cinder-backup、cinder-scheduler、cinder-volume) 监控状态时非up时为异常

      注:  

        监控采用api的方式获取,命令加入--debug即可获得api请求cinder --debug service-list 

    

查看云主机信息  

     特定tenant下所有云主机 nova list

       所有tenant下的云主机信息  nova list --all-tenants (admin keyfile)

       注:nova api配置限制返回条目nova.conf

1
2
3
# The maximum number of items returned in a single response
# from a collection resource (integer value)
osapi_max_limit=1000


      根据IP过滤查询   nova list --all-tenant --ip 10.199.133.152


      keyfile文件示例

1
2
3
4
5
6
cat keystonerc_admin 
export OS_USERNAME=admin
export OS_TENANT_NAME=admin
export OS_PASSWORD=openstack_pass
export OS_AUTH_URL=http://keystone_ip:5000/v2.0/
export PS1='[\u@\h \W(keystone_admin)]\$ '

    查看详细信息    nova show uuid

      

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
+--------------------------------------+-------------------------------------------------------------+
| Property                             | Value                                                       |
+--------------------------------------+-------------------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                                      |
| OS-EXT-AZ:availability_zone          | qa-zone                                                     |
| OS-EXT-SRV-ATTR:host                 | hh-yun-compute-130128.vclound.com                           |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | hh-yun-compute-130128.vclound.com                           |
| OS-EXT-SRV-ATTR:instance_name        | instance-00021e62                                           |
| OS-EXT-STS:power_state               | 1                                                           |
| OS-EXT-STS:task_state                | -                                                           |
| OS-EXT-STS:vm_state                  | active                                                      |
| OS-SRV-USG:launched_at               | 2017-01-04T06:39:22.000000                                  |
| OS-SRV-USG:terminated_at             | -                                                           |
| QATOOL_NET network                   | 10.199.133.152                                              |
| accessIPv4                           |                                                             |
| accessIPv6                           |                                                             |
| availability_zone                    | qa-zone                                                     |
| config_drive                         |                                                             |
| created                              | 2017-01-04T06:38:18Z                                        |
| flavor                               | 4core-4g (dc98e6d6-143f-42c2-9482-ee6efb04ff7e)             |
| hostId                               | 38e138eb165ba7732ce3f40b6830eb158ef8788bdc4279c63e2a024f    |
id                                   | e2bbc0ff-a16a-4dea-8c5e-1e9bb7445c13                        |
| image                                | Centos7_Generic_1503 (5aa770b3-8636-4532-9ffd-e1b0dca982be) |
| key_name                             | -                                                           |
| metadata                             | {}                                                          |
| name                                 | harbor-ui.vclound.com                                       |
| os-extended-volumes:volumes_attached | [{"id""ee67e9a3-3b63-41dd-bd4a-ef778dbe89d4"}]            |
| progress                             | 0                                                           |
| security_groups                      | default                                                     |
| status                               | ACTIVE                                                      |
| tenant_id                            | 359df7f169214333a7562c7a3095beb8                            |
| updated                              | 2017-01-04T06:39:22Z                                        |
| user_id                              | e69ce5e92b4c427189269c0d6df38fb7                            |
+--------------------------------------+-------------------------------------------------------------+


查看flavor   nova flavor-list

查看镜像  nova image-list   glance image-list

查看网络  neutron net-list

查看用zone nova aggregate-list

查看zone下的物理主机  nova aggregate-details qa-zone

创建并启动一台名为adams_test_vm的云主机

创建云主机指定物理主机及密码   nova boot --flavor flavor_name --image image_name --security_group default --nic net-id=net_uuid --availability-zone  qa-nova:computer_name vm_host_name --user-data ./passwd.sh --poll

1
2
3
passwd.sh内容如下:
#!/bin/bash
echo qwe123qwe | passwd --stdin root


下载镜像  glance  image-download image_id --file Win7

上传镜像   glance image-create --name image_name --disk-format qcow2 --file /root/Win7 --container-format bare --is-public True

卸载云盘   nova  volume-detach  云主机uuid 云盘uuid

挂载云盘  nova volume-attach 云主机uuid 云盘uuid

查看用户信息 keystone user-get user_id

查看tenant信息 keystone tenant-get tenant_id 

查看compute节点列表 nova hypervisor-list

查看compute节点信息  nova hypervisor-show compute_node_name

查看宿主机节点上的所有云主机信息  nova hypervisor-servers compute_node_name

查看compute节点资源使用情况   nova hypervisor-stats 

删除云主机 nova delete uuid

创建云盘  cinder create size_by_G --availability-zone nova --volume-type ceph-sata --display-name harbor-ui-01 --display-description "ui log disk" --metadata create_user_login=jack01.wu readonly=False create_user_id=xxx  attached_mode=rw

迁移云主机  nova live-migration uuid  compute_node_name  (挂载有云硬盘的实例,需要先卸载后操作)

禁用compute节点服务  nova service-disable compute_node_name

IP分配信息 neutron port-list

租户列表   keystone tenant-list

配额信息   nova quota-show

变更实例配置  nova  resize  instance_uuid|instance_name  flavor_name|flavor_id

重新配置实例  nova  instance_uuid|instance_name  flavor_name|flavor_id --rebuild-password test 




Openstack超配设置

1
nova.conf(默认值)


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
CPU
# Virtual CPU to physical CPU allocation ratio which affects
# all CPU filters. This configuration specifies a global ratio
# for CoreFilter. For AggregateCoreFilter, it will fall back
# to this configuration value if no per-aggregate setting
# found. (floating point value)
#cpu_allocation_ratio=16.0
 
DISK  磁盘超配如云主机使用宿主机存储易导致灾难事故
# Virtual disk to physical disk allocation ratio (floating
# point value)
#disk_allocation_ratio=1.0
 
MEM
# Virtual ram to physical ram allocation ratio which affects
# all ram filters. This configuration specifies a global ratio
# for RamFilter. For AggregateRamFilter, it will fall back to
# this configuration value if no per-aggregate setting found.
# (floating point value)
#ram_allocation_ratio=1.5
 
# Enables dynamic memory allocation (ballooning) when set to a
# value greater than 1. The value expresses the ratio between
# the total RAM assigned to an instance and its startup RAM
# amount. For example a ratio of 2.0 for an instance with
# 1024MB of RAM implies 512MB of RAM allocated at startup
# (floating point value)
#dynamic_memory_ratio=1.0



      从14的开发测试环境开始使用openstack,整体架构初期采用openstack底层、页面抛弃原生Horizon自主开发集成后台界面,实现全套的从物理机裸机至云主机业务上线使用、监控报警的流程。初期采用puppet用于管理云主机,glusterfs文件存储作为后端存储。

      后续由于时间及研究未深入原因,puppet不适合用于管理3k+以上云主机,后续采用特定用户密钥+自研发布系统的方式管理云主机的管理软件。及机房断电时glusterfs的恢复能力、文件丢失情况严重问题后续后端采用ceph的rbd块存储的方式稳定提供高可用服务。

    大致功能模块如下:

openstack i版常用命令

          

 


本文转自 qwjhq 51CTO博客,原文链接:http://blog.51cto.com/bingdian/1708902