openstack安装--keystone

本文详细介绍了OpenStack中Keystone组件的安装与配置过程,包括数据库配置、memcached安装、Apache配置、服务实体及API端点创建等步骤。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

安装在controller节点
一、数据库
1、要求controller和compute节点的数据库能互相访问
grant all on *.* to root@'%' identified by "mima" WITH GRANT OPTION;         
flush privileges;

2、 mysql -u root -p
CREATE DATABASE keystone;
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' \
IDENTIFIED BY 'KEYSTONE_DBPASS';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' \
IDENTIFIED BY 'KEYSTONE_DBPASS';

3、生成一个随机的字符串
openssl rand -hex 10
假设为aaaaa

二、
1、安装memcached
yum install openstack-keystone httpd mod_wsgi memcached python-memcached
systemctl enable memcached.service
systemctl start memcached.service

2、Edit the /etc/keystone/keystone.conf file and complete the following actions:
[DEFAULT]
admin_token = ADMIN_TOKEN(aaaaa)
verbose = True
[database]
connection = mysql://keystone:KEYSTONE_DBPASS@controller/keystone
[memcache]
servers = localhost:11211
[token]
provider = uuid
driver = memcache
[revoke]
driver = sql

同步keystone数据库
su -s /bin/sh -c "keystone-manage db_sync" keystone
注意:如果报错No handlers could be found for logger "oslo_config.cfg"
解决办法:去掉verbose = True这行

3、配置Apache
Edit the /etc/httpd/conf/httpd.conf file and configure the ServerName option to reference the controller node:

ServerName controller

Create the /etc/httpd/conf.d/wsgi-keystone.conf file with the following content:
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
<IfVersion >= 2.4>
ErrorLogFormat "%{cu}t %M"
</IfVersion>
ErrorLog /var/log/httpd/keystone-error.log
CustomLog /var/log/httpd/keystone-access.log combined

<Directory /usr/bin>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
</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
<IfVersion >= 2.4>
ErrorLogFormat "%{cu}t %M"
</IfVersion>
ErrorLog /var/log/httpd/keystone-error.log
CustomLog /var/log/httpd/keystone-access.log combined

<Directory /usr/bin>
<IfVersion >= 2.4>
Require all granted
</IfVersion>
<IfVersion < 2.4>
Order allow,deny
Allow from all
</IfVersion>
</Directory>
</VirtualHost>


配置之后启动http服务
systemctl enable httpd.service
systemctl start httpd.service


三、
1.设置环境变量
export OS_TOKEN=ADMIN_TOKEN(aaaaa)
export OS_URL=http://controller:35357/v3
export OS_IDENTITY_API_VERSION=3


2.Create the service entity and API endpoints

openstack service create  --name keystone --description "OpenStack Identity" identity

报错:Unable to establish connection to http://controller:35357/v3/services
检查35357端口是否已经被监听,如果没有,就检查配置文件是否写错

3.创建endpoint
Create the Identity service API endpoints:
openstack endpoint create --region RegionOne identity public http://controller:5000/v2.0
openstack endpoint create --region RegionOne identity internal http://controller:5000/v2.0
openstack endpoint create --region RegionOne identity admin http://controller:35357/v2.0

四、创建project、user、role并关联
1.admin
openstack project create --domain default \
--description "Admin Project" admin
openstack user create --domain default \
--password-prompt admin
User Password:
Repeat User Password:
openstack role create admin
openstack role add --project admin --user admin admin


2.demo
openstack project create --domain default \
--description "Service Project" service
openstack project create --domain default \
--description "Demo Project" demo
openstack user create --domain default \
--password-prompt demo
User Password:
Repeat User Password:
openstack role create user
openstack role add --project demo --user demo user


五、
1、For security reasons, disable the temporary authentication token mechanism:
Edit the /usr/share/keystone/keystone-dist-paste.ini file and remove admin_token_auth from the [pipeline:public_api], [pipeline:admin_api], and [pipeline:api_v3] sections.
2、
unset OS_TOKEN OS_URL

3、As the admin user, request an authentication token:
 openstack --os-auth-url http://controller:35357/v3 \
--os-project-domain-id default --os-user-domain-id default \
--os-project-name admin --os-username admin --os-auth-type password \
token issue
Password:

用这一长串访问keystone时,不能有相关的环境变量,所以要unset
4、As the demo user, request an authentication token:
openstack --os-auth-url http://controller:5000/v3 \
--os-project-domain-id default --os-user-domain-id default \
--os-project-name demo --os-username demo --os-auth-type password \
token issue
Password:


六、
1.Creating the scripts
vim admin-openrc.sh

export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=admin
export OS_TENANT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=ADMIN_PASS //注意替换
export OS_AUTH_URL=http://controller:35357/v3
export OS_IDENTITY_API_VERSION=3


vim demo-openrc.sh
export OS_PROJECT_DOMAIN_ID=default
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_NAME=demo
export OS_TENANT_NAME=demo
export OS_USERNAME=demo
export OS_PASSWORD=DEMO_PASS //注意替换
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3


2.Using the scripts
source admin-openrc.sh


Request an authentication token:
 openstack token issue
<think>嗯,用户遇到了关于OpenStack Keystone服务的问题,执行systemctl status和start命令时显示服务未找到。我需要仔细分析可能的原因,并提供解决方案。 首先,用户可能没有安装Keystone服务。在基于RHEL的系统上,软件包名称通常是openstack-keystone,使用yum或dnf安装。需要检查是否已正确安装。 其次,软件包名称可能因发行版不同而有所变化。例如,Ubuntu上的包名可能不同,但用户使用的是CentOS/RHEL,所以应确认正确的包名和仓库是否启用。 另外,用户可能安装Keystone没有启用或启动服务。需要提醒用户使用systemctl enable和start命令,并确认安装后是否进行了必要的配置,比如数据库设置、Fernet密钥生成和Apache配置,因为现代OpenStack版本可能将Keystone作为Apache模块运行,而不是独立的服务。 此外,如果用户从源代码安装,服务文件可能不在标准位置,需要手动创建。或者,用户可能误删了服务文件,需要重新安装软件包。 最后,建议用户检查安装步骤,确认是否遗漏了某些环节,并查看日志文件以获取更多信息。需要分步骤引导用户逐一排查,确保问题得到解决。</think>当遇到`openstack-keystone.service`服务未找到的情况时,通常由以下原因导致: --- ### **1. 未安装 Keystone 服务** #### 现象特征 - 执行 `systemctl status/start` 命令时提示 **"Unit not found"** - 系统中缺少 `/usr/lib/systemd/system/openstack-keystone.service` 文件 #### 解决方法 **步骤 1:确认软件包是否安装** ```bash rpm -qa | grep openstack-keystone ``` -没有输出结果,说明未安装 **步骤 2:安装 Keystone 软件包** ```bash yum install openstack-keystone httpd mod_wsgi -y ``` - 注意:现代 OpenStack 版本(如 Queens+)通常将 Keystone 集成到 Apache 中,需同时安装 `httpd` 和 `mod_wsgi` --- ### **2. 服务名称不匹配** #### 现象特征 - 不同发行版或安装方式可能导致服务名称差异 - 例如:部分环境使用 `keystone.service` 而非 `openstack-keystone.service` #### 解决方法 **尝试通用服务名查询** ```bash systemctl list-unit-files | grep -i keystone ``` --- ### **3. 服务未启用或未配置** #### 现象特征 -安装软件包但未完成初始化配置 - 未生成 systemd 服务文件 #### 解决方法 **步骤 1:检查配置文件完整性** ```bash ls /etc/keystone/keystone.conf ``` **步骤 2:执行数据库初始化**(需先配置数据库连接) ```bash su -s /bin/sh -c "keystone-manage db_sync" keystone ``` **步骤 3:生成 Fernet 密钥** ```bash keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone keystone-manage credential_setup --keystone-user keystone --keystone-group keystone ``` **步骤 4:启动 Apache 服务**(替代传统 systemd 服务) ```bash systemctl enable httpd --now ``` --- ### **4. 软件源问题** #### 现象特征 - 使用非标准软件源导致包名不一致 - 例如:从源码安装时未生成服务文件 #### 解决方法 **验证软件源配置** ```bash yum repolist | grep openstack ``` - 确保已启用正确的 OpenStack 仓库(如 `centos-openstack-zed`) --- ### **5. 服务文件被误删除** #### 现象特征 - 其他服务管理正常,仅 Keystone 异常 - `/usr/lib/systemd/system/` 目录下无相关服务文件 #### 解决方法 **重新安装软件包** ```bash yum reinstall openstack-keystone -y ``` --- ### **关键日志检查位置** | 日志路径 | 作用 | |---------|------| | `/var/log/httpd/keystone_*.log` | Apache 整合后的 Keystone 日志 | | `/var/log/keystone/keystone.log` | 传统独立服务日志(若存在) | | `/var/log/messages` | 系统级服务启动错误 | --- ### **总结处理流程** ```bash # 1. 确认安装 yum install openstack-keystone httpd mod_wsgi -y # 2. 完成基础配置 keystone-manage db_sync keystone-manage fernet_setup ... keystone-manage bootstrap ... # 3. 启动 Apache 服务 systemctl enable httpd --now # 4. 验证服务状态 curl -s http://controller:5000/v3/ | python -m json.tool ```
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值