博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
openstack镜像服务glance
阅读量:4982 次
发布时间:2019-06-12

本文共 6605 字,大约阅读时间需要 22 分钟。

官方文档:https://docs.openstack.org/ocata/install-guide-rdo/glance-install.html

Glance主要有两个重要的服务:

Glance-api:接受云系统镜像创建、删除、读取请求。
Glance-Registry:云系统的镜像注册服务。

加载admin的环境变量:source /admin-openstack.sh
vim /admin-openstack.sh
export OS_USERNAME=admin
export OS_PASSWORD=admin
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_DOMAIN_NAME=default
export OS_AUTH_URL=http://192.168.2.11:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
注意:只要有用到openstack就要加载环境变量

//创建glance用户(控制节点)

openstack user create --domain default --password-prompt glance

openstack role add --project service --user glance admin

//安装glance服务组件(控制节点)
yum install -y openstack-glance

//编辑文件 /etc/glance/glance-api.conf 并完成如下动作(控制节点)

vim  /etc/glance/glance-api.conf
****************************************************
[database]

1823 connection = mysql+pymysql://glance:glance@192.168.2.11/glance

(打开注释并修改)

[keystone_authtoken] 3282 在这个模块下面添加如下

auth_uri = http://192.168.2.11:5000
auth_url = http://192.168.2.11:35357
memcached_servers = 192.168.2.11:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance

(添加内容)

4235 #flavor = keystone

(打开注释)

[glance_store]

# ...
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/

(添加内容)

//编辑文件 /etc/glance/glance-registry.conf 并完成如下动作(控制节点)
vim /etc/glance/glance-registry.conf
[database]
1141 connection = mysql+pymysql://glance:glance@192.168.2.11/glance

(打开注释并修改 )

[keystone_authtoken]

auth_uri = http://192.168.2.11:5000
auth_url = http://192.168.2.11:35357
memcached_servers = 192.168.2.11:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = glance

(添加内容)

2159 #flavor = keystone

(打开注释)

同步glance数据库
su -s /bin/sh -c "glance-manage db_sync" glance
查看是否同步成功
mysql -h 192.168.2.11 -uglance -pglance -e "use glance;show tables;"

修改memcached的配置文件:vim /etc/sysconfig/memcached

PORT="11211"
USER="memcached"
MAXCONN="1024"
CACHESIZE="64"
OPTIONS="-l 192.168.2.11,::1"

systemctl enable memcached

systemctl start memcached

设置开机自启动并启动glance-api,glance-registry服务

systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl start openstack-glance-api.service openstack-glance-registry.service

 

注册:

openstack service create --name glance --description "OpenStack Image" image

[root@localhost log]# openstack service create --name glance \
> --description "OpenStack Image" image
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image |
| enabled | True |
| id | 37c0c42ff7ab4629bb0309e6affe1316 |
| name | glance |
| type | image |
+-------------+----------------------------------+

 

 openstack endpoint create --region RegionOne  image public http://192.168.2.11:9292

[root@localhost log]# openstack endpoint create --region RegionOne \
> image public http://192.168.2.11:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 07c702eebf5c485da26849e4a2094c72 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 37c0c42ff7ab4629bb0309e6affe1316 |
| service_name | glance |
| service_type | image |
| url | http://192.168.2.11:9292 |
+--------------+----------------------------------+

 

openstack endpoint create --region RegionOne image internal http://192.168.2.11:9292

[root@localhost log]# openstack endpoint create --region RegionOne image internal http://192.168.2.11:9292

+--------------+----------------------------------+

| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 8d120557b1a644a0ab1762704717faff |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 37c0c42ff7ab4629bb0309e6affe1316 |
| service_name | glance |
| service_type | image |
| url | http://192.168.2.11:9292 |
+--------------+----------------------------------+

 

openstack endpoint create --region RegionOne image admin http://192.168.2.11:9292

[root@localhost log]# openstack endpoint create --region RegionOne image admin http://192.168.2.11:9292

+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | a7cb98957cda4c0b86c9b0c0604def9a |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 37c0c42ff7ab4629bb0309e6affe1316 |
| service_name | glance |
| service_type | image |
| url | http://192.168.2.11:9292 |
+--------------+----------------------------------+

[root@localhost log]# openstack endpoint list

+----------------------------------+-----------+--------------+--------------+---------+-----------+-------------------------------+
| ID | Region | Service Name | Service Type | Enabled | Interface | URL |
+----------------------------------+-----------+--------------+--------------+---------+-----------+-------------------------------+
| 07c702eebf5c485da26849e4a2094c72 | RegionOne | glance | image | True | public | http://192.168.2.11:9292 |
| 09279edb612341f38f85884b2bfcdb78 | RegionOne | keystone | identity | True | public | http://19.168.2.11:5000/v3 |
| 09b6e07b2be943b59af2a87d7303215c | RegionOne | keystone | identity | True | internal | http://192.168.2.11:5000/v3 |
| 8d120557b1a644a0ab1762704717faff | RegionOne | glance | image | True | internal | http://192.168.2.11:9292 |
| a7cb98957cda4c0b86c9b0c0604def9a | RegionOne | glance | image | True | admin | http://192.168.2.11:9292 |
| ed2e3a4c9d9c43a9819ad2a49c058522 | RegionOne | keystone | identity | True | admin | http://192.168.2.11:35357/v3/ |
+----------------------------------+-----------+--------------+--------------+---------+-----------+-------------------------------+

验证是否正常

[root@localhost log]# openstack image list

[root@localhost log]#

(没有报错就说明服务正常)

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

openstack image create "cirros" \

--file cirros-0.3.4-x86_64-disk.img \
--disk-format qcow2 --container-format bare \
--public

[root@localhost log]# openstack image list
+--------------------------------------+--------+--------+
| ID | Name | Status |
+--------------------------------------+--------+--------+
| 958a9dd4-5eef-44f7-a0a0-c16b09227958 | cirros | active |
+--------------------------------------+--------+--------+

 

转载于:https://www.cnblogs.com/liuhui-xzz/p/9891329.html

你可能感兴趣的文章
PolyCluster: Minimum Fragment Disagreement Clustering for Polyploid Phasing 多聚类:用于多倍体的最小碎片不一致聚类...
查看>>
省市三级菜单
查看>>
C#中的事件
查看>>
【每日进步】July 2012
查看>>
策略模式
查看>>
单机部署多实例redis
查看>>
Cookie登录保存
查看>>
继承与重写的具体事例
查看>>
327 作业
查看>>
sql 取汉字首字母
查看>>
python3 字符串属性(四)
查看>>
javascript 封装ajax(多版本)
查看>>
bzoj4034: [HAOI2015]树上操作(树剖)
查看>>
android-Activity
查看>>
${sessionScope.user}的使用方法
查看>>
IOS断点下载
查看>>
Steal 偷天换日 题解(From luoguBlog)
查看>>
Hadoop HDFS学习总结
查看>>
C#wxpay和alipay
查看>>
Combination Sum
查看>>