#只在controller上执行
#1.安装和配置
#先决条件
#(1)用数据库连接客户端以 root 用户连接到数据库服务器
mysql
#(2)创建 keystone 数据库:
CREATE DATABASE keystone;
文章来源:https://www.toymoban.com/news/detail-458285.html
#(3)对``keystone``数据库授予恰当的权限
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' \
IDENTIFIED BY 'KEYSTONE_DBPASS';
GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' \
IDENTIFIED BY 'KEYSTONE_DBPASS';
#(4)验证
show databases; #可以看到keystone库已创建
show databases; #可以看到keystone库已创建
#(5)退出
exit
#2.安全并配置组件
#(1)安装包
yum install openstack-keystone httpd mod_wsgi -y
#(2)编辑文件 /etc/keystone/keystone.conf 并完成如下动作
(直接复制打到里面,不用打开文件夹)
openstack-config --set /etc/keystone/keystone.conf DEFAULT admin_token 646db5835f01db8f9333
openstack-config --set /etc/keystone/keystone.conf database connection mysql+pymysql://keystone:KEYSTONE_DBPASS@controller/keystone
openstack-config --set /etc/keystone/keystone.conf token provider fernet
#(3)初始化身份认证服务的数据库:
su -s /bin/sh -c "keystone-manage db_sync" keystone
#(4)初始化Fernet key:
keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
#3.配置 Apache HTTP 服务器
#(1)编辑``/etc/httpd/conf/httpd.conf`` 文件,配置``ServerName`` 选项为控制节点:
sed -i 's/#ServerName www.example.com:80/ServerName controller/g' /etc/httpd/conf/httpd.conf
#(2)编辑/etc/httpd/conf.d/wsgi-keystone.conf
(直接复制粘贴)
echo '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
LimitRequestBody 114688
<IfVersion >= 2.4>
ErrorLogFormat "%{cu}t %M"
</IfVersion>
ErrorLog /var/log/httpd/keystone.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
LimitRequestBody 114688
<IfVersion >= 2.4>
ErrorLogFormat "%{cu}t %M"
</IfVersion>
ErrorLog /var/log/httpd/keystone.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>
Alias /identity /usr/bin/keystone-wsgi-public
<Location /identity>
SetHandler wsgi-script
Options +ExecCGI
WSGIProcessGroup keystone-public
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
</Location>
Alias /identity_admin /usr/bin/keystone-wsgi-admin
<Location /identity_admin>
SetHandler wsgi-script
Options +ExecCGI
WSGIProcessGroup keystone-admin
WSGIApplicationGroup %{GLOBAL}
WSGIPassAuthorization On
</Location>' >/etc/httpd/conf.d/wsgi-keystone.conf
#4.完成安装
#(1)启动 Apache HTTP 服务并配置其随系统启动:
systemctl enable httpd.service
systemctl restart httpd.service
#5.创建服务实体和API端点
#(1)配置初始登录信息:
export OS_TOKEN=646db5835f01db8f9333
export OS_URL=http://controller:35357/v3
export OS_IDENTITY_API_VERSION=3
#查看环境变量是否存在:
env | grep OS
#查看网络端口5000,35357是否启用
ss -ntl | grep -E "5000|35357"
#(2)创建服务实体和身份认证服务:
openstack service create \
--name keystone --description "OpenStack Identity" identity
#(3)创建认证服务的 API 端点:
openstack endpoint create --region RegionOne \
identity public http://controller:5000/v3
openstack endpoint create --region RegionOne \
identity internal http://controller:5000/v3
openstack endpoint create --region RegionOne \
identity admin http://controller:35357/v3
#6.创建域、项目、用户和角色
#(1)创建域``default``:
openstack domain create --description "Default Domain" default
#(2)创建 admin 项目:
openstack project create --domain default \
--description "Admin Project" admin
#(3)创建 admin 用户:
openstack user create --domain default \
--password ADMIN_PASS admin
#(4)创建 admin 角色:
openstack role create admin
#(5)添加``admin`` 角色到 admin 项目和用户上:
openstack role add --project admin --user admin admin
#(6)每个服务包含独有用户的service 项目。创建``service``项目:
openstack project create --domain default \
--description "Service Project" service
#(7)常规(非管理)任务应该使用无特权的项目和用户。作为例子,本指南创建 demo 项目和用户。
#创建 demo 项目
openstack project create --domain default \
--description "Demo Project" demo
#创建``demo`` 用户:(密码 123456)
openstack user create --domain default \
--password 123456 demo
#创建 user 角色:
openstack role create user
#授权
openstack role add --project demo --user demo user
#7.验证操作
#(1)撤销临时环境变量 OS_TOKEN 和 OS_URL
unset OS_TOKEN OS_URL
#(2)作为 admin 用户,请求认证令牌:
openstack --os-auth-url http://controller:35357/v3 \
--os-project-domain-name default --os-user-domain-name default \
--os-project-name admin --os-username admin --os-password ADMIN_PASS token issue
这个命令使用``admin``用户的密码。
#(3)作为``demo`` 用户,请求认证令牌:
openstack --os-auth-url http://controller:5000/v3 \
--os-project-domain-name default --os-user-domain-name default \
--os-project-name demo --os-username demo --os-password 123456 token issue
这个命令使用 demo 用户的密码。
验证通过!
#7.配置环境变量
echo 'export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_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
export OS_IMAGE_API_VERSION=2' >>/etc/keystone/admin-openrc
echo 'export OS_PROJECT_DOMAIN_NAME=default
export OS_USER_DOMAIN_NAME=default
export OS_PROJECT_NAME=demo
export OS_USERNAME=demo
export OS_PASSWORD=123456
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2' >>/etc/keystone/demo-openrc
. /etc/keystone/admin-openrc
试一下免密登录:
openstack token issue
#截图,创建快照文章来源地址https://www.toymoban.com/news/detail-458285.html
到了这里,关于云计算技术应用实训OpenStack认证服务的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!