前言:
默认的openstack安装完毕后,基本都是使用默认值得,因此,如果是在实际的应用中,很可能会不够用,例如,虚拟机实例创建数默认是10个,超出10个将会创建失败。
那么,如何设置配额或者是直接关闭配额是一个需要思考的问题。
其次,是一个创建虚拟机实例的时候经常报错的问题,No valid host was found,本文将深入分析此报错的原因以及解决方案。
一,
认识并了解openstack的官方文档
官方文档链接:OpenStack Docs: Zed
首先不得不说openstack的官方文档内容非常的多,但,openstack的方方面面都有写到,只是有一些地方并不是非常的清楚。
OK,yum部署openstack是选择installation guides,那么,安装部署完毕后,如何调试安装好的openstack呢?
OpenStack Docs: Configuration Guide
OK,根据此文档,配置/etc/nova/nova.conf 文件如下:
openstack-config --set /etc/nova/nova.conf DEFAULT quota_instances 1000000
openstack-config --set /etc/nova/nova.conf DEFAULT quota_cores 2000
openstack-config --set /etc/nova/nova.conf DEFAULT quota_ram 5120000
重启nova-api服务,以使以上配置生效:
systemctl restart openstack-nova-api
在dashboard里的概况里,可以看到配额已经生效:
那么,如何关闭所有配额,无限制使用呢?
driver
¶
Type: | string |
---|---|
Default: | nova.quota.DbQuotaDriver |
Valid Values: | nova.quota.DbQuotaDriver, nova.quota.NoopQuotaDriver |
Provides abstraction for quota checks. Users can configure a specific driver to use for quota checks.
Possible values:
- nova.quota.DbQuotaDriver: Stores quota limit information in the database and relies on the quota_* configuration options for default quota limit values. Counts quota usage on-demand.
- nova.quota.NoopQuotaDriver: Ignores quota and treats all resources as unlimited.
修改成这样后,在重启nova-api服务,在dashboard里,可以看到配额全部取消了:
卷的配额同样以这种方式修改,官方文档:OpenStack Docs: Additional options
在此就不演示了
二,
创建虚拟机实例时报错:No valid host was found
创建虚拟机的命令:
openstack server create --flavor m1.large --image new1 --security-group default --key-name mykey newlinux1
[root@openstack1 ~]# openstack flavor list
+----+-----------+-------+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+----+-----------+-------+------+-----------+-------+-----------+
| 0 | m1.nano | 64 | 1 | 0 | 1 | True |
| 1 | m1.tiny | 1024 | 50 | 0 | 1 | True |
| 2 | m1.small | 2048 | 500 | 0 | 1 | True |
| 3 | m1.medium | 4096 | 500 | 0 | 2 | True |
| 4 | m1.large | 8192 | 500 | 0 | 4 | True |
| 5 | m1.xlarge | 16384 | 500 | 0 | 8 | True |
+----+-----------+-------+------+-----------+-------+-----------+
[root@openstack1 ~]# openstack server create --flavor m1.large --image newlinux --security-group default --key-name mykey newlinux1
Could not find resource newlinux
[root@openstack1 ~]# openstack image list
+--------------------------------------+---------+--------+
| ID | Name | Status |
+--------------------------------------+---------+--------+
| 200984db-d793-4a1b-808a-5c78fd0028f7 | Centos7 | active |
| 4737972b-31e8-4bef-9ad0-e542b271dbf7 | back | active |
| 867784df-9090-4ae0-ad25-564b941cc350 | cirros | active |
| 2b527304-8fe6-4582-8451-8feba9a86cfb | new1 | active |
+--------------------------------------+---------+--------+
OK,实例模板使用的是large,而控制节点的配置总共才8G内存,100G硬盘,很明显是超出了节点的可使用资源。
当然,这个问题看日志也基本看不出来什么原因,只是给了一个报错
tail -f /var/log/nova/nova-conductor.log
2023-02-05 14:09:58.647 1685 ERROR nova.conductor.manager File "/usr/lib/python2.7/site-packages/nova/scheduler/manager.py", line 154, in select_destinations
2023-02-05 14:09:58.647 1685 ERROR nova.conductor.manager raise exception.NoValidHost(reason="")
2023-02-05 14:09:58.647 1685 ERROR nova.conductor.manager
2023-02-05 14:09:58.647 1685 ERROR nova.conductor.manager NoValidHost: No valid host was found.
2023-02-05 14:09:58.647 1685 ERROR nova.conductor.manager
2023-02-05 14:09:58.647 1685 ERROR nova.conductor.manager
2023-02-05 14:09:58.815 1685 WARNING nova.scheduler.utils [req-f387e7f7-d1f7-4346-8387-9c027d20eb49 74bc206609e04092b698698d944e922a 205ce8addd9444c893bd62244bcdae78 - default default] Failed to compute_task_build_instances: No valid host was found.
Traceback (most recent call last):
File "/usr/lib/python2.7/site-packages/oslo_messaging/rpc/server.py", line 229, in inner
return func(*args, **kwargs)
File "/usr/lib/python2.7/site-packages/nova/scheduler/manager.py", line 154, in select_destinations
raise exception.NoValidHost(reason="")
NoValidHost: No valid host was found.
: NoValidHost_Remote: No valid host was found.
2023-02-05 14:09:58.820 1685 WARNING nova.scheduler.utils [req-f387e7f7-d1f7-4346-8387-9c027d20eb49 74bc206609e04092b698698d944e922a 205ce8addd9444c893bd62244bcdae78 - default default] [instance: ad3da68e-0cc8-4406-8f87-34dff4bc277a] Setting instance to ERROR state.: NoValidHost_Remote: No valid host was found.
总的来说,出现此种错误一般是节点资源不足造成的,因此,创建虚拟机实例的时候需要使用一个合适的虚拟机模板(也就是flavor )
本例中,创建虚拟机的时候使用m1.tiny 这个模板是比较合适的,改用如下命令后,即可成功创建虚拟机了:
openstack server create --flavor m1.tiny --image new1 --security-group default --key-name mykey newlinux1