创建glance数据库
1进入数据库
$ mysql -u root -p
2 Create the glance databese 创建一个glance数据库
MariaDB [(none)]> CREATE DATABASE glance;
3 Grant 给数据库赋予权限
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \
IDENTIFIED BY 'GLANCE_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
IDENTIFIED BY 'GLANCE_DBPASS';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'用户名' \ IDENTIFIED BY 'GLANCE_DBPASS';
4 Source the admin credentials to gain access to admin-only CLI commands:
$ . admin-openrcz
5 创建服务:
Create the glance user:
$ openstack user create --domain default --password-prompt glance
User Password:
Repeat User Password:
Add the admin role to the glance user and service project:
$ openstack role add --project service --user glance admin
service为服务用户可更改
6创建glance服务:
$ openstack service create --name glance \
--description "OpenStack Image" image
7 创建api镜像文件:
$ openstack endpoint create --region RegionOne \
image public http://controller:9292
$ openstack endpoint create --region RegionOne \
image internal http://controller:9292
$ openstack endpoint create --region RegionOne \
image admin http://controller:9292
Install and configure components¶
8安装需要的包:
# yum install openstack-glance
编辑 /etc/glance/glance-api.conf 下的配置:
In the [database] section, configure database access:
[database]
# ...
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
GLANCE_DBPASS为自己的密码 controller为自己的ip
In the [keystone_authtoken] and [paste_deploy] sections, configure Identity service access:
[keystone_authtoken]
# ...
auth_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = GLANCE_PASS
#controller为自己的ip
#glance_pass为自己的密码
#service为自己的服务用户
[paste_deploy]
# ...
flavor = keystone
9打开[glance_store] section, 开启此目录下的文件:
[glance_store]
# ...
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
编辑/etc/glance/glance-registry.conf 目录下的文件操作:
In the [database] section, configure database access:
[database]
# ...
connection = mysql+pymysql://glance:GLANCE_DBPASS@controller/glance
GLANCE_DBPASS为自己的密码 controller为自己的ip
In the [keystone_authtoken] and [paste_deploy] sections, configure Identity service access:
[keystone_authtoken]
# ...
auth_uri = http://controller:5000
auth_url = http://controller:5000
memcached_servers = controller:11211
auth_type = password
project_domain_name = Default
user_domain_name = Default
project_name = service
username = glance
password = GLANCE_PASS
#controller为自己的ip
#glance_pass为自己的密码
#service为自己的服务用户
[paste_deploy]
# ...
flavor = keystone
10初始化数据库:
# su -s /bin/sh -c "glance-manage db_sync" glance
开启glance¶
# systemctl enable openstack-glance-api
systemctl enable openstack-glance-registry
# systemctl start openstack-glance-api
systemctl start openstack-glance-registry