Openstack Zed-Glance部署实现

系统环境: UbuntuServer 22.04 LTS Mini

一: 设定Glance相关信息

root@srv1:~(keystone)# openstack user create --domain default --project service --password servicepassword glance
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| default_project_id  | 4fabd4d8316c40a398d6496c0a733caf |
| domain_id           | default                          |
| enabled             | True                             |
| id                  | 37fbc0869121415785509976bba657a5 |
| name                | glance                           |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+
  
  root@srv1:~(keystone)# openstack role add --project service --user glance admin

root@srv1:~(keystone)# openstack role assignment list --name
+-------+----------------+-------+-----------------+--------+--------+-----------+
| Role  | User           | Group | Project         | Domain | System | Inherited |
+-------+----------------+-------+-----------------+--------+--------+-----------+
| admin | glance@Default |       | service@Default |        |        | False     |
| admin | admin@Default  |       | admin@Default   |        |        | False     |
| admin | admin@Default  |       |                 |        | all    | False     |
+-------+----------------+-------+-----------------+--------+--------+-----------+
  
  root@srv1:~(keystone)# openstack service create --name glance --description "OpenStack Image service" image
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Image service          |
| enabled     | True                             |
| id          | c7945ac7deb044a6b3219c456c454d86 |
| name        | glance                           |
| type        | image                            |
+-------------+----------------------------------+
  
  root@srv1:~(keystone)# openstack endpoint create --region RegionOne image public https://srv1.1000y.cloud:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | e9d0001142c04262bd276c041c053b5d |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | c7945ac7deb044a6b3219c456c454d86 |
| service_name | glance                           |
| service_type | image                            |
| url          | https://srv1.1000y.cloud:9292    |
+--------------+----------------------------------+
  
  root@srv1:~(keystone)# openstack endpoint create --region RegionOne image internal https://srv1.1000y.cloud:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | fe634386a635461d98c86eb3ef66069b |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | c7945ac7deb044a6b3219c456c454d86 |
| service_name | glance                           |
| service_type | image                            |
| url          | https://srv1.1000y.cloud:9292    |
+--------------+----------------------------------+

root@srv1:~(keystone)# openstack endpoint create --region RegionOne image admin https://srv1.1000y.cloud:9292
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 127171465d97440cae85a463d562bd38 |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | c7945ac7deb044a6b3219c456c454d86 |
| service_name | glance                           |
| service_type | image                            |
| url          | https://srv1.1000y.cloud:9292    |
+--------------+----------------------------------+

root@srv1:~(keystone)# openstack catalog show image
+-----------+-------------------------------------------+
| Field     | Value                                     |
+-----------+-------------------------------------------+
| endpoints | RegionOne                                 |
|           |   admin: https://srv1.1000y.cloud:9292    |
|           | RegionOne                                 |
|           |   public: https://srv1.1000y.cloud:9292   |
|           | RegionOne                                 |
|           |   internal: https://srv1.1000y.cloud:9292 |
|           |                                           |
| id        | c7945ac7deb044a6b3219c456c454d86          |
| name      | glance                                    |
| type      | image                                     |
+-----------+-------------------------------------------+


二: 创建Glance数据库

root@srv1:~(keystone)# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 38
Server version: 10.6.7-MariaDB-2ubuntu1.1 Ubuntu 22.04

Copyright (c) 2000, 2016, 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.001 sec)

MariaDB [(none)]> grant all privileges on glance.* to glance@'localhost' identified by 'password';
Query OK, 0 rows affected (0.018 sec)

MariaDB [(none)]> grant all privileges on glance.* to glance@'%' identified by 'password';
Query OK, 0 rows affected (0.023 sec)

MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.002 sec)

MariaDB [(none)]> exit
Bye
root@srv1:~(keystone)#


三: 安装及配置Glance

1) 安装Glance
root@srv1:~(keystone)# apt install glance -y

2) 配置Glance API
root@srv1:~(keystone)# mv /etc/glance/glance-api.conf /etc/glance/glance-api.conf.bak
root@srv1:~(keystone)# vim /etc/glance/glance-api.conf
[DEFAULT]
bind_host = 127.0.0.1
transport_url = rabbit://openstack:password@srv1.1000y.cloud

[glance_store]
stores = file,http
default_store = file
filesystem_store_datadir = /var/lib/glance/images/

[database]
connection = mysql+pymysql://glance:password@srv1.1000y.cloud/glance

[keystone_authtoken]
www_authenticate_uri = https://srv1.1000y.cloud:5000
auth_url = https://srv1.1000y.cloud:5000
memcached_servers = srv1.1000y.cloud:11211
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = glance
password = servicepassword
insecure = true

[paste_deploy]
flavor = keystone

root@srv1:~(keystone)# chmod 640 /etc/glance/glance-api.conf
root@srv1:~(keystone)# chown root.glance /etc/glance/glance-api.conf

root@srv1:~(keystone)# su -s /bin/bash glance -c "glance-manage db_sync"
2022-10-24 16:30:42.719 11362 INFO alembic.runtime.migration [-] Context impl MySQLImpl.
2022-10-24 16:30:42.720 11362 INFO alembic.runtime.migration [-] Will assume non-transactional DDL.
2022-10-24 16:30:42.733 11362 INFO alembic.runtime.migration [-] Context impl MySQLImpl.
2022-10-24 16:30:42.733 11362 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  -> liberty, liberty initial
......
......
......
......
......
......
Database is synced successfully.

root@srv1:~(keystone)# systemctl restart glance-api && systemctl enable glance-api

3) 配置Nginx Porxy
root@srv1:~(keystone)# vim /etc/nginx/nginx.conf
......
......
......
......
......
......

stream {
    upstream glance-api {
        server 127.0.0.1:9292;
    }
    server {
        listen srv1.1000y.cloud:9292 ssl;
        proxy_pass glance-api;
    }
    ssl_certificate "/etc/ssl/private/zed.crt";
    ssl_certificate_key "/etc/ssl/private/zed.key";
}

root@srv1:~(keystone)# systemctl restart nginx

四: 下载镜像并设定

1) 下载镜像
root@srv1:~(keystone)# wget http://cloud-images.ubuntu.com/releases/22.04/release/ubuntu-22.04-server-cloudimg-amd64.img

2) 更改镜像设定
root@srv1:~(keystone)# modprobe nbd

root@srv1:~(keystone)# qemu-nbd --connect=/dev/nbd0 ubuntu-22.04-server-cloudimg-amd64.img

root@srv1:~(keystone)# mount /dev/nbd0p1 /mnt

root@srv1:~(keystone)# chroot /mnt /bin/bash

root@srv1:/# vim /etc/cloud/cloud.cfg
......
......
......
......
......
......
disable_root: true
# 于13行,添加如下内容
ssh_pwauth: true

......
......
......
......
......
......

# System and/or distro specific settings
# (not accessible to handlers/transforms)
system_info:
   # This will affect which distro class gets used
   distro: ubuntu
   # Default user name + that default users groups (if added/used)
   default_user:
     # 更改102行的值
     name: snow
     # 更改103行的值
     lock_passwd: False
     # 更改104行的值
     gecos: snow
     groups: [adm, audio, cdrom, dialout, dip, floppy, lxd, netdev, plugdev, sudo, video]
     sudo: ["ALL=(ALL) NOPASSWD:ALL"]
     shell: /bin/bash
......
......
......
......
......
......

root@srv1:/# adduser snow
Adding user `snow' ...                       
Adding new group `snow' (1000) ...                                                               
Adding new user `snow' (1000) with group `snow' ...      
Creating home directory `/home/snow' ... 
Copying files from `/etc/skel' ...
New password:     # 设定密码
Retype new password: 
passwd: password updated successfully
Changing the user information for snow
Enter the new value, or press ENTER for the default
        Full Name []:      # 回车
        Room Number []:       # 回车
        Work Phone []:       # 回车
        Home Phone []:       # 回车
        Other []:       # 回车
Is the information correct? [Y/n] y

root@srv1:/# exit

root@srv1:~(keystone)# umount /mnt
root@srv1:~(keystone)# qemu-nbd --disconnect /dev/nbd0p1
/dev/nbd0p1 disconnected


五: 将镜像添加至Glance

root@srv1:~(keystone)# openstack image create "us2204" 
--file ubuntu-22.04-server-cloudimg-amd64.img 
--disk-format qcow2 
--container-format bare 
--public
+------------------+-------------------------------------------------------
| Field            | Value                                                 
+------------------+-------------------------------------------------------
| container_format | bare                                                  
| created_at       | 2022-10-24T08:51:03Z                                  
| disk_format      | qcow2                                                 
| file             | /v2/images/e1f0e4a7-26a6-4357-8358-9b35a76e3a9b/file  
| id               | e1f0e4a7-26a6-4357-8358-9b35a76e3a9b                  
| min_disk         | 0                                                     
| min_ram          | 0                                                     
| name             | us2204                                                
| owner            | 994a4a3e0fbc4f5891f38470e158e6b4                      
| properties       | os_hidden='False', owner_specified.openstack.md5=''.. 
| protected        | False                                                 
| schema           | /v2/schemas/image                                     
| status           | queued                                                
| tags             |                                                       
| updated_at       | 2022-10-24T08:51:03Z                                  
| visibility       | public                                                
+------------------+-------------------------------------------------------

root@srv1:~(keystone)# openstack image list
+--------------------------------------+--------+--------+
| ID                                   | Name   | Status |
+--------------------------------------+--------+--------+
| e1f0e4a7-26a6-4357-8358-9b35a76e3a9b | us2204 | active |
+--------------------------------------+--------+--------+
展开阅读全文

页面更新:2024-04-25

标签:密码   环境   数据库   内容   系统

1 2 3 4 5

上滑加载更多 ↓
推荐阅读:
友情链接:
更多:

本站资料均由网友自行发布提供,仅用于学习交流。如有版权问题,请与我联系,QQ:4156828  

© CopyRight 2008-2024 All Rights Reserved. Powered By bs178.com 闽ICP备11008920号-3
闽公网安备35020302034844号

Top