OpenStack Train版-3.安装glance镜像服务
1. 创建数据库并授权
[ ~]# mysql -u root MariaDB [(none)]> CREATE DATABASE glance; Query OK, 1 row affected (0.000 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO ‘glance‘@‘localhost‘ IDENTIFIED BY ‘GLANCE_DBPASS‘; Query OK, 0 rows affected (0.000 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO ‘glance‘@‘%‘ IDENTIFIED BY ‘GLANCE_DBPASS‘; Query OK, 0 rows affected (0.000 sec)
2. 创建glance用户
[ ~]# openstack user create --domain default --password GLANCE_PASS glance +---------------------+----------------------------------+ | Field | Value | +---------------------+----------------------------------+ | domain_id | default | | enabled | True | | id | c9cccf601ece444a86fcba967b4633ad | | name | glance | | options | {} | | password_expires_at | None | +---------------------+----------------------------------+ 给glance用户授权 [ ~]# openstack role add --project service --user glance admin
3. 创建glance服务实体
[ ~]# openstack service create --name glance --description "OpenStack Image" image +-------------+----------------------------------+ | Field | Value | +-------------+----------------------------------+ | description | OpenStack Image | | enabled | True | | id | 165c4d71d9354940a7efe60a9bb71211 | | name | glance | | type | image | +-------------+----------------------------------+
4. 创建镜像服务API访问端点
[ ~]# openstack endpoint create --region RegionOne image public http://controller:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 94a3dac1cadd419f9d40e29a8dd8fed2 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 165c4d71d9354940a7efe60a9bb71211 | | service_name | glance | | service_type | image | | url | http://controller:9292 | +--------------+----------------------------------+ [ ~]# openstack endpoint create --region RegionOne image internal http://controller:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | c2be9485f8a7412490ca1af815041461 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 165c4d71d9354940a7efe60a9bb71211 | | service_name | glance | | service_type | image | | url | http://controller:9292 | +--------------+----------------------------------+ [ ~]# openstack endpoint create --region RegionOne image admin http://controller:9292 +--------------+----------------------------------+ | Field | Value | +--------------+----------------------------------+ | enabled | True | | id | 806cde326a604e15b9bd6ecbb9340787 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 165c4d71d9354940a7efe60a9bb71211 | | service_name | glance | | service_type | image | | url | http://controller:9292 | +--------------+----------------------------------+
5. 安装glance软件包
[ ~]# yum install openstack-glance
6. 编辑glance的配置文件
cp -a /etc/glance/glance-api.conf{,.bak} cp -a /etc/glance/glance-registry.conf{,.bak} grep -Ev ‘^$|#‘ /etc/glance/glance-api.conf.bak > /etc/glance/glance-api.conf grep -Ev ‘^$|#‘ /etc/glance/glance-registry.conf.bak > /etc/glance/glance-registry.conf openstack-config --set /etc/glance/glance-api.conf database connection mysql+pymysql://glance:/glance openstack-config --set /etc/glance/glance-api.conf keystone_authtoken www_authenticate_uri http://controller:5000 openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_url http://controller:5000 openstack-config --set /etc/glance/glance-api.conf keystone_authtoken memcached_servers controller:11211 openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_type password openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_domain_name Default openstack-config --set /etc/glance/glance-api.conf keystone_authtoken user_domain_name Default openstack-config --set /etc/glance/glance-api.conf keystone_authtoken project_name service openstack-config --set /etc/glance/glance-api.conf keystone_authtoken username glance openstack-config --set /etc/glance/glance-api.conf keystone_authtoken password GLANCE_PASS openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone openstack-config --set /etc/glance/glance-api.conf glance_store stores file,http openstack-config --set /etc/glance/glance-api.conf glance_store default_store file openstack-config --set /etc/glance/glance-api.conf glance_store filesystem_store_datadir /var/lib/glance/images/
7. 填充glance数据库
[ ~]# su -s /bin/sh -c "glance-manage db_sync" glance
8. 启动glance服务并设置开机自启
[ ~]# systemctl enable openstack-glance-api.service [ ~]# systemctl start openstack-glance-api.service 启动好之后,查看端口情况,如果有9292端口,则表示glance启动成功。 [ ~]# lsof -i:9292 COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME glance-ap 9333 glance 4u IPv4 48361 0t0 TCP *:armtechdaemon (LISTEN) glance-ap 9913 glance 4u IPv4 48361 0t0 TCP *:armtechdaemon (LISTEN)
9.下载cirros镜像,验证glance的安装
[ ~]# wget http://download.cirros-cloud.net/0.4.0/cirros-0.4.0-x86_64-disk.img [ ~]# openstack image create --file /root/cirros-0.4.0-x86_64-disk.img --disk-format qcow2 --container-format bare --public cirros +------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | Field | Value | +------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ | checksum | 443b7623e27ecf03dc9e01ee93f67afe | | container_format | bare | | created_at | 2020-01-09T14:30:34Z | | disk_format | qcow2 | | file | /v2/images/060d49e3-5346-4bbd-ba42-7247f2daead5/file | | id | 060d49e3-5346-4bbd-ba42-7247f2daead5 | | min_disk | 0 | | min_ram | 0 | | name | cirros | | owner | 8dd2972e6c0b4d99b100d087e35ad439 | | properties | os_hash_algo=‘sha512‘, os_hash_value=‘6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e2161b5b5186106570c17a9e58b64dd39390617cd5a350f78‘, os_hidden=‘False‘ | | protected | False | | schema | /v2/schemas/image | | size | 12716032 | | status | active | | tags | | | updated_at | 2020-01-09T14:30:35Z | | virtual_size | None | | visibility | public | +------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+ (官方文档坑点之一,这里不要使用官方文档里面的glance image-create这样的写法,新版本的OpenStack已经不支持,尽量统一使用以openstack开头的命令写法) [ ~]# glance image-list +--------------------------------------+--------+ | ID | Name | +--------------------------------------+--------+ | 060d49e3-5346-4bbd-ba42-7247f2daead5 | cirros | +--------------------------------------+--------+ 查看镜像的物理文件 [ ~]# ll /var/lib/glance/images/ total 12420 -rw-r----- 1 glance glance 12716032 Jan 9 22:30 060d49e3-5346-4bbd-ba42-7247f2daead5
相关推荐
Moolightshadow 2020-07-16
fyggzb 2020-07-05
gokeibi 2020-06-12
zziyuann 2020-06-12
fyggzb 2020-06-12
fyggzb 2020-06-10
JeremyLiu 2020-06-10
JeremyLiu 2020-06-10
jmppok 2020-06-07
jmppok 2020-06-05
hhphhp 2020-06-01
zziyuann 2020-05-17
gokeibi 2020-05-07
gokeibi 2020-04-26
gokeibi 2020-04-19
gokeibi 2020-04-19
嗯 2020-04-17