openstack学习-glance安装(三)
glance在openstack负责镜像相关管理的,对外提供标准的api提供服务,glance有两个服务,一个是glance-api接受云系统镜像的创建、删除、读取请求。glance-registry是云系统的镜像注册服务。
glance有两个监听端口,一个是9292,监听api一个是9191,监听registry。
一、安装Glance
[root@linux-node1 ~]# yum install -y openstack-glance
二、Glance数据库配置
1、Glance-api
[root@linux-node1 ~]# vim /etc/glance/glance-api.conf [database] connection= mysql+pymysql://glance:glance@192.168.56.11/glance
2、glance-registry
[root@linux-node1 ~]# vim /etc/glance/glance-registry.conf [database] connection= mysql+pymysql://glance:glance@192.168.56.11/glance
三、设置Keystone
1、glance-api
[root@linux-node1 ~]# vim /etc/glance/glance-api.conf [keystone_authtoken] auth_uri = http://192.168.56.11:5000 auth_url = http://192.168.56.11:35357 memcached_servers = 192.168.56.11:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = glance [paste_deploy] flavor=keystone
2、glance-registry
[root@linux-node1 ~]# vim /etc/glance/glance-registry.conf [keystone_authtoken] auth_uri = http://192.168.56.11:5000 auth_url = http://192.168.56.11:35357 memcached_servers = 192.168.56.11:11211 auth_type = password project_domain_name = default user_domain_name = default project_name = service username = glance password = glance [paste_deploy] flavor=keystone
四、设置Glance镜像存储
[root@linux-node1 ~]# vim /etc/glance/glance-api.conf [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
六、验证同步的情况
[root@linux-node1 ~]# mysql -h 192.168.56.11 -uglance -pglance -e "use glance;show tables;" +----------------------------------+ | Tables_in_glance | +----------------------------------+ | alembic_version | | image_locations | | image_members | | image_properties | | image_tags | | images | | metadef_namespace_resource_types | | metadef_namespaces | | metadef_objects | | metadef_properties | | metadef_resource_types | | metadef_tags | | migrate_version | | task_info | | tasks | +----------------------------------+
七、启动Glance服务
# systemctl enable openstack-glance-api.service # systemctl enable openstack-glance-registry.service # systemctl start openstack-glance-api.service # systemctl start openstack-glance-registry.service
八、Glance服务注册
想要让别的服务可以使用Glance,就需要在Keystone上完成服务的注册。注意需要先source一下admin的环境变量。
[root@linux-node1 ~]# source admin-openstack.sh # openstack service create --name glance --description "OpenStack Image service" image # openstack endpoint create --region RegionOne image public http://192.168.56.11:9292 # openstack endpoint create --region RegionOne image internal http://192.168.56.11:9292 # openstack endpoint create --region RegionOne image admin http://192.168.56.11:9292
九、测试Glance状态
[root@linux-node1 ~]# source admin-openstack.sh
[root@linux-node1 ~]# openstack image list
十一、Glance镜像
在刚开始实施OpenStack平台阶段,如果没有制作镜像。可以使用一个实验的镜像进行测试,这是一个小的Linux系统。
[root@linux-node1 ~]# cd /usr/local/src [root@linux-node1 src]#wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img [root@linux-node1 src]# openstack image create "cirros" --disk-format qcow2 \ --container-format bare --file cirros-0.3.5-x86_64-disk.img --public [root@linux-node1 src]# openstack image list +--------------------------------------+--------+--------+ | ID | Name | Status | +--------------------------------------+--------+--------+ | cf154a84-a73a-451b-bcb3-83c98e7c0d3e | cirros | active | +--------------------------------------+--------+--------+
作者:凉生墨客
本文版权归作者所有,欢迎转载,但未经作者同意必须保留此段声明,且在文章页面明显位置给出原文连接,否则保留追究法律责任的权利。