Openstack组件部署 — Keystone Install & Create service entity and API endpoints

本文涉及的产品
RDS MySQL Serverless 基础系列,0.5-2RCU 50GB
云数据库 RDS PostgreSQL,高可用系列 2核4GB
云数据库 RDS MySQL,高可用系列 2核4GB
简介: 目录目录前文列表Install and configurePrerequisites 先决条件Create the database for identity service生成一个随机数Install and configure compone...

目录

前文列表

Openstack组件部署 — Overview和前期环境准备
Openstack组建部署 — Environment of Controller Node
Openstack组件部署 — Keystone功能介绍与认证实现流程

Install and configure

This section describes how to install and configure the OpenStack Identity service, code-named keystone, on the controller node.
For performance, this configuration deploys Fernet tokens and the Apache HTTP server to handle requests.

这一节记录了怎样在Controller Node上安装和配置Openstack的认证服务,代号为Keystone。在性能上,这个配置使用了Fernet Tokens和Apache HTTP服务器去处理请求。

Fernet Tokens:是K版本的更新内容,区别于UUID tokens只能持久化存入数据库,Fernet tokens完全不需要持久化。部署人员可以通过设置keystone.conf中的[token] provider = keystone.token.providers.fernet.Provider来启用Fernet token,这也是我们一会需要配置的参数项。Fernet tokens需要symmetric encryption keys(对称加密密钥),这些keys可以使用keystone-manage fernet_setup建立, 并且使用keystone-manage fernet_rotate周期性地轮换。这些keys必须被在一个multi-node(或者multi-region)部署中的所有Keystone nodes共享,这样就能使一个node生成的tokens可以立即被其他节点验证。

Prerequisites 先决条件

Before you configure the OpenStack Identity service, you must create a database and an administration token.
在配置Openstack认证服务之前,你需要先创建一个keystone数据库和一个用于初始化keystone期间的临时管理token。

Create the database for identity service

这个数据库用于存放Keystone组件(User、Tenant、Roles等)的相关信息。
Step1.进入MySQL

mysql -u root -pfanguiju

Step2.创建数据库keystone

CREATE DATABASE keystone;

Step3.创建keystone数据库用户并授予适当的访问权限
创建keystone数据库用户,使其可以对keystone数据库有完全控制权限。

GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'fanguiju';     #fanguiju为用户keystone的密码
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'fanguiju';

Step4.退出MySQL

MariaDB [(none)]> exit
Bye

生成一个随机数

Generate a random value to use as the administration token during initial configuration
生成一个用于初始化keystone期间的临时管理token

[root@controller Desktop]# openssl rand -hex 10
c44048d3212d3f977643

Install and configure components

Note:This guide uses the Apache HTTP server with mod_wsgi to serve Identity service requests on ports 5000 and 35357. By default, the keystone service still listens on these ports. Therefore, this guide manually disables the keystone service.
注意:该指南使用Apache Http服务器的mod_wsgi(Python Web Server Gateway Interface)动态访问模块来支持认证服务在5000和35357端口上的请求。keystone service默认就会监听这两个端口,所以,该指南手动的禁用keystone service。

WSGI:Python Web服务器网关接口(Python Web Server Gateway Interface,缩写为WSGI),是Python应用程序或框架和Web服务器之间的一种接口,已经被广泛接受, 它已基本达成它的可移植性方面的目标。

Step1.安装openstack-keystoneHTTPmod_wsgi模块

yum install openstack-keystone httpd mod_wsgi -y

Step2.Edit the /etc/keystone/keystone.conf file and complete the following actions:
vim /etc/keystone/keystone.conf

#1. In the [DEFAULT] section, define the value of the initial administration token:
[DEFAULT]
admin_token = c44048d3212d3f977643              #刚刚使用openssl指令生成的随机数

#2. In the [database] section, configure database access:
[database]
connection = mysql+pymysql://keystone:fanguiju@controller.jmilk.com/keystone       #数据库连接配置 --> 使用mysql+pymysql协议://访问keystone用户:密码为范桂飓@数据库服务器hostname/访问keystone数据库;必要时可能需要使用IP代替hostname

#3. In the [token] section, configure the Fernet token provider:
[token]
provider = fernet

总览

[root@controller ~]# cat /etc/keystone/keystone.conf | grep -v ^# | grep -v ^$
[DEFAULT]
admin_token = c44048d3212d3f977643
[assignment]
[auth]
[cache]
[catalog]
[cors]
[cors.subdomain]
[credential]
[database]
connection = mysql+pymysql://keystone:fanguiju@controller.jmilk.com/keystone
[domain_config]
[endpoint_filter]
[endpoint_policy]
[eventlet_server]
[eventlet_server_ssl]
[federation]
[fernet_tokens]
[identity]
[identity_mapping]
[kvs]
[ldap]
[matchmaker_redis]
[memcache]
[oauth1]
[os_inherit]
[oslo_messaging_amqp]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_middleware]
[oslo_policy]
[paste_deploy]
[policy]
[resource]
[revoke]
[role]
[saml]
[shadow_users]
[signing]
[ssl]
[token]
provider = fernet
[tokenless_auth]
[trust]

注意:从总览的内容可以看出,在最新的版本中,第一次安装Keystone组件的时候,配置文件中的节点内容都是空的。但如果是使用该指南来安装其他版本Keystone的话,需要注意,我们应该是添加该指南的参数项到配置文件中,而不需要删除原来就已经存在的参数项。

Step3.Populate the Identity service database:

su -s /bin/sh -c "keystone-manage db_sync" keystone      #使用sh执行keystone数据库初始化填充指令

查看数据库表是否创建成功

[root@controller Desktop]# mysql -u keystone -pfanguiju
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 3
Server version: 10.1.12-MariaDB MariaDB Server

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)]> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| keystone           |
+--------------------+
2 rows in set (0.03 sec)

MariaDB [(none)]> use keystone;
Database changed

MariaDB [keystone]> show tables;
+------------------------+
| Tables_in_keystone     |
+------------------------+
| access_token           |
| assignment             |
| config_register        |
| consumer               |
| credential             |
| domain                 |
| endpoint               |
| endpoint_group         |
| federated_user         |
| federation_protocol    |
| group                  |
| id_mapping             |
| identity_provider      |
| idp_remote_ids         |
| implied_role           |
| local_user             |
| mapping                |
| migrate_version        |
| password               |
| policy                 |
| policy_association     |
| project                |
| project_endpoint       |
| project_endpoint_group |
| region                 |
| request_token          |
| revocation_event       |
| role                   |
| sensitive_config       |
| service                |
| service_provider       |
| token                  |
| trust                  |
| trust_role             |
| user                   |
| user_group_membership  |
| whitelisted_config     |
+------------------------+
37 rows in set (0.00 sec)

注意:执行此指令之后,忽略所有的deprecation messages。但是如果一直卡在这一步的话,我建议从新查看一下keystone.conf配置文件是否能够成功连接到数据库。

Step4.Initialize Fernet keys:
前文有过描述:Fernet tokens需要symmetric encryption keys,而这个keys就是使用keystone-manage fernet_setup来创建。

keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone

Configure the Apache HTTP server

Step1.Edit the /etc/httpd/conf/httpd.conf file and configure the ServerName option to reference the controller node:
vim /etc/httpd/conf/httpd.conf

#指定Apache HTTP Server的hostname
ServerName controller.jmilk.com

Step2.Create the /etc/httpd/conf.d/wsgi-keystone.conf file with the following content:
开启两个监听端口,并配置两个Virtualhost-Port虚拟主机。
vim /etc/httpd/conf.d/wsgi-keystone.conf

Listen 5000
Listen 35357

<VirtualHost *:5000>
    WSGIDaemonProcess keystone-public processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
    WSGIProcessGroup keystone-public
    WSGIScriptAlias / /usr/bin/keystone-wsgi-public
    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On
    ErrorLogFormat "%{cu}t %M"
    ErrorLog /var/log/httpd/keystone-error.log
    CustomLog /var/log/httpd/keystone-access.log combined

    <Directory /usr/bin>
        Require all granted
    </Directory>
</VirtualHost>

<VirtualHost *:35357>
    WSGIDaemonProcess keystone-admin processes=5 threads=1 user=keystone group=keystone display-name=%{GROUP}
    WSGIProcessGroup keystone-admin
    WSGIScriptAlias / /usr/bin/keystone-wsgi-admin
    WSGIApplicationGroup %{GLOBAL}
    WSGIPassAuthorization On
    ErrorLogFormat "%{cu}t %M"
    ErrorLog /var/log/httpd/keystone-error.log
    CustomLog /var/log/httpd/keystone-access.log combined

    <Directory /usr/bin>
        Require all granted
    </Directory>
</VirtualHost>

Step3.Start the Apache HTTP service and configure it to start when the system boots:

systemctl start httpd.service
systemctl enable httpd.service

到此为止,Keystone的安装已经完成了

Create the service entity and API endpoints

The Identity service provides a catalog of services and their locations. Each service that you add to your OpenStack environment requires a service entity and several API endpoints in the catalog.
认证服务提供了一个服务目录,需要为每一个加入到Openstack环境中的openstack service的service entity和若干个API endpoints添加到该服务目录中。

Prerequisites 先决条件

By default, the Identity service database contains no information to support conventional authentication and catalog services. You must use a temporary authentication token that you created in the section called Install and configure to initialize the service entity and API endpoint for the Identity service.
默认的,新建的认证服务数据库并没有包含任何支持authentication catalog services的信息。你必须使用在上文中创建的临时的authentication token——admin_token去初始化service entityAPI endpoint

Step1.创建临时authentication token文件
vim ~/auth_token

#1. Configure the authentication token(OS_TOKEN = keystone.conf中的参数项admin_token的值)
export OS_TOKEN=c44048d3212d3f977643 

#2. Configure the endpoint URL(使用35357号Port)
export OS_URL=http://controller.jmilk.com:35357/v3

#3. Configure the Identity API version
export OS_IDENTITY_API_VERSION=3

加载auth_token文件的环境变量

source ~/auth_token

Create the service entity and API endpoints

Step1.Create the service entity服务实体 for the Identity service:
The Identity service manages a catalog of services in your OpenStack environment. Services use this catalog to determine the other services available in your environment.
认证服务在Openstack中管理着一个服务目录,Openstack services是通过服务目录来定位其他的service。

[root@controller Desktop]# openstack service create --name keystone --description "OpenStack Identity" identity
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description | OpenStack Identity               |
| enabled     | True                             |
| id          | c89a25e54e5b4ca3b277b15ec0d75853 |
| name        | keystone                         |
| type        | identity                         |
+-------------+----------------------------------+

ERROR: An unexpected error prevented the server from fulfilling your request. (HTTP 500) (Request-ID: req-7e447b64-0ab1-4add-b0f9-ccb29de79156)
这是一个非常常见的错误,尤其对于入门Openstack的小伙伴而言,很多人就卡在这个ERROR上。这里给出一些解决的方案:
1. 一定要检查Keystone的表是否成功创建
2. 确保环境变量正确,尤其是OS_TOKENadmin_token的值是一致的,建议使用Copy,因为常见参数值后面带有空格,导致不一致的情况。
3. 确保Hostname和IP能够成功解析
4. 确保Port:35357已经开启
5. 确保HTTP服务正常运行
6. 查看openstack-keystone服务是否打开,如果是M版本就无所谓了
7. 实在不行,建议重启主机试试(放大招了)

Step2.Create the Identity service API endpoints:
The Identity service manages a catalog of API endpoints associated with the services in your OpenStack environment. Services use this catalog to determine how to communicate with other services in your environment.OpenStack uses three API endpoint variants for each service: admin, internal, and public.

认证服务还管理着一个服务相关的API endpoints目录,Services使用endpoints目录确定怎么与其他Services通信。每一个Openstack service提供了三种形式的API endpoint:admin管理, internal内部, and public外部.

[root@controller Desktop]# openstack endpoint create --region RegionOne identity public http://controller.jmilk.com:5000/v3
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | 670ccbe782ba4e788c681f532d540177 |
| interface    | public                           |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | c89a25e54e5b4ca3b277b15ec0d75853 |
| service_name | keystone                         |
| service_type | identity                         |
| url          | http://192.168.1.5:5000/v3       |
+--------------+----------------------------------+

[root@controller Desktop]# openstack endpoint create --region RegionOne identity internal http://controller.jmilk.com:5000/v3
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | c1d4504fc49741f4968d0c28ee66cbbc |
| interface    | internal                         |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | c89a25e54e5b4ca3b277b15ec0d75853 |
| service_name | keystone                         |
| service_type | identity                         |
| url          | http://192.168.1.5:5000/v3       |
+--------------+----------------------------------+

[root@controller Desktop]# openstack endpoint create --region RegionOne identity admin http://controller.jmilk.com:35357/v3
+--------------+----------------------------------+
| Field        | Value                            |
+--------------+----------------------------------+
| enabled      | True                             |
| id           | b0a761a6365941d2a5db215c36883b4f |
| interface    | admin                            |
| region       | RegionOne                        |
| region_id    | RegionOne                        |
| service_id   | c89a25e54e5b4ca3b277b15ec0d75853 |
| service_name | keystone                         |
| service_type | identity                         |
| url          | http://192.168.1.5:35357/v3      |
+--------------+----------------------------------+
相关实践学习
每个IT人都想学的“Web应用上云经典架构”实战
本实验从Web应用上云这个最基本的、最普遍的需求出发,帮助IT从业者们通过“阿里云Web应用上云解决方案”,了解一个企业级Web应用上云的常见架构,了解如何构建一个高可用、可扩展的企业级应用架构。
MySQL数据库入门学习
本课程通过最流行的开源数据库MySQL带你了解数据库的世界。 &nbsp; 相关的阿里云产品:云数据库RDS MySQL 版 阿里云关系型数据库RDS(Relational Database Service)是一种稳定可靠、可弹性伸缩的在线数据库服务,提供容灾、备份、恢复、迁移等方面的全套解决方案,彻底解决数据库运维的烦恼。 了解产品详情:&nbsp;https://www.aliyun.com/product/rds/mysql&nbsp;
相关文章
|
5月前
|
数据采集 机器学习/深度学习 搜索推荐
利用通义大模型构建个性化推荐系统——从数据预处理到实时API部署
本文详细介绍了基于通义大模型构建个性化推荐系统的全流程,涵盖数据预处理、模型微调、实时部署及效果优化。通过采用Qwen-72B结合LoRA技术,实现电商场景下CTR提升58%,GMV增长12.7%。文章分析了特征工程、多任务学习和性能调优的关键步骤,并探讨内存优化与蒸馏实践。最后总结了大模型在推荐系统中的适用场景与局限性,提出未来向MoE架构和因果推断方向演进的建议。
923 11
|
1月前
|
存储 监控 安全
132_API部署:FastAPI与现代安全架构深度解析与LLM服务化最佳实践
在大语言模型(LLM)部署的最后一公里,API接口的设计与安全性直接决定了模型服务的可用性、稳定性与用户信任度。随着2025年LLM应用的爆炸式增长,如何构建高性能、高安全性的REST API成为开发者面临的核心挑战。FastAPI作为Python生态中最受青睐的Web框架之一,凭借其卓越的性能、强大的类型安全支持和完善的文档生成能力,已成为LLM服务化部署的首选方案。
|
5月前
|
缓存 自然语言处理 监控
基于通义大模型的智能客服系统构建实战:从模型微调到API部署
本文详细解析了基于通义大模型的智能客服系统构建全流程,涵盖数据准备、模型微调、性能优化及API部署等关键环节。通过实战案例与代码演示,展示了如何针对客服场景优化训练数据、高效微调大模型、解决部署中的延迟与并发问题,以及构建完整的API服务与监控体系。文章还探讨了性能优化进阶技术,如模型量化压缩和缓存策略,并提供了安全与合规实践建议。最终总结显示,微调后模型意图识别准确率提升14.3%,QPS从12.3提升至86.7,延迟降低74%。
1757 15
|
11月前
|
存储 人工智能 API
AgentScope:阿里开源多智能体低代码开发平台,支持一键导出源码、多种模型API和本地模型部署
AgentScope是阿里巴巴集团开源的多智能体开发平台,旨在帮助开发者轻松构建和部署多智能体应用。该平台提供分布式支持,内置多种模型API和本地模型部署选项,支持多模态数据处理。
5826 77
AgentScope:阿里开源多智能体低代码开发平台,支持一键导出源码、多种模型API和本地模型部署
|
8月前
|
人工智能 自然语言处理 API
零门槛,即刻拥有DeepSeek-R1满血版——调用API及部署各尺寸模型
本文介绍了如何利用阿里云技术快速部署和使用DeepSeek系列模型,涵盖满血版API调用和云端部署两种方案。DeepSeek在数学、代码和自然语言处理等复杂任务中表现出色,支持私有化部署和企业级加密,确保数据安全。通过详细的步骤和代码示例,帮助开发者轻松上手,提升工作效率和模型性能。解决方案链接:[阿里云DeepSeek方案](https://www.aliyun.com/solution/tech-solution/deepseek-r1-for-platforms?utm_content=g_1000401616)。
零门槛,即刻拥有DeepSeek-R1满血版——调用API及部署各尺寸模型
|
消息中间件 运维 Serverless
函数计算产品使用问题之如何部署Stable Diffusion Serverless API
函数计算产品作为一种事件驱动的全托管计算服务,让用户能够专注于业务逻辑的编写,而无需关心底层服务器的管理与运维。你可以有效地利用函数计算产品来支撑各类应用场景,从简单的数据处理到复杂的业务逻辑,实现快速、高效、低成本的云上部署与运维。以下是一些关于使用函数计算产品的合集和要点,帮助你更好地理解和应用这一服务。
|
存储 API 网络架构
【Azure 存储服务】调用REST API获取Stroage Account Table中所有的Entity计数 -- Count
【Azure 存储服务】调用REST API获取Stroage Account Table中所有的Entity计数 -- Count
153 1
|
9月前
|
Cloud Native 安全 Serverless
云原生应用实战:基于阿里云Serverless的API服务开发与部署
随着云计算的发展,Serverless架构日益流行。阿里云函数计算(Function Compute)作为Serverless服务,让开发者无需管理服务器即可运行代码,按需付费,简化开发运维流程。本文从零开始,介绍如何使用阿里云函数计算开发简单的API服务,并探讨其核心优势与最佳实践。通过Python示例,演示创建、部署及优化API的过程,涵盖环境准备、代码实现、性能优化和安全管理等内容,帮助读者快速上手Serverless开发。
|
8月前
|
人工智能 测试技术 API
Ollama本地模型部署+API接口调试超详细指南
本文介绍了如何使用Ollama工具下载并部署AI大模型(如DeepSeek-R1、Llama 3.2等)。首先,访问Ollama的官方GitHub页面下载适合系统的版本并安装。接着,在终端输入`ollama`命令验证安装是否成功。然后,通过命令如`ollama run Llama3.2`下载所需的AI模型。下载完成后,可以在控制台与AI模型进行对话,或通过快捷键`control+d`结束会话。为了更方便地与AI互动,可以安装GUI或Web界面。此外,Ollama还提供了API接口,默认支持API调用,用户可以通过Apifox等工具调试这些API。
|
监控 安全 API
Docker + .NET API:简化部署和扩展
Docker + .NET API:简化部署和扩展
159 1