openstack 命令行管理nova - quota资源管理 (备忘)

本文介绍了OpenStack Nova中quota配额的作用,它可对每个tenants的浮动IP、内存等资源进行限制。还提及了帮助文档、可管理资源、查看配额信息及更新方法,建议通过horizon进行租户配额限制,也可通过数据库查询,同时给出了不同资源查询的对应表。

quota配额用于对每个 tenants 进行限制, 如浮动 IP, 内存, CPU, 磁盘, 密钥, 安全规则, 云硬盘等

帮助文档

(my_new_env) likailiang@pubbeta1-nova10:~$ nova -h | grep quota
    quota-class-show    List the quotas for a quota class.
    quota-class-update  Update the quotas for a quota class.
    quota-defaults      List the default quotas for a tenant.
    quota-delete        Delete quota for a tenant/user so their quota will
    quota-show          List the quotas for a tenant/user.
    quota-update        Update the quotas for a tenant/user.

可管理资源

fixed-ips                               每个 project 可用固定 IP 地址, 必须大于等于实例可用的 IP 地址数量
floating-ips                 每个 project 可用的浮动 IP 地址
injected-file-content-bytes             添加的文件最大可包含多少 bytes 
injected-file-path-bytes                指定的文件目录下最大可包含的文件 bytes
injected-files                          每个 project 可以包含的文件数量
instances                               每个 project 可包含的最多的 instances 数量
key-pairs                               每个用户可用的  key-pairs 的数量
metadata-items                          每个实例可拥有的 metadata-items  数量
ram                                     允许每个 project 中的 instances 可用的 ram (MB) 数量
security-group-rules                    可用的安全组规则
security-groups                         每个 project 的安全组
cores                                   每个 project 可用的虚拟 CPU 个数

查看配额信息

[root@station140 ~(keystone_admin)]# nova quota-defaults
+-----------------------------+-------+
| Quota                       | Limit |
+-----------------------------+-------+
| instances                   | 10    |
| cores                       | 20    |
| ram                         | 51200 |
| floating_ips                | 10    |
| fixed_ips                   | -1    |
| metadata_items              | 128   |
| injected_files              | 5     |
| injected_file_content_bytes | 10240 |
| injected_file_path_bytes    | 255   |
| key_pairs                   | 100   |
| security_groups             | 10    |
| security_group_rules        | 20    |
+-----------------------------+-------+

更新方法

[root@station140 ~(keystone_admin)]# nova quota-class-update --instances 20 default
[root@station140 ~(keystone_admin)]# nova quota-defaults
+-----------------------------+-------+
| Quota                       | Limit |
+-----------------------------+-------+
| instances                   | 20    |
--------------------- 

建议直接通过 horizon 对每个租户进行配额限制,  方便简单, 准确。通过数据库方法对 quota 进行查询会更加准确。

表一, 用于查询 内核, 实例, 内存, 安全组资源

mysql> select a.name, b.resource, b.hard_limit from keystone.project a, nova.quotas b where a.enabled=1  and  b.deleted=0 and a.id=b.project_id and a.name='admin';
+-------+-----------------------------+------------+
| name  | resource                    | hard_limit |
+-------+-----------------------------+------------+
| admin | cores                       |        500 |
| admin | injected_files              |         50 |
| admin | injected_file_content_bytes |      10240 |
| admin | instances                   |        200 |
| admin | metadata_items              |        128 |
| admin | ram                         |    1024000 |
| admin | security_groups             |         10 |
| admin | security_group_rules        |         20 |
+-------+-----------------------------+------------+
8 rows in set (0.00 sec)

表二, 用于查询云盘大小, 云盘快照, 云盘数量配额

mysql> select a.name, b.resource, b.hard_limit from keystone.project a, cinder.quotas b where a.enabled=1  and  b.deleted=0 and a.id=b.project_id and a.name='admin';
+-------+-----------+------------+
| name  | resource  | hard_limit |
+-------+-----------+------------+
| admin | gigabytes |      10000 |
| admin | snapshots |         10 |
| admin | volumes   |        100 |
+-------+-----------+------------+
3 rows in set (0.00 sec)
--------------------- 

表三, 用于查询对路由, 网络安全策略, 浮动IP, IP 地址的配额限制

mysql> select a.name, b.resource, b.limit from keystone.project a, neutron.quotas b where a.enabled=1  and a.id=b.tenant_id and a.name='QA';
+------+---------------------+-------+
| name | resource            | limit |
+------+---------------------+-------+
| QA   | router              |  1000 |
| QA   | security_group_rule | 10000 |
| QA   | subnet              |  1000 |
| QA   | network             |  1000 |
| QA   | security_group      |  1000 |
| QA   | floatingip          |  5000 |
| QA   | port                |  8172 |
+------+---------------------+-------+
7 rows in set (0.00 sec)
--------------------- 

参考:openstack nova 基础知识——Quota(配额管理)https://blog.youkuaiyun.com/hackerain/article/details/8223125

### 安装 OpenStack Nova 组件 可以通过 `yum` 命令来安装 OpenStack Nova 的相关组件,具体命令如下: ```bash yum -y install openstack-nova-api openstack-nova-conductor openstack-nova-scheduler openstack-nova-novncproxy ``` 此命令将会自动下载并安装所需的依赖项以及指定的服务组件[^1]。 --- ### 配置 OpenStack Nova 服务 完成安装后,需要对这些服务进行必要的配置。以下是主要步骤说明: #### 修改主配置文件 编辑 `/etc/nova/nova.conf` 文件以调整调度器的行为。例如,为了实现定期扫描计算节点的功能,可以在 `[scheduler]` 节下添加以下参数: ```ini [scheduler] discover_hosts_in_cells_interval = 300 ``` 这表示每隔 300 秒(即 5 分钟)扫描一次计算节点中的主机状态[^4]。 保存更改后重启 API 服务以使新配置生效: ```bash systemctl restart openstack-nova-api.service ``` --- ### 启动与设置开机自启 安装完成后,需手动启动各个 Nova 相关服务,并将其设为随系统启动而运行: ```bash systemctl start openstack-nova-api openstack-nova-scheduler openstack-nova-conductor openstack-nova-novncproxy systemctl enable openstack-nova-api openstack-nova-scheduler openstack-nova-conductor openstack-nova-novncproxy ``` 以上操作确保了所有核心服务正常运行并能够在下次系统启动时自动加载[^2]。 --- ### 创建管理接口端点 如果尚未创建 Nova管理员服务端点,则可通过以下命令完成初始化工作: ```bash openstack endpoint create --region RegionOne nova admin http://<control_node_ip>:8774/v2.1 ``` 其中 `<control_node_ip>` 应替换为实际的控制器节点 IP 地址。成功执行该命令后,将返回包含字段及其对应值的结果表单,确认端点已正确注册到 Keystone 中[^3]。 --- ### 总结 综上所述,通过 Yum 源安装 OpenStack Nova 组件的过程涉及以下几个方面: 1. 使用 `yum` 工具批量安装所需软件包; 2. 编辑配置文件优化功能选项; 3. 手动激活各子服务并将它们加入系统的引导序列; 4. 注册相应的访问入口至身份验证框架内。 按照上述指导即可顺利完成基础环境搭建任务。 ---
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值