OpenStack Glance创建镜像时遭遇HTTP 404资源未找到错误求助
创建Glance镜像时遭遇HTTP 404资源未找到错误
操作流程
- 编辑
/etc/glance/glance-api.conf配置文件:
[database] connection = mysql+pymysql://glance:glance@localhost/glance [DEFAULT] rabbit_password = openstack rabbit_userid = openstack rabbit_host = localhost [keystone_authtoken] auth_uri = http://controller:5000 auth_url = http://controller:35357 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = openstack memcached_servers = controller:11211 [paste_deploy] flavor = keystone [glance_store] stores = file,http default_store = file filesystem_store_datadir = /var/lib/glance/images/
- 编辑
/etc/glance/glance-registry.conf配置文件:
[database] connection = mysql+pymysql://glance:glance@localhost/glance [keystone_authtoken] auth_uri = http://controller:5000 auth_url = http://controller:35357 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = openstack memcached_servers = controller:11211 [paste_deploy] flavor = keystone
- 同步数据库:
root@controller:~# su -s /bin/sh -c "glance-manage db_sync" glance
错误详情
执行镜像创建命令时返回404错误:
root@controller:~# openstack image create "cirros-0.4.0-x86_64" --file /tmp/cirros-0.4.0-x86_64-disk.img --disk-format qcow2 --container-format bare --public (http://controller:35357/v2/schemas/image): The resource could not be found. (HTTP 404)
环境版本信息:
openstack --version openstack 3.12.2 glance-api --version 15.0.2
排查与修复方案
修正Keystone认证API版本
错误显示请求指向Keystone v2 API路径,但Glance 15(Rocky版本)依赖Keystone v3 API。- 检查当前环境变量:
echo $OS_AUTH_URL,确保值为http://controller:5000/v3。 - 若使用rc文件,更新
admin-openrc.sh,添加或修改:export OS_AUTH_URL=http://controller:5000/v3 export OS_IDENTITY_API_VERSION=3 - 重新加载rc文件:
source admin-openrc.sh
- 检查当前环境变量:
验证Glance服务状态
- 重启Glance服务:
systemctl restart glance-api glance-registry systemctl status glance-api glance-registry - 确认服务端口监听:
ss -tulpn | grep glance,确保glance-api监听9292,glance-registry监听9191。
- 重启Glance服务:
完善配置文件认证路径
在glance-api.conf和glance-registry.conf的[keystone_authtoken]段,将auth_url修改为http://controller:35357/v3,添加v3后缀后重启服务。检查Keystone端点配置
- 确认Glance服务已注册:
openstack service list,查看是否存在type为image的glance服务。 - 检查Glance端点:
openstack endpoint list,确保所有端点的URL为http://controller:9292,而非Keystone的35357端口。
- 确认Glance服务已注册:
验证数据库同步结果
登录MySQL检查Glance数据库表是否生成:mysql -u glance -p USE glance; SHOW TABLES;若表为空,重新执行
glance-manage db_sync并检查输出是否有报错。
内容的提问来源于stack exchange,提问作者And
相关产品推荐
相关产品推荐

