安装配置
Before you install and configure the Image service, you must create a database, service credentials, and API endpoint.
一、创建glance数据库并授权
1.登陆数据库
mysql -u root -p
2.创建数据库并授权
CREATE DATABASE glance; GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' IDENTIFIED BY 'GLANCE_DBPASS'; GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'GLANCE_DBPASS';
Replace GLANCE_DBPASS
with a suitable password.
3.Source the admin
credentials to gain access to admin-only CLI commands:
source admin-openrc.sh
4.To create the service credentials, complete these steps:
Create the glance
user:
openstack user create --password-prompt glance
Add the admin
role to the glance
user and service
project:
openstack role add --project service --user glance admin
Create the glance
service entity:
openstack service create --name glance --description "OpenStack Image service" image
Create the Image service API endpoint:
openstack endpoint create --publicurl http://controller:9292 --internalurl http://controller:9292 --adminurl http://controller:9292 --region RegionOne image
二、To install and configure the Image service components
1.Install the packages:
yum install openstack-glance python-glance python-glanceclient
2.Edit the /etc/glance/glance-api.conf
file and complete the following actions:
In the [database]
section, configure database access:
[database] ... connection = mysql://glance:GLANCE_DBPASS@controller/glance
Replace GLANCE_DBPASS
with the password you chose for the Image service database.
In the [keystone_authtoken]
and [paste_deploy]
sections, configure Identity service access:
[keystone_authtoken] ... auth_uri = http://controller:5000 auth_url = http://controller:35357 auth_plugin = password project_domain_id = default user_domain_id = default project_name = service username = glance password = GLANCE_PASS [paste_deploy] ... flavor = keystone
Replace GLANCE_PASS
with the password you chose for the glance
user in the Identity service.
注意:Comment out or remove any other options in the [keystone_authtoken]
section.
In the [glance_store]
section, configure the local file system store and location of image files:
[glance_store] ... default_store = file filesystem_store_datadir = /var/lib/glance/images/
In the [DEFAULT]
section, configure the noop
notification driver to disable notifications because they only pertain to the optional Telemetry service:
[DEFAULT]
...
notification_driver = noop
The Telemetry chapter provides an Image service configuration that enables notifications.
(Optional) To assist with troubleshooting, enable verbose logging in the [DEFAULT]
section:
[DEFAULT]
...
verbose = True
3.Edit the /etc/glance/glance-registry.conf
file and complete the following actions:
In the [database]
section, configure database access:
[database] ... connection = mysql://glance:GLANCE_DBPASS@controller/glance
Replace GLANCE_DBPASS
with the password you chose for the Image service database.
In the [keystone_authtoken]
and [paste_deploy]
sections, configure Identity service access:
[keystone_authtoken] ... auth_uri = http://controller:5000 auth_url = http://controller:35357 auth_plugin = password project_domain_id = default user_domain_id = default project_name = service username = glance password = GLANCE_PASS [paste_deploy] ... flavor = keystone
Replace GLANCE_PASS
with the password you chose for the glance
user in the Identity service.
注意:Comment out or remove any other options in the [keystone_authtoken]
section.
In the [DEFAULT]
section, configure the noop
notification driver to disable notifications because they only pertain to the optional Telemetry service:
[DEFAULT]
...
notification_driver = noop
The Telemetry chapter provides an Image service configuration that enables notifications.
(Optional) To assist with troubleshooting, enable verbose logging in the [DEFAULT]
section:
[DEFAULT]
...
verbose = True
4.Populate the Image service database:
su -s /bin/sh -c "glance-manage db_sync" glance
To finalize installation
Start the Image service services and configure them to start when the system boots:
systemctl enable openstack-glance-api.service openstack-glance-registry.service
systemctl start openstack-glance-api.service openstack-glance-registry.service