1.安装glance软件
# apt-get install -y glance
2.修改glance配置文件 /etc/glance/glance-api.config
debug = True
default_store = file
bind_host = 0.0.0.0
bind_port = 9292
log_file = /var/log/glance/api.log
backlog = 4096
workers = 1
registry_host = 0.0.0.0
registry_port = 9191
registry_client_protocol = http
rabbit_host = localhost
rabbit_port = 5672
rabbit_use_ssl = false
rabbit_userid = guest
rabbit_password = guest
rabbit_virtual_host = /
rabbit_notification_exchange = glance
rabbit_notification_topic = notifications
rabbit_durable_queues = False
qpid_notification_exchange = glance
qpid_notification_topic = notifications
qpid_hostname = localhost
qpid_port = 5672
qpid_username =
qpid_password =
qpid_sasl_mechanisms =
qpid_reconnect_timeout = 0
qpid_reconnect_limit = 0
qpid_reconnect_interval_min = 0
qpid_reconnect_interval_max = 0
qpid_reconnect_interval = 0
qpid_heartbeat = 5
qpid_protocol = tcp
qpid_tcp_nodelay = True
filesystem_store_datadir = /var/lib/glance/images/
swift_store_auth_version = 2
swift_store_auth_address = 127.0.0.1:5000/v2.0/
swift_store_user = jdoe:jdoe
swift_store_key = a86850deb2742ec3cb41518e26aa2d89
swift_store_container = glance
swift_store_create_container_on_put = False
swift_store_large_object_size = 5120
swift_store_large_object_chunk_size = 200
swift_enable_snet = False
s3_store_host = 127.0.0.1:8080/v1.0/
s3_store_access_key = <20-char AWS access key>
s3_store_secret_key = <40-char AWS secret key>
s3_store_bucket = <lowercased 20-char aws access key>glance
s3_store_create_bucket_on_put = False
sheepdog_store_address = localhost
sheepdog_store_port = 7000
sheepdog_store_chunk_size = 64
delayed_delete = False
scrub_time = 43200
scrubber_datadir = /var/lib/glance/scrubber
image_cache_dir = /var/lib/glance/image-cache/
sqlite_db = /var/lib/glance/glance.sqlite
backend = sqlalchemy
connection = mysql://glanceuser:openstack@localhost/glance
<pre name="code" class="python">
[keystone_authtoken]
auth_host = 127.0.0.1
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = glance
admin_password = openstack
flavor=keystone
这其中有一些其他组件的有关的配置项,是安装完glance自动选择的不需要更改,只要注意红色字体部分即可
3.修改 /etc/glance/glance-registre.conf文件
verbose = True
debug = True
bind_host = 0.0.0.0
bind_port = 9191
log_file = /var/log/glance/registry.log
backlog = 4096
api_limit_max = 1000
limit_param_default = 25
sqlite_db = /var/lib/glance/glance.sqlite
backend = sqlalchemy
connection = mysql://glanceuser:openstack@localhost/glance
[keystone_authtoken]auth_host = 127.0.0.1auth_port = 35357auth_protocol = httpadmin_tenant_name = serviceadmin_user = glanceadmin_password = openstack
flavor=keystone
这其中有一些其他组件的有关的配置项,是安装完glance自动选择的不需要更改,只要注意红色字体部分即可
4.创建glance数据库
根据上面配置的connection创建用户名为glanceuser密码为opensatck。
# mysql -uroot -p -e "CREATE DATABASE glance;"
# mysql -uroot -p -e "GRANT ALL PRIVILEGES ON glance.* TO 'glanceuser'@'localhost'IDENTIFIED BY 'openstack';
5.在keystone中创建glance用户,服务和endpoint
创建一个tenant
# keystone tenant-create --name=service
创建一个user
# keystone user-create --name=glance --pass=openstack
关联用户组
# keystone user-role-add --user glance --role admin --tenant service
创建glance的service
# keystone service-create --name glance --type image --description 'OpenStack ImageService'
创建endpoint
# keystone endpoint-create --service-id 2b9fcdf627f648ec9ffd6cc7cf3487b2 --publicurl 'http://192.168.0.101:9292' --adminurl 'http://10.80.80.10:9292/' --internalurl 'http:10.80.80.10:9292/'
把操作更新到数据库
# glance-manage db_sync
注意:此处可能会报错:ValueError: Tables "migrate_version" have non utf8 collation, please make sure all tables are CHARSET=utf8;
最好使用下面这条指令执行更新操作(参考资料出处)
# glance-manage db_version_control 0
解决办法:修改数据库表额编码
mysql -u root -p glance
mysql> alter table migrate_version convert to character set utf8 collate utf8_unicode_ci;
mysql> flush privileges;
mysql> quit;
# service glance-api restart
# service glance-registry restart
到网上获取一个glance支持的镜像
# wget http://download.cirros-cloud.net/0.3.1/cirros-0.3.1-x86_64-disk.img
这跳命令下载的镜像会保存在当前pwd路径下,执行前请确认路径是否是你想要保存的位置。
添加镜像到glance
# glance image-create --name cirros-0.3.1-x86_64 --is-public true --container-format bare --disk-format qcow2 --file cirros-0.3.1-x86_64-disk.img
可以运行下面指令查看已经上传的镜像
# glance image-list
输出如下:
+--------------------------------------+---------------------+-------------+------------------+----------+--------+
| ID | Name | Disk Format | Container Format | Size | Status |
+--------------------------------------+---------------------+-------------+------------------+----------+--------+
| 929af9d7-1d4a-46fb-ae6c-f0695e1adfe3 | cirros-0.3.1-x86_64 | qcow2 | bare | 13147648 | active |
+--------------------------------------+---------------------+-------------+------------------+----------+--------+
glance安装完成,明天安装Neutron。