当前位置: 首页 > 工具软件 > Horizon > 使用案例 >

openstack horizon 创建虚拟机

郁承运
2023-12-01

先决条件: 安装glance

配置glace

#数据库,授权
mysql -u root -p

CREATE DATABASE glance;
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
  IDENTIFIED BY 'root';
GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
  IDENTIFIED BY 'root';

#使用环境变量
. admin-openrc
#创建服务
openstack user create --domain Openstack --password-prompt glance
openstack role add --project service --user glance admin
openstack service create --name glance --description "openstack Image" image
openstack endpoint create --region RegionOne image public http://controller:9292
openstack endpoint create --region RegionOne image internal http://controller:9292
openstack endpoint create --region RegionOne image admin http://controller:9292

#安装和配置组件
yum isntall openstack-glance

vim /etc/glance/glance-api.conf

[database]
# ...
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
[keystone_authtoken]
# ...
www_authenticate_uri  = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = GLANCE_PASS

[paste_deploy]
# ...
flavor = keystone
[glance_store]
# ...
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/

#填充数据库
su -s /bin/sh -c "glance-manage db_sync" glance

#完成
systemctl enable openstack-glance-api.service
systemctl start openstack-glance-api.service

验证

. admin-openrc

wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img

glance image-create --name "cirros" --file cirros-0.4.0-x86_64-disk.img --disk-format qcow2 --container-format bare --visibility=public

报错:HTTP 410 Gone: Error in store configuration. Adding images to store is disabled.
解决:添加filesystem_store_datadirs = /opt/stack/data/glance/images/
注释filesystem_store_datadir = /opt/stack/data/glance/images/

报错:Error finding address for http://controller:9292/v2/schemas/image: Unable to
解决: 9292端口未打开
检查配置文件glance-api.conf

+------------------+----------------------------------------------------------------------------------+
| Property         | Value                                                                            |
+------------------+----------------------------------------------------------------------------------+
| checksum         | 443b7623e27ecf03dc9e01ee93f67afe                                                 |
| container_format | bare                                                                             |
| created_at       | 2022-03-24T02:45:40Z                                                             |
| disk_format      | qcow2                                                                            |
| id               | e5073a83-c6cd-4fd5-90c6-6a165ac9b7c4                                             |
| min_disk         | 0                                                                                |
| min_ram          | 0                                                                                |
| name             | cirros                                                                           |
| os_hash_algo     | sha512                                                                           |
| os_hash_value    | 6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e |
|                  | 2161b5b5186106570c17a9e58b64dd39390617cd5a350f78                                 |
| os_hidden        | False                                                                            |
| owner            | b4c2aab7856b4c8c98db4ef9830a0649                                                 |
| protected        | False                                                                            |
| size             | 12716032                                                                         |
| status           | active                                                                           |
| tags             | []                                                                               |
| updated_at       | 2022-03-24T02:45:40Z                                                             |
| virtual_size     | 46137344                                                                         |
| visibility       | public                                                                           |
+------------------+----------------------------------------------------------------------------------+

glance image-list

+--------------------------------------+--------+
| ID                                   | Name   |
+--------------------------------------+--------+
| 11ebaa14-4a48-4c67-a059-1fd7e948acf2 | cirros |
| 270bfa9b-0656-4ca0-aa12-81f46e668b74 | cirros |
| 75f7c305-927c-498c-a113-214657d6d5e3 | cirros |
| 6842527d-357e-4654-8f34-20cb9061015f | cirros |
| 29cba671-c424-4991-a9d1-87a9f6a539d0 | cirros |
| 40241143-f3ac-4137-98d2-4dccf46b80c3 | cirros |
| a55a1bae-c0f9-48b8-949c-23fa2753701b | cirros |
| 97e5d424-4177-4c6f-abe9-dc7dbc1999ef | cirros |
| 0b4ff359-a151-4530-92df-5118fcd86e89 | cirros |
| 87dd7634-3153-418a-99c2-3070d50d21c7 | cirros |
| 4a7bdd97-d7f5-4298-b3bd-76f94592d66d | cirros |
| fe28d0a8-b1f8-4b32-98fa-04b29bc4b9a7 | cirros |
| 344c24f9-943d-4ecb-9e0f-221c461fc094 | cirros |
| dbf6c8b8-a412-4033-ae6f-7d6822bc39f8 | cirros |
| 08c03e61-fcb4-45de-8ff8-4f1735137f0f | cirros |
| 3d6d1869-9766-406e-87ed-1a4aa4939eb2 | cirros |
| a49b0cf7-5d91-45b2-a1f0-5d59d14e7c5a | cirros |
| adbe4bf5-66b0-4239-b2dd-4142beac4830 | cirros |
| b33b4f35-d19f-49f9-ab58-b8ac4ee90149 | cirros |
| 940c3484-8b39-44de-b5b6-61ff8dbec159 | cirros |
| e9d2f7cd-bbc7-429d-af1e-20cfc21492cc | cirros |
| dc1d7fc3-d62b-4a88-9fee-99d9531a9f8b | cirros |
| e8b268bc-a8e5-4c43-8814-d2b03c5ff625 | cirros |
| 5b3687a1-175a-4a99-a1f6-46278c27a06d | cirros |
| a7830bff-4991-45b0-970f-8db3aa91eedd | cirros |
| 987e7185-e783-4bba-be4e-bf3dfa15dee1 | cirros |
| f209e936-d625-4671-a81c-3b74169a898e | cirros |
| d3e4e102-0489-4bd6-9033-9bc713d12b76 | cirros |
| d49c7011-0f41-4cc6-83f6-00db40b95d49 | cirros |
| 17285ec3-5404-4980-b7fb-b2e37d8706b6 | cirros |
| 49921afe-c8a6-41c2-98f3-f1df9db785f6 | cirros |
| 78e801b5-4117-4994-87c8-f7ef77bb9bcb | cirros |
| e5073a83-c6cd-4fd5-90c6-6a165ac9b7c4 | cirros |
+--------------------------------------+--------+



问题:hirizon web界面创建虚拟机实例类型为空
查找问题:

openstack flavor list
#无输出

排错:
(1)查看/etc/openstack-dashboard/local_settings 配置,未发现错误
(2)查看service

openstack endpoint list --service keystone

+----------------------------------+-----------+--------------+--------------+---------+-----------+--------------------------------+
| ID                               | Region    | Service Name | Service Type | Enabled | Interface | URL                            |
+----------------------------------+-----------+--------------+--------------+---------+-----------+--------------------------------+
| a030a1a312e34174b84bcfb3ffd947a2 | RegionOne | keystone     | identity     | True    | internal  | http://192.168.143.203:5000/v3 |
| aa8e7a1683ad4a629af1b5b24148e870 | RegionOne | keystone     | identity     | True    | admin     | http://192.168.143.203:5000/v3 |
| fb82c8c4a0d4486ba31316a434dcacd8 | RegionOne | keystone     | identity     | True    | public    | http://192.168.143.203:5000/v3 |
+----------------------------------+-----------+--------------+--------------+---------+-----------+--------------------------------+
(3)发现是没有创建
nova flavor-create --is-public true boshen_ram_1024_disk_1_vcpus_1 boshen_ram_1024_disk_1_vcpus_1 1024 1 1

创建时报错无法创建虚拟机
ERROR:nics are required after microversion 2.36
解决: 搭neutron

 类似资料: