本溪網(wǎng)站建設(shè)網(wǎng)站建站公司
目錄
1、登錄數(shù)據(jù)庫(kù)授權(quán)
2、安裝glance
3、測(cè)試一下
安裝部署Glance鏡像服務(wù)
- Image Service? 鏡像服務(wù):
- 代號(hào):Glance:
- 為云平臺(tái)虛擬機(jī)提供鏡像服務(wù),例如:上傳鏡像、刪除鏡像等。
- 說明:鏡像:磁盤文件。裝好了系統(tǒng)的磁盤文件。把鏡像拷貝過來,就不需要裝系統(tǒng)。
1、登錄數(shù)據(jù)庫(kù)授權(quán)
1.Use the database access client to connect to the database server as the?root
?user(登錄數(shù)據(jù)庫(kù))
[root@controller ~]# mysql -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 31
Server version: 10.3.20-MariaDB MariaDB ServerCopyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.MariaDB [(none)]>
2.Create the?glance
?database(數(shù)據(jù)庫(kù)里創(chuàng)建glance)
MariaDB [(none)]> CREATE DATABASE glance;
3.Grant proper access to the?glance
?database:
MariaDB [(none)]> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \
IDENTIFIED BY '123';
4.退出數(shù)據(jù)庫(kù)
MariaDB [(none)]> quit
5.Create the?glance
?user(創(chuàng)建glance用戶密碼為glance)?
[root@controller ~]# openstack user create --domain default --password glance glance
Missing value auth-url required for auth plugin password
如上我的這里會(huì)報(bào)錯(cuò),時(shí)因?yàn)闆]有source環(huán)境變量導(dǎo)致。
如下修改/etc/profile文件解決:
#[root@controller ~]# vi /etc/profileexport OS_USERNAME=admin
export OS_PASSWORD=123
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
[root@controller ~]# source /etc/profile
[root@controller ~]# openstack user create --domain default --password glance glance
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | 0293557b8f094dd3855537343b14228b |
| name | glance |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
6.Add the?admin
?role to the?glance
?user and?service
?project(增加admin角色)
[root@controller ~]# openstack role add --project service --user glance admin
7.Create the?glance
?service entity(創(chuàng)建glance服務(wù))
[root@controller ~]# openstack service create --name glance \
> --description "OpenStack Image" image
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Image |
| enabled | True |
| id | 906253e30699402a9f3a52405119532c |
| name | glance |
| type | image |
+-------------+----------------------------------+
8.Create the Image service API endpoints(創(chuàng)建API端點(diǎn))
[root@controller ~]# openstack endpoint create --region RegionOne \
> image public http://controller:9292
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 572837d27f794675a4be0d5b32f7d442 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 906253e30699402a9f3a52405119532c |
| 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 | f23f9f9af4854d49aa87076c51630e28 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 906253e30699402a9f3a52405119532c |
| 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 | 8ab8803387634f20acaf2c5443381f54 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 906253e30699402a9f3a52405119532c |
| service_name | glance |
| service_type | image |
| url | http://controller:9292 |
+--------------+----------------------------------+
2、安裝glance
1.安裝glance包
[root@controller ~]# yum install openstack-glance -y
2.備份配置文件并且修改(修改了4個(gè)地方)
[root@controller ~]# cp /etc/glance/glance-api.conf{,.bak}
[root@controller ~]# grep -Ev "^$|#" /etc/glance/glance-api.conf.bak > /etc/glance/glance-api.conf
[root@controller ~]# vi /etc/glance/glance-api.conf
[DEFAULT]
[cinder]
[cors]
[database]
connection = mysql+pymysql://glance:123@controller/glance
[file]
[glance.store.http.store]
[glance.store.rbd.store]
[glance.store.sheepdog.store]
[glance.store.swift.store]
[glance.store.vmware_datastore.store]
[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/
[image_format]
[keystone_authtoken]
www_authenticate_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
[oslo_concurrency]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_middleware]
[oslo_policy]
[paste_deploy]
flavor = keystone
[profiler]
[store_type_location_strategy]
[task]
[taskflow_executor]
3.同步數(shù)據(jù)庫(kù)
[root@controller ~]# su -s /bin/sh -c "glance-manage db_sync" glance
[root@controller ~]# systemctl start openstack-glance-api.service
[root@controller ~]# systemctl enable openstack-glance-api.service
4.(這一步可以不做)現(xiàn)在glance沒有日志,我們需要配置下
#[root@controller ~]# vi /etc/glance/glance-api.conf[DEFAULT]
log_file = /var/log/glance/glance-api.log
[root@controller ~]# systemctl restart openstack-glance-api.service
[root@controller ~]# tail -f /var/log/glance/glance-api.log
). Its value may be silently ignored in the future.
2023-02-09 10:18:22.350 43599 INFO glance.common.wsgi [-] Starting 4 workers
2023-02-09 10:18:22.352 43599 INFO glance.common.wsgi [-] Started child 43611
2023-02-09 10:18:22.354 43611 INFO eventlet.wsgi.server [-] (43611) wsgi starting up on http://0.0.0.0:9292
2023-02-09 10:18:22.355 43599 INFO glance.common.wsgi [-] Started child 43612
2023-02-09 10:18:22.357 43612 INFO eventlet.wsgi.server [-] (43612) wsgi starting up on http://0.0.0.0:9292
2023-02-09 10:18:22.358 43599 INFO glance.common.wsgi [-] Started child 43613
2023-02-09 10:18:22.360 43613 INFO eventlet.wsgi.server [-] (43613) wsgi starting up on http://0.0.0.0:9292
2023-02-09 10:18:22.361 43599 INFO glance.common.wsgi [-] Started child 43614
2023-02-09 10:18:22.363 43614 INFO eventlet.wsgi.server [-] (43614) wsgi starting up on http://0.0.0.0:9292
3、測(cè)試一下
下載cirros-0.4.0-x86_64-disk.img這個(gè)鏡像上傳到/opt下面(鏡像文件在我的資源csdn下載地方找到)
切換到/opt目錄下
[root@controller opt]# ls
cirros-0.4.0-x86_64-disk.img
[root@controller opt]# glance image-create --name "cirros" \
> --file cirros-0.4.0-x86_64-disk.img \
> --disk-format qcow2 --container-format bare \
> --visibility=public
+------------------+----------------------------------------------------------------------------------+
| Property | Value |
+------------------+----------------------------------------------------------------------------------+
| checksum | 443b7623e27ecf03dc9e01ee93f67afe |
| container_format | bare |
| created_at | 2023-02-09T15:25:52Z |
| disk_format | qcow2 |
| id | 79e21395-0d41-4c98-86f2-bfa813a48a2f |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| os_hash_algo | sha512 |
| os_hash_value | 6513f21e44aa3da349f248188a44bc304a3653a04122d8fb4535423c8e1d14cd6a153f735bb0982e |
| | 2161b5b5186106570c17a9e58b64dd39390617cd5a350f78 |
| os_hidden | False |
| owner | 4c7bdbb75b9e481db886549f7d2711be |
| protected | False |
| size | 12716032 |
| status | active |
| tags | [] |
| updated_at | 2023-02-09T15:25:53Z |
| virtual_size | Not available |
| visibility | public |
+------------------+----------------------------------------------------------------------------------+
[root@controller opt]# glance image-list
+--------------------------------------+--------+
| ID | Name |
+--------------------------------------+--------+
| 79e21395-0d41-4c98-86f2-bfa813a48a2f | cirros |
+--------------------------------------+--------+
以上說明部署glance成功
【glance鏡像服務(wù)】
- 它在open stack中的項(xiàng)目名稱為Glance.在早期的open stack版本中,Glance只有管理鏡像的功能,并不具備鏡像存儲(chǔ)功能?,F(xiàn)在,Glance已經(jīng)發(fā)展稱為集上傳,檢索,管理和存儲(chǔ)等多種功能的open stack核心服務(wù)。
【glance由兩部分組成】
(1)glance-api: 接受云系統(tǒng)鏡像的創(chuàng)建,刪除,讀取請(qǐng)求
(2)glance-Registry: 云系統(tǒng)的鏡像注冊(cè)服務(wù)
- glance-api 是接受 rest api請(qǐng)求的。完成諸如鏡像的查找,獲取,上傳,刪除等操作,默認(rèn)是監(jiān)聽9292端口
- glance-registry 是用于Mysql的數(shù)據(jù)交互,用戶存儲(chǔ)或獲取鏡像的元數(shù)據(jù)(metadata);提供鏡像元數(shù)據(jù)相關(guān)的REST接口,通過glance-Registry,可以向數(shù)據(jù)庫(kù)中寫入或獲取鏡像的各種數(shù)據(jù)。glance-Registry監(jiān)聽的端口是9191.Glance數(shù)據(jù)庫(kù)中有兩種表,一張是image表,主要存儲(chǔ)了鏡像格式,大小等信息;另一張是image property表,主要存了鏡像定制化信息。
- image-store是一個(gè)存儲(chǔ)的接口層,通過這個(gè)接口,glance可以獲取鏡像,image store支持的存儲(chǔ)有Amazon的S3,Openstack本身的swift,還有諸如ceph,sheepdog,GluasterFS等分布式存儲(chǔ),image store是鏡像保存與獲取的接口,它僅僅是一個(gè)接口層,具體的實(shí)現(xiàn)需要外部的存儲(chǔ)支持。
【鏡像服務(wù)的主要功能】
- 1.查詢和獲取鏡像的元數(shù)據(jù)和鏡像本身
- 2.注冊(cè)和上傳虛擬機(jī)鏡像,包括鏡像的創(chuàng)建、上傳、下載和管理
- 3.維護(hù)鏡像信息,包括元數(shù)據(jù)和鏡像本身
- 4.支持多種方式存儲(chǔ)鏡像,包括普通的文件系統(tǒng)、swift、Amazon、S3等
- 5.對(duì)虛擬機(jī)實(shí)例執(zhí)行創(chuàng)建快照命令來創(chuàng)建新的鏡像,或者備份虛擬機(jī)的狀態(tài)
-
OpenStack簡(jiǎn)介 | 常見的基礎(chǔ)組件
-
OpenStack云平臺(tái)搭建(1) | 基礎(chǔ)環(huán)境準(zhǔn)備
-
OpenStack云平臺(tái)搭建(2) | 安裝Keystone