image部署

第一步:创建glance库
[root@zxw6 ~]# mysql -uroot -p123
create database glance;

第二步:给与权限0和远程登录
MariaDB [(none)]> grant all on glance.* to glance@localhost identified by 'zxw6';
Query OK, 0 rows affected (0.00 sec)

MariaDB [(none)]> grant all on glance.* to glance@'%' identified by 'zxw6';
Query OK, 0 rows affected (0.00 sec)

第三步:登录认证
[root@zxw6 ~]# source openrc

第四步:创建glance用户
[root@zxw6 ~]# openstack user create --domain default --password=zxw6 glance


第五步:把glanse用户添加到service项目设置为管理员
[root@zxw6 ~]# openstack role add --project service --user glance admin

第六步:创建glance的服务
[root@zxw6 ~]# openstack service create --name glance --description "OpenStack Image" image

 

第七步:创建服务端点

[root@zxw6 ~]# openstack endpoint create --region RegionOne image public http://zxw6:9292

[root@zxw6 ~]# openstack endpoint create --region RegionOne image internal http://zxw6:9292

[root@zxw6 ~]# openstack endpoint create --region RegionOne image admin http://zxw6:9292

 

第八步:安装glance服务
[root@zxw6 ~]# yum install openstack-glance -y

第九步:编辑glance的api配置文件/etc/glance/glance-api.conf (查找)

[database]
connection = mysql+pymysql://glance:zxw6@zxw6/glance

[keystone_authtoken]
auth_uri = http://zxw6:5000 服务端点地址
auth_url = http://zxw6:35357
memcached_servers = zxw6:11211 缓存地址
auth_type = password 认证类型
project_domain_name = default 工作域
user_domain_name = default 域名字
project_name = service
username = glance 认证账号
password = zxw6 认证密码

[glance_store]
stores = file,http 保存方式
default_store = file 默认保存方式
filesystem_store_datadir = /var/lib/glance/images/ 保存路径
[paste_deploy]
flavor = keystone

[root@zxw6 ~]# egrep -v '(^#|^$)' /etc/glance/glance-api.conf
[DEFAULT]
[cors]
[cors.subdomain]
[database]
connection = mysql+pymysql://glance:zxw6@zxw6/glance
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
[image_format]
[keystone_authtoken]
auth_uri = http://zxw6:5000
auth_url = http://zxw6:35357
memcached_servers = zxw6:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = zxw6
[matchmaker_redis]
[oslo_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_messaging_zmq]
[oslo_middleware]
[oslo_policy]
[paste_deploy]
flavor = keystone
[profiler]
[store_type_location_strategy]
[task]
[taskflow_executor]


第十步:编辑配置文件/etc/glance/glance-registry.conf(元数据)
[database]
connection = mysql+pymysql://glance:zxw6@zxw6/glance


[keystone_authtoken]
auth_uri = http://zxw6:5000
auth_url = http://zxw6:35357
memcached_servers = zxw6:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = zxw6

paste_deploy]
flavor = keystone

[root@zxw6 ~]# egrep -v '(^#|^$)' /etc/glance/glance-registry.conf
[DEFAULT]
[database]
connection = mysql+pymysql://glance:zxw6@zxw6/glance
[keystone_authtoken]
auth_uri = http://zxw6:5000
auth_url = http://zxw6:35357
memcached_servers = zxw6:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = zxw6
[matchmaker_redis]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_messaging_zmq]
[oslo_policy]
[paste_deploy]
flavor = keystone
[profiler]

 

第十一步:同步glance的数据库
[root@zxw6 glance]# su -s /bin/sh -c "glance-manage db_sync" glance


第十二步:启动glance服务并开机自启
[root@zxw6 glance]# systemctl start openstack-glance-api.service openstack-glance-registry.service

[root@zxw6 glance]# systemctl enable openstack-glance-api.service openstack-glance-registry.service

第十三步:下载镜像

[root@zxw6 glance]# wget
http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img

  http://download2.yunwei.edu/shell/openstack_app.tar.gz

[root@zxw6 ~]# tar -xf openstack_app.tar.gz

第十四步:创建镜像
[root@zxw6 openstack-ocata]# openstack image create "centos"
> --file cirros-0.3.3-x86_64-disk.img
> --disk-format qcow2 --container-format bare
> --public


第十五步:查看镜像
[root@zxw6 openstack-ocata]# openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| 96872cee-b8f5-45f5-8025-5838f4afa605 | centos | active |
+--------------------------------------+--------+--------+
[root@zxw6 ~]# glance image-list
+--------------------------------------+--------+
| ID | Name |
+--------------------------------------+--------+
| 96872cee-b8f5-45f5-8025-5838f4afa605 | centos |
+--------------------------------------+--------+

 

原文地址:https://www.cnblogs.com/itzhao/p/11335505.html