此内容没有您所选择的语言版本。
5.4. Configure the Image Service
- Configure the Identity service for Image service authentication (create database entries, set connection strings, and update configuration files).
- Configure the disk-image storage back end (this guide uses the Object Storage service).
- Configure the firewall for Image service access.
- Configure TLS/SSL.
- Populate the Image service database.
5.4.1. Configure the Image Service Database Connection 复制链接链接已复制到粘贴板!
/etc/glance/glance-api.conf
and /etc/glance/glance-registry.conf
files. It must be updated to point to a valid database server before starting the service.
root
user.
Procedure 5.2. Configuring the Image Service SQL Database Connection
- Set the value of the
sql_connection
configuration key in theglance-api.conf
file:openstack-config --set /etc/glance/glance-api.conf \ DEFAULT sql_connection mysql://USER:PASS@IP/DB
# openstack-config --set /etc/glance/glance-api.conf \ DEFAULT sql_connection mysql://USER:PASS@IP/DB
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace the following values:- Replace USER with the Image service database user name, usually
glance
. - Replace PASS with the password of the database user.
- Replace IP with the IP address or host name of the server hosting the database service.
- Replace DB with the name of the Image service database, usually
glance
.
- Set the value of the
sql_connection
configuration key in theglance-registry.conf
file:openstack-config --set /etc/glance/glance-registry.conf \ DEFAULT sql_connection mysql://USER:PASS@IP/DB
# openstack-config --set /etc/glance/glance-registry.conf \ DEFAULT sql_connection mysql://USER:PASS@IP/DB
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace USER, PASS, IP, and DB with the same values used in the previous step.
Important
5.4.2. Create the Image Service Identity Records 复制链接链接已复制到粘贴板!
services
tenant. For more information, see:
keystonerc_admin
file and on which the keystone command-line utility is installed.
Procedure 5.3. Creating Identity Records for the Image Service
- Set up the shell to access Keystone as the admin user:
source ~/keystonerc_admin
# source ~/keystonerc_admin
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Create the
glance
user:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace PASSWORD with a secure password that will be used by the Image Service when authenticating with the Identity service. - Link the
glance
user and theadmin
role together within the context of theservices
tenant:[(keystone_admin)]# openstack role add --project services --user glance admin
[(keystone_admin)]# openstack role add --project services --user glance admin
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Create the
glance
Image service entry:[(keystone_admin)]# openstack service create --name glance \ --description "Glance Image Service" \ image
[(keystone_admin)]# openstack service create --name glance \ --description "Glance Image Service" \ image
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Create the
glance
endpoint entry:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace IP with the IP address or host name of the server hosting the Image service.
5.4.3. Configure Image Service Authentication 复制链接链接已复制到粘贴板!
root
user.
Procedure 5.4. Configuring the Image Service to Authenticate through the Identity Service
- Configure the
glance-api
service:Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Configure the
glance-registry
service:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
- Replace IP with the IP address or host name of the Identity server.
- Replace services with the name of the tenant that was created for the use of the Image service (previous examples set this to
services
). - Replace glance with the name of the service user that was created for the Image service (previous examples set this to
glance
). - Replace PASSWORD with the password associated with the service user.
5.4.4. Use the Object Storage Service for Image Storage 复制链接链接已复制到粘贴板!
file
) for its storage back end; however, either of the following storage back ends can be used to store uploaded disk images:
file
- Local file system of the Image server (/var/lib/glance/images/
directory)swift
- OpenStack Object Storage service
Note
openstack-config
command; however, you can also manually update the /etc/glance/glance-api.conf
file. If manually updating the file, ensure that the default_store
parameter is set to the correct back end (for example, 'default_store=rbd
'), and update the parameters in that back end's section (for example, under 'RBD Store Options
').
Procedure 5.5. Configuring the Image Service to use the Object Storage Service
- Set the
default_store
configuration key toswift
:openstack-config --set /etc/glance/glance-api.conf \ DEFAULT default_store swift
# openstack-config --set /etc/glance/glance-api.conf \ DEFAULT default_store swift
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Set the
swift_store_auth_address
configuration key to the public endpoint for the Identity service:openstack-config --set /etc/glance/glance-api.conf \ DEFAULT swift_store_auth_address http://IP:5000/v2.0/
# openstack-config --set /etc/glance/glance-api.conf \ DEFAULT swift_store_auth_address http://IP:5000/v2.0/
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Add the container for storing images in the Object Storage service:
openstack-config --set /etc/glance/glance-api.conf \ DEFAULT swift_store_create_container_on_put True
# openstack-config --set /etc/glance/glance-api.conf \ DEFAULT swift_store_create_container_on_put True
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Set the
swift_store_user
configuration key, in the format TENANT:USER, to contain the tenant and user to use for authentication:openstack-config --set /etc/glance/glance-api.conf \ DEFAULT swift_store_user services:swift
# openstack-config --set /etc/glance/glance-api.conf \ DEFAULT swift_store_user services:swift
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - If you followed the instructions in this guide to deploy Object Storage, replace these values with the
services
tenant and theswift
user respectively (as shown in the command example above). - If you did not follow the instructions in this guide to deploy Object Storage, replace these values with the appropriate Object Storage tenant and user for your environment.
- Set the
swift_store_key
configuration key to the password that was set for theswift
user when deploying the Object Storage service:openstack-config --set /etc/glance/glance-api.conf \ DEFAULT swift_store_key PASSWORD
# openstack-config --set /etc/glance/glance-api.conf \ DEFAULT swift_store_key PASSWORD
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
9292
. All steps in this procedure must be performed on the server hosting the Image service, while logged in as the root
user.
Procedure 5.6. Configuring the Firewall to Allow Image Service Traffic
- Open the
/etc/glance/glance-api.conf
file in a text editor, and remove any comment characters preceding the following parameters:bind_host = 0.0.0.0 bind_port = 9292
bind_host = 0.0.0.0 bind_port = 9292
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Open the
/etc/sysconfig/iptables
file in a text editor. - Add an INPUT rule allowing TCP traffic on port
9292
. The new rule must appear before any INPUT rules that REJECT traffic:-A INPUT -p tcp -m multiport --dports 9292 -j ACCEPT
-A INPUT -p tcp -m multiport --dports 9292 -j ACCEPT
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Save the changes to the
/etc/sysconfig/iptables
file. - Restart the
iptables
service to ensure that the change takes effect:systemctl restart iptables.service
# systemctl restart iptables.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
root
user.
Procedure 5.7. Configuring the Image Service (glance) to Use the RabbitMQ Message Broker
- Set RabbitMQ as the notifier:
openstack-config --set /etc/glance/glance-api.conf \ DEFAULT notification_driver messaging
# openstack-config --set /etc/glance/glance-api.conf \ DEFAULT notification_driver messaging
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Set the name of the RabbitMQ host:
openstack-config --set /etc/glance/glance-api.conf \ DEFAULT rabbit_host RABBITMQ_HOST
# openstack-config --set /etc/glance/glance-api.conf \ DEFAULT rabbit_host RABBITMQ_HOST
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace RABBITMQ_HOST with the IP address or host name of the message broker. - Set the message broker port to
5672
:openstack-config --set /etc/glance/glance-api.conf \ DEFAULT rabbit_port 5672
# openstack-config --set /etc/glance/glance-api.conf \ DEFAULT rabbit_port 5672
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Set the RabbitMQ user name and password created for the Image service when RabbitMQ was configured:
openstack-config --set /etc/glance/glance-api.conf \ DEFAULT rabbit_userid glance openstack-config --set /etc/glance/glance-api.conf \ DEFAULT rabbit_password GLANCE_PASS
# openstack-config --set /etc/glance/glance-api.conf \ DEFAULT rabbit_userid glance # openstack-config --set /etc/glance/glance-api.conf \ DEFAULT rabbit_password GLANCE_PASS
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replaceglance
and GLANCE_PASS with the RabbitMQ user name and password created for the Image service. - When RabbitMQ was launched, the
glance
user was granted read and write permissions to all resources: specifically, through the virtual host/
. Configure the Image service to connect to this virtual host:openstack-config --set /etc/glance/glance-api.conf \ DEFAULT rabbit_virtual_host /
# openstack-config --set /etc/glance/glance-api.conf \ DEFAULT rabbit_virtual_host /
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
5.4.7. Configure the Image Service to Use SSL 复制链接链接已复制到粘贴板!
glance-api.conf
file to configure SSL.
Configuration Option | Description |
---|---|
cert_file
|
The path to the certificate file to use when starting the API server securely.
|
key_file
|
The path to the private key file to use when starting the API server securely.
|
ca_file
|
The path to the CA certificate file to use to verify connecting clients.
|
5.4.8. Populate the Image Service Database 复制链接链接已复制到粘贴板!
Procedure 5.8. Populating the Image Service Database
- Log in to the system hosting the Image service.
- Switch to the
glance
user:su glance -s /bin/sh
# su glance -s /bin/sh
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Initialize and populate the database identified in
/etc/glance/glance-api.conf
and/etc/glance/glance-registry.conf
:glance-manage db_sync
$ glance-manage db_sync
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Note
Procedure 5.9. Configuring Image and Compute Services to Send and Receive Images through the Local File System
- Create a JSON document that exposes the Image file system metadata required by
openstack-nova-compute
. - Configure the Image service to use the JSON document.
- Configure
openstack-nova-compute
to use the file system metadata provided by the Image service.
openstack-nova-compute
service.
Procedure 5.10. Configuring the Image Service to Expose Local File System Metadata to the Compute Service
- Determine the mount point of the file system used by the Image service:
df
# df Filesystem 1K-blocks Used Available Use% Mounted on /dev/sda3 51475068 10905752 37947876 23% / devtmpfs 2005504 0 2005504 0% /dev tmpfs 2013248 668 2012580 1% /dev/shm
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For example, if the Image service uses the/dev/sda3
file system, its corresponding mount point is/
. - Create a unique ID for the mount point:
uuidgen
# uuidgen ad5517ae-533b-409f-b472-d82f91f41773
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Note the output of theuuidgen
, as this will be used in the next step. - Create a file with the
.json
extension. - Open the file in a text editor, and add the following information:
{ "id": "UID", "mountpoint": "MOUNTPT" }
{ "id": "UID", "mountpoint": "MOUNTPT" }
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace the following values:- Replace UID with the unique ID created in the previous step.
- Replace MOUNTPT with the mount point of the Image service's file system, as determined in the first step.
- Configure the Image service to use this JSON file:
openstack-config --set /etc/glance/glance-api.conf \ DEFAULT show_multiple_locations True openstack-config --set /etc/glance/glance-api.conf \ DEFAULT filesystem_store_metadata_file JSON_PATH
# openstack-config --set /etc/glance/glance-api.conf \ DEFAULT show_multiple_locations True # openstack-config --set /etc/glance/glance-api.conf \ DEFAULT filesystem_store_metadata_file JSON_PATH
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace JSON_PATH with the full path to the JSON file.Important
If configured without the proper policy settings, a non-admin user of the Image Service can replace active image data (that is, switch out a current image without other users knowing). See the OSSN announcement (recommended actions) for configuration information: https://wiki.openstack.org/wiki/OSSN/OSSN-0065 - Restart the Image service (if it is already running):
systemctl restart openstack-glance-registry.service systemctl restart openstack-glance-api.service
# systemctl restart openstack-glance-registry.service # systemctl restart openstack-glance-api.service
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
openstack-nova-compute
to load images from the local file system.
Procedure 5.11. Configuring the Compute Service to use File System Metadata Provided by the Image Service
- Configure
openstack-nova-compute
to enable the use of direct URLs that have thefile://
scheme:openstack-config --set /etc/nova/nova.conf \ DEFAULT allowed_direct_url_schemes file
# openstack-config --set /etc/nova/nova.conf \ DEFAULT allowed_direct_url_schemes file
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Create an entry for the Image service's file system:
openstack-config --set /etc/nova/nova.conf \ image_file_url filesystems FSENTRY
# openstack-config --set /etc/nova/nova.conf \ image_file_url filesystems FSENTRY
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace FSENTRY with a name to assign to the Image service's file system. - Open the
.json
file used by the Image service to expose its local file-system metadata. The information in this file will be used in the next step. - Associate the entry for Image service's file system to the file system metadata exposed by the Image service:
openstack-config --set /etc/nova/nova.conf \ image_file_url:FSENTRY id UID openstack-config --set /etc/nova/nova.conf \ image_file_url:FSENTRY mountpoint MOUNTPT
# openstack-config --set /etc/nova/nova.conf \ image_file_url:FSENTRY id UID # openstack-config --set /etc/nova/nova.conf \ image_file_url:FSENTRY mountpoint MOUNTPT
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Replace the following values:- Replace UID with the unique ID used by the Image service. In the
.json
file used by the Image service, the UID is the"id"
value. - Replace MOUNTPT with the mount point used by the Image service's file system. In the
.json
file used by the Image service, the MOUNTPT is the"mountpoint"
value.