首页 > 代码库 > OpenStack组件系列?glance搭建

OpenStack组件系列?glance搭建

第一步:glance关于数据库的操作

mysql -u root -p #登入数据库
CREATE DATABASE glance; #新建库keystone
GRANT ALL PRIVILEGES ON glance.* TO glance@localhost   IDENTIFIED BY 123; #新建本地访问glance库的账号
GRANT ALL PRIVILEGES ON glance.* TO glance@%   IDENTIFIED BY 123; #新建远程访问glance库的账号

第二部:glance关于keystone的操作

soure admin-openrc #执行管理员脚本
#为glance的使用者创建用户
openstack user create --domain default --password-prompt glance 

#对glance-service添加role角色,提示:用户glance只有在一个确定的项目service内才有角色的概念,单独的用户或者单独的项目都是无法绑定角色的。
openstack role add --project service --user glance admin 


#创建glance服务的catalog:service+endpoint
openstack service create --name glance --description "OpenStack Image" image

openstack endpoint create --region RegionOne   image public http://106.14.254.63:9292
openstack endpoint create --region RegionOne   image internal http://106.14.254.63:9292
openstack endpoint create --region RegionOne   image admin http://106.14.254.63:9292

第三步:安装软件包

yum -y install openstack-glance

第四步:配置/etc/glance/glance.conf

先要创建本地存储文件:

mkdir -p /var/lib/glance/images
chown -R glance.glance /var/lib/glance/images

然后再开始配置/etc/glance/glance-api.conf

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

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

[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:123@106.14。254.63/glance

第五步:初始化glanceshujuku:

su -s /bin/sh -c "glance-manage db_sync" glance
‘‘‘
忽略以下打印,此乃正常性行为:
Option "verbose" from group "DEFAULT" is deprecated for removal.  Its value may be silently ignored in the future.
/usr/lib/python2.7/site-packages/oslo_db/sqlalchemy/enginefacade.py:1171:...... oslo_db.sqlalchemy.enginefacade
...... a future release.")
  result = self._query(query)
‘‘‘

第六步:启动glance且设置开机启动

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

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

LAST:验证glance功能:

source admin-openrc

#如果没有wget则必须yum -y install wget
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
  
  
openstack image list

 

OpenStack组件系列?glance搭建