Installing and Configuring the Image Service Install the Image service, as root: # sudo apt-get install glance # yum install openstack-glance # zypper install openstack-glance If you are using Ubuntu, delete the glance.sqlite file created in the /var/lib/glance/ directory: # rm /var/lib/glance/glance.sqlite
Configuring the Image Service database backend Configure the backend data store. For MySQL, create a glance MySQL database and a glance MySQL user. Grant the "glance" user full access to the glance MySQL database. Start the MySQL command line client by running: $ mysql -u root -p Enter the MySQL root user's password when prompted. To configure the MySQL database, create the glance database. mysql> CREATE DATABASE glance; Create a MySQL user for the newly-created glance database that has full control of the database. mysql> GRANT ALL ON glance.* TO 'glance'@'%' IDENTIFIED BY '[YOUR_GLANCEDB_PASSWORD]'; mysql> GRANT ALL ON glance.* TO 'glance'@'localhost' IDENTIFIED BY '[YOUR_GLANCEDB_PASSWORD]'; In the above commands, even though the 'glance'@'%' also matches 'glance'@'localhost', you must explicitly specify the 'glance'@'localhost' entry. By default, MySQL will create entries in the user table with User='' and Host='localhost'. The User='' acts as a wildcard, matching all users. If you do not have the 'glance'@'localhost' account, and you try to log in as the glance user, the precedence rules of MySQL will match against the User='' Host='localhost' account before it matches against the User='glance' Host='%' account. This will result in an error message that looks like: ERROR 1045 (28000): Access denied for user 'glance'@'localhost' (using password: YES) Thus, we create a separate User='glance' Host='localhost' entry that will match with higher precedence. See the MySQL documentation on connection verification for more details on how MySQL determines which row in the user table it uses when authenticating connections. Enter quit at the mysql> prompt to exit MySQL. mysql> quit
Edit the Glance configuration files The Image service has a number of options that you can use to configure the Glance API server, optionally the Glance Registry server, and the various storage backends that Glance can use to store images. By default, the storage backend is in a file, specified in the glance-api.conf config file in the section [DEFAULT]. The glance-api service implements versions 1 and 2 of the OpenStack Images API. By default, both are enabled by setting these configuration options to True in the glance-api.conf file. enable_v1_api=True enable_v2_api=True Disable either version of the Images API by setting the option to False in the glance-api.conf file. In order to use the v2 API, you must copy the necessary SQL configuration from your glance-registry service to your glance-api configuration file. The following instructions assume that you want to use the v2 Image API for your installation. The v1 API is implemented on top of the glance-registry service while the v2 API is not. Most configuration is done via configuration files, with the Glance API server (and possibly the Glance Registry server) using separate configuration files. When installing through an operating system package management system, sample configuration files are installed in /etc/glance. This walkthrough installs the image service using a file backend and the Identity service (Keystone) for authentication. Add the admin and service identifiers and flavor=keystone to the end of /etc/glance/glance-api.conf as shown below. [keystone_authtoken] auth_host = 127.0.0.1 auth_port = 35357 auth_protocol = http admin_tenant_name = service admin_user = glance admin_password = glance [paste_deploy] # Name of the paste configuration file that defines the available pipelines config_file = /etc/glance/glance-api-paste.ini # Partial name of a pipeline in your paste configuration file with the # service name removed. For example, if your paste section name is # [pipeline:glance-api-keystone], you would configure the flavor below # as 'keystone'. flavor=keystone Ensure that /etc/glance/glance-api.conf points to the MySQL database rather than sqlite.sql_connection = mysql://glance:[YOUR_GLANCEDB_PASSWORD]@192.168.206.130/glance Restart glance-api to pick up these changed settings. # service openstack-glance-api restart Update the last sections of /etc/glance/glance-registry.conf to reflect the values you set earlier for admin user and the service tenant, plus enable the Identity service with flavor=keystone. [keystone_authtoken] auth_host = 127.0.0.1 auth_port = 35357 auth_protocol = http admin_tenant_name = service admin_user = glance admin_password = glance [paste_deploy] # Name of the paste configuration file that defines the available pipelines config_file = /etc/glance/glance-registry-paste.ini # Partial name of a pipeline in your paste configuration file with the # service name removed. For example, if your paste section name is # [pipeline:glance-api-keystone], you would configure the flavor below # as 'keystone'. flavor=keystone Update /etc/glance/glance-registry-paste.ini by enabling the Identity service, keystone: # Use this pipeline for keystone auth [pipeline:glance-registry-keystone] pipeline = authtoken context registryapp Ensure that /etc/glance/glance-registry.conf points to the MySQL database rather than sqlite.sql_connection = mysql://glance:[YOUR_GLANCEDB_PASSWORD]@192.168.206.130/glance Restart glance-registry to pick up these changed settings. # service openstack-glance-registry restart Any time you change the .conf files, restart the corresponding service. On Ubuntu 12.04, the database tables are under version control and you must do these steps on a new install to prevent the Image service from breaking possible upgrades, as root: # glance-manage version_control 0 Now you can populate or migrate the database. # glance-manage db_sync Restart glance-registry and glance-api services, as root: # service glance-registry restart # service glance-api restart This guide does not configure image caching. Refer to http://docs.openstack.org/developer/glance/ for more information.