部署Glance

2022-12-13 12:23:50 浏览数 (3)

部署Glance

1、创建glance数据库、用户、表 登录MySQL客户端,创建数据库和用户,并授权相应的数据库权限 [root@controller ~]# mysql -u root -p000000 Welcome to the MariaDB monitor. Commands end with ; or g. Your MariaDB connection id is 22 Server version: 10.3.20-MariaDB MariaDB Server

Copyright © 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type ‘help;’ or ‘h’ for help. Type ‘c’ to clear the current input statement.

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’;* Query OK, 0 rows affected (0.001 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance. TO ‘glance’@‘controller’ IDENTIFIED BY ‘glance’;* Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance. TO ‘glance’@’%’ IDENTIFIED BY ‘glance’;* Query OK, 0 rows affected (0.000 sec)

MariaDB [(none)]> exit Bye 2、创建OpenStack中的glance用户 创建用户之前,需要先执行管理员环境变量脚本 [root@controller ~]# ./admin-openrc [root@controller ~]# openstack user create --domain default --password-prompt glance User Password:000000 Repeat User Password:000000 ±--------------------±--------------------------------- | Field | Value | ±--------------------±--------------------------------- | domain_id | default | | enabled | True | | id | 0c968195a7a54fe690c5dd755a8030f7 | | name | glance | | options | {} | | password_expires_at | None | ±--------------------±--------------------------------- [root@controller ~]# openstack role add --project service --user glance admin [root@controller ~]# openstack service create --name glance --description “OpenStack Image” image ±------------±--------------------------------- | Field | Value | ±------------±--------------------------------- | description | OpenStack Image | | enabled | True | | id | 62cb2bbb9ffd42d289a3791aff402a76 | | name | glance | | type | image | ±------------±--------------------------------- 3、创建镜像服务API端点 [root@controller ~]# openstack endpoint create --region RegionOne image public http://controller:9292 ±-------------±--------------------------------- | Field | Value | ±-------------±--------------------------------- | enabled | True | | id | 41f1e1a662fc4db8a9f27677ed5a0dd7 | | interface | public | | region | RegionOne | | region_id | RegionOne | | service_id | 62cb2bbb9ffd42d289a3791aff402a76 | | service_name | glance | | service_type | image | | url | http://controller:9292 | ±-------------±--------------------------------- [root@controller ~]# openstack endpoint create --region RegionOne image internal http://controller:9292 ±-------------±--------------------------------- | Field | Value | ±-------------±--------------------------------- | enabled | True | | id | 3e4e422427b143aeba70a99bb4cb1200 | | interface | internal | | region | RegionOne | | region_id | RegionOne | | service_id | 62cb2bbb9ffd42d289a3791aff402a76 | | service_name | glance | | service_type | image | | url | http://controller:9292 | ±-------------±--------------------------------- [root@controller ~]# openstack endpoint create --region RegionOne image admin http://controller:9292 ±-------------±--------------------------------- | Field | Value | ±-------------±--------------------------------- | enabled | True | | id | 1fcda8fb74d9477497cd828fafec03a6 | | interface | admin | | region | RegionOne | | region_id | RegionOne | | service_id | 62cb2bbb9ffd42d289a3791aff402a76 | | service_name | glance | | service_type | image | | url | http://controller:9292 | ±-------------±--------------------------------- 4、安装glance包 [root@controller ~]# yum install -y openstack-glance 5、配置/etc/glance/glance-api.conf文件 在配置文件的相应位置添加以下配置内容 [root@controller ~]# vim /etc/glance/glance-api.conf [database] connection = mysql pymysql://glance:glance@controller/glance [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 = 000000 [paste_deploy] lavor = keystone [glance_store] stores = file,http default_store = file filesystem_store_datadir = /var/lib/glance/images/ 6、配置/etc/glance/glance-registry.conf文件 在配置文件的相应位置添加以下配置内容 [root@controller ~]# vim /etc/glance/glance-registry.conf [database] connection=mysql pymysql://glance:glance@controller/glance [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 = 000000 [paste_deploy] flavor = keystone 7、初始化glance数据库 [root@controller ~]# su -s /bin/sh -c “glance-manage db_sync” glance INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. /usr/lib/python2.7/site-packages/pymysql/cursors.py:170: Warning: (1280, u"Name ‘alembic_version_pkc’ ignored for PRIMARY key.") result = self._query(query) INFO [alembic.runtime.migration] Running upgrade -> liberty, liberty initial INFO [alembic.runtime.migration] Running upgrade liberty -> mitaka01, add index on created_at and updated_at columns of ‘images’ table INFO [alembic.runtime.migration] Running upgrade mitaka01 -> mitaka02, update metadef os_nova_server INFO [alembic.runtime.migration] Running upgrade mitaka02 -> ocata_expand01, add visibility to images INFO [alembic.runtime.migration] Running upgrade ocata_expand01 -> pike_expand01, empty expand for symmetry with pike_contract01 INFO [alembic.runtime.migration] Running upgrade pike_expand01 -> queens_expand01 INFO [alembic.runtime.migration] Running upgrade queens_expand01 -> rocky_expand01, add os_hidden column to images table INFO [alembic.runtime.migration] Running upgrade rocky_expand01 -> rocky_expand02, add os_hash_algo and os_hash_value columns to images table INFO [alembic.runtime.migration] Running upgrade rocky_expand02 -> train_expand01, empty expand for symmetry with train_contract01 INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. Upgraded database to: train_expand01, current revision(s): train_expand01 INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. Database migration is up to date. No migration needed. INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. INFO [alembic.runtime.migration] Running upgrade mitaka02 -> ocata_contract01, remove is_public from images INFO [alembic.runtime.migration] Running upgrade ocata_contract01 -> pike_contract01, drop glare artifacts tables INFO [alembic.runtime.migration] Running upgrade pike_contract01 -> queens_contract01 INFO [alembic.runtime.migration] Running upgrade queens_contract01 -> rocky_contract01 INFO [alembic.runtime.migration] Running upgrade rocky_contract01 -> rocky_contract02 INFO [alembic.runtime.migration] Running upgrade rocky_contract02 -> train_contract01 INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. Upgraded database to: train_contract01, current revision(s): train_contract01 INFO [alembic.runtime.migration] Context impl MySQLImpl. INFO [alembic.runtime.migration] Will assume non-transactional DDL. Database is synced successfully. 8、启动glance相关服务 [root@controller ~]# systemctl start openstack-glance-api.service && systemctl start openstack-glance-registry.service [root@controller ~]# systemctl enable openstack-glance-api.service && systemctl enable openstack-glance-registry.service Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-api.service to /usr/lib/systemd/system/openstack-glance-api.service. Created symlink from /etc/systemd/system/multi-user.target.wants/openstack-glance-registry.service to /usr/lib/systemd/system/openstack-glance-registry.service. 9、验证操作 执行admin环境变量脚本,从互联网下载测试镜像“cirros”并导入glance,查看是否创建成功 [root@controller ~]# ./admin-openrc [root@controller ~]# openstack image list [root@controller ~]# wget http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img [root@controller ~]# openstack image create “cirrors” --file cirros-0.3.5-x86_64-disk.img --disk-format qcow2 --container-format bare ±-----------------±------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | Field | Value | ±-----------------±------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | checksum | f8ab98ff5e73ebab884d80c9dc9c7290 | | container_format | bare | | created_at | 2020-05-08T13:50:34Z | | disk_format | qcow2 | | file | /v2/images/40c8e1bf-e114-40a1-b768-3a3e7a6daee4/file | | id | 40c8e1bf-e114-40a1-b768-3a3e7a6daee4 | | min_disk | 0 | | min_ram | 0 | | name | cirrors | | owner | None | | properties | os_hash_algo=‘sha512’, os_hash_value=‘f0fd1b50420dce4ca382ccfbb528eef3a38bbeff00b54e95e3876b9bafe7ed2d6f919ca35d9046d437c6d2d8698b1174a335fbd66035bb3edc525d2cdb187232’, os_hidden=‘False’ | | protected | False | | schema | /v2/schemas/image | | size | 13267968 | | status | active | | tags | | | updated_at | 2020-05-08T13:50:35Z | | virtual_size | None | | visibility | shared | ±-----------------±------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- [root@controller ~]# openstack image list ±-------------------------------------±--------±------- | ID | Name | Status | ±-------------------------------------±--------±------- | 40c8e1bf-e114-40a1-b768-3a3e7a6daee4 | cirrors | active | ±-------------------------------------±--------±------- 至此,glance部署完成。

0 人点赞