云计算管理平台之OpenStack认证服务Keystone
一、keystone简介
keystone是openstack中的核心服务,它主要作用是实现用户认证和授权以及服务目录;所谓服务目录指所有可用服务的信息库,包含所有可用服务及其API endport路径;简单点讲就是存储各服务的API endport路径和各服务的其他信息;对于openstack的认证服务来讲,有几个核心的术语要了解下;
user:这里指使用openstack的用户,一个用户可以以关联多个tenant(租户)
tenant:租户,这里的租户指openstack上的项目project,或者一个组织;通常一个租户对应一个project或一个组织;
role:角色,这里的角色类似Linux用户里的用户组概念,拥有授权为一个用户为一个角色,那么这个用户就拥有这个角色所对应的权限;
token:令牌,用于认证和授权;这是另一种认证的方式;在openstack中各服务之间通过令牌来做认证的;
service:服务,这个和我们理解的服务一样,没有特别的不一样;
endport:服务端点,通常指服务访问入口;
上述这些术语对应的数据,通常会用一个数据库来存储,我们把这个数据库统称为driver,对于不同类型的数据我们可以选择不同的driver来存储;比如对于token我们可以选择存储到k/v键值存储系统中,也可以选择存储在memcached中或者mysql中;catalog我们可以选择存储在k/v键值存储系统中,也可选择存储到mysql中,也可以选择存储到一个模板中;identity我们可以存储k/v键值存储系统中,也可选择存储到mysql中或者pam中也可以;
提示:上图是一个用户在openstack上创建一个虚拟机内部验证的过程;首先用户要登入openstack上要把用户的用户名和密码发送给keystone进行验证,如果在keystone中验证通过后,keystone会给用户返回一个token,此时用户就可以拿着这个返回的token去计算节点请求nova服务,进行创建虚拟机请求,在nova服务接受到用户的请求后,nova它不能直接相信用户的token是否是keystone给的,它会把这个token发送给keystone进行验证,如果keystone验证通过,此时nova才会拿着这个token去请求glance进行虚拟机镜像请求,同样的glance也不相信nova拿到这个token,它会去找keystone验证,只有keystone通过后,glance才会把镜像发送给nova,nova拿到镜像启动虚拟机;启动虚拟机过程中nova还会拿着用户的token去请求neutron服务给虚拟机分配网络,同样neutron也是不相信nova的token,它也会去keystone上验证token,只有验证通过后才给nova创建的虚拟机分配网络;最后nova启动好虚拟以后在返回,告诉用户虚拟机启动成功;从上面的过程来看,几乎所有服务都会去keystone上验证用户的token,所以keystone服务会非常繁忙;
二、keystone服务安装、配置、测试
1、创建数据库
[root@node02 ~]# mysql
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 10.1.20-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)]> CREATE DATABASE keystone;
Query OK, 1 row affected (0.00 sec) MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database |
+--------------------+
| information_schema |
| keystone |
| mysql |
| performance_schema |
| test |
+--------------------+
5 rows in set (0.04 sec) MariaDB [(none)]>
2、创建keystone用户并授权允许从任何主机连接数据库
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'keystone123';
Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]> flush privileges;
Query OK, 0 rows affected (0.00 sec) MariaDB [(none)]>
验证:在node01上使用keystone用户连接数据库,看看是否能够正常连接?
[root@node01 ~]# mysql -ukeystone -pkeystone123 -hnode02
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 4
Server version: 10.1.20-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 |
| test |
+--------------------+
3 rows in set (0.00 sec) MariaDB [(none)]>
提示:能够从别的主机用keystone账号连接到mysql,并看到我们刚才创建的数据库,说明我们创建的keystone账号没有问题;
3、在控制节点安装openstack-keystone、httpd和mod_wsgi
[root@node01 ~]# yum install -y openstack-keystone httpd mod_wsgi
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
* base: mirrors.aliyun.com
* centos-qemu-ev: mirrors.aliyun.com
* extras: mirrors.aliyun.com
* updates: mirrors.aliyun.com
Resolving Dependencies
--> Running transaction check
---> Package httpd.x86_64 0:2.4.6-93.el7.centos will be installed
--> Processing Dependency: httpd-tools = 2.4.6-93.el7.centos for package: httpd-2.4.6-93.el7.centos.x86_64
--> Processing Dependency: /etc/mime.types for package: httpd-2.4.6-93.el7.centos.x86_64
--> Processing Dependency: libaprutil-1.so.0()(64bit) for package: httpd-2.4.6-93.el7.centos.x86_64
--> Processing Dependency: libapr-1.so.0()(64bit) for package: httpd-2.4.6-93.el7.centos.x86_64
---> Package mod_wsgi.x86_64 0:3.4-18.el7 will be installed
……省略部分内容……
Dependency Installed:
MySQL-python.x86_64 0:1.2.5-1.el7 apr.x86_64 0:1.4.8-5.el7
apr-util.x86_64 0:1.5.2-6.el7 httpd-tools.x86_64 0:2.4.6-93.el7.centos
mailcap.noarch 0:2.1.41-2.el7 python-aniso8601.noarch 0:0.82-3.el7
python-beaker.noarch 0:1.5.4-10.el7 python-editor.noarch 0:0.4-4.el7
python-jwcrypto.noarch 0:0.4.2-1.el7 python-keystone.noarch 1:14.2.0-1.el7
python-mako.noarch 0:0.8.1-2.el7 python-migrate.noarch 0:0.11.0-1.el7
python-oslo-cache-lang.noarch 0:1.30.4-1.el7 python-oslo-concurrency-lang.noarch 0:3.27.0-1.el7
python-oslo-db-lang.noarch 0:4.40.2-1.el7 python-oslo-middleware-lang.noarch 0:3.36.0-1.el7
python-oslo-policy-lang.noarch 0:1.38.1-1.el7 python-paste.noarch 0:1.7.5.1-9.20111221hg1498.el7
python-paste-deploy.noarch 0:1.5.2-6.el7 python-pycadf-common.noarch 0:2.8.0-1.el7
python-routes.noarch 0:2.4.1-1.el7 python-sqlparse.noarch 0:0.1.18-5.el7
python-tempita.noarch 0:0.5.1-8.el7 python2-alembic.noarch 0:0.9.7-1.el7
python2-amqp.noarch 0:2.4.0-1.el7 python2-bcrypt.x86_64 0:3.1.6-2.el7
python2-cachetools.noarch 0:2.1.0-1.el7 python2-click.noarch 0:6.7-8.el7
python2-defusedxml.noarch 0:0.5.0-2.el7 python2-eventlet.noarch 0:0.20.1-6.el7
python2-fasteners.noarch 0:0.14.1-6.el7 python2-flask.noarch 1:1.0.2-1.el7
python2-flask-restful.noarch 0:0.3.6-7.el7 python2-future.noarch 0:0.18.2-2.el7
python2-futurist.noarch 0:1.7.0-1.el7 python2-greenlet.x86_64 0:0.4.12-1.el7
python2-itsdangerous.noarch 0:0.24-14.el7 python2-jinja2.noarch 0:2.10-2.el7
python2-keystonemiddleware.noarch 0:5.2.2-1.el7 python2-kombu.noarch 1:4.2.2-1.el7
python2-ldap.x86_64 0:3.1.0-1.el7 python2-ldappool.noarch 0:2.3.1-1.el7
python2-markupsafe.x86_64 0:0.23-16.el7 python2-oauthlib.noarch 0:2.0.1-8.el7
python2-oslo-cache.noarch 0:1.30.4-1.el7 python2-oslo-concurrency.noarch 0:3.27.0-1.el7
python2-oslo-db.noarch 0:4.40.2-1.el7 python2-oslo-messaging.noarch 0:8.1.4-1.el7
python2-oslo-middleware.noarch 0:3.36.0-1.el7 python2-oslo-policy.noarch 0:1.38.1-1.el7
python2-oslo-service.noarch 0:1.31.8-1.el7 python2-osprofiler.noarch 0:2.3.1-1.el7
python2-passlib.noarch 0:1.7.1-1.el7 python2-pyasn1.noarch 0:0.3.7-6.el7
python2-pyasn1-modules.noarch 0:0.3.7-6.el7 python2-pycadf.noarch 0:2.8.0-1.el7
python2-pyngus.noarch 0:2.3.0-1.el7 python2-pysaml2.noarch 0:4.5.0-4.el7
python2-qpid-proton.x86_64 0:0.32.0-2.el7 python2-scrypt.x86_64 0:0.8.0-2.el7
python2-sqlalchemy.x86_64 0:1.2.7-1.el7 python2-statsd.noarch 0:3.2.1-5.el7
python2-tenacity.noarch 0:4.12.0-1.el7 python2-vine.noarch 0:1.2.0-1.el7
python2-webob.noarch 0:1.8.2-1.el7 python2-werkzeug.noarch 0:0.14.1-3.el7
qpid-proton-c.x86_64 0:0.32.0-2.el7 Complete!
[root@node01 ~]#
4、生成token
[root@node01 ~]# openssl rand -hex 10
752e7981c9f3bb1b1a91
[root@node01 ~]#
5、编辑keystone配置文件/etc/keystone/keystone.conf,在default配置段里添加admin_token,把我们生成的token配置上;
在database配置段配置连接数据库的地址;
提示:连接数据库前边的mysql+pymysql://这一段不用变,默认格式就是这个,双斜线后面的是keystone用户,冒号后面是对应keystone用户的密码;@后面是数据库服务器地址;斜线后面是指连接那个数据库;我这里是因为配置了主机名解析,所以数据库服务器我用主机名代替了;
在token配置段配置provider = fernet
keystone的最终配置
[root@node01 ~]# grep "^[a-Z\[]" /etc/keystone/keystone.conf
[DEFAULT]
admin_token = 752e7981c9f3bb1b1a91
[application_credential]
[assignment]
[auth]
[cache]
[catalog]
[cors]
[credential]
[database]
connection = mysql+pymysql://keystone:keystone123@node02/keystone
[domain_config]
[endpoint_filter]
[endpoint_policy]
[eventlet_server]
[federation]
[fernet_tokens]
[healthcheck]
[identity]
[identity_mapping]
[ldap]
[matchmaker_redis]
[memcache]
[oauth1]
[oslo_messaging_amqp]
[oslo_messaging_kafka]
[oslo_messaging_notifications]
[oslo_messaging_rabbit]
[oslo_messaging_zmq]
[oslo_middleware]
[oslo_policy]
[policy]
[profiler]
[resource]
[revoke]
[role]
[saml]
[security_compliance]
[shadow_users]
[signing]
[token]
provider = fernet
[tokenless_auth]
[trust]
[unified_limit]
[wsgi]
[root@node01 ~]#
提示:这个配置文件是ini风格的配置文件,里面有很多配置段,其实生效的就只有我们刚才配置的三段;
6、在控制节点初始化keystone数据库
[root@node01 ~]# su -s /bin/sh -c "keystone-manage db_sync" keystone
[root@node01 ~]#
提示:以上命令会通过我们刚才配置的连接数据库的地址,通过keystone连接到数据库中创建一堆表;
验证:在node02上验证,看看keystone库中是否多了很多表?
MariaDB [(none)]> use keystone
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A Database changed
MariaDB [keystone]> show tables;
+-----------------------------+
| Tables_in_keystone |
+-----------------------------+
| access_token |
| application_credential |
| application_credential_role |
| assignment |
| config_register |
| consumer |
| credential |
| endpoint |
| endpoint_group |
| federated_user |
| federation_protocol |
| group |
| id_mapping |
| identity_provider |
| idp_remote_ids |
| implied_role |
| limit |
| local_user |
| mapping |
| migrate_version |
| nonlocal_user |
| password |
| policy |
| policy_association |
| project |
| project_endpoint |
| project_endpoint_group |
| project_tag |
| region |
| registered_limit |
| request_token |
| revocation_event |
| role |
| sensitive_config |
| service |
| service_provider |
| system_assignment |
| token |
| trust |
| trust_role |
| user |
| user_group_membership |
| user_option |
| whitelisted_config |
+-----------------------------+
44 rows in set (0.00 sec) MariaDB [keystone]>
7、在控制节点上初始化Fernet密钥
[root@node01 ~]# keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
[root@node01 ~]# keystone-manage credential_setup --keystone-user keystone --keystone-group keystone
[root@node01 ~]#
提示:以上命令会在/etc/keystone/fernet-keys/目录下生成两个key文件;
验证:查看/etc/keystone/fernet-keys/目录下是否有两个key生成?
[root@node01 ~]# ll /etc/keystone/fernet-keys/
total 8
-rw------- 1 keystone keystone 44 Oct 28 19:23 0
-rw------- 1 keystone keystone 44 Oct 28 19:23 1
[root@node01 ~]#
8、配置httpd代理keystone
提示:以上主要修改了httpd的servername监听地址,其实这里不修改也行,不影响;重要的是下面的配置;
把/usr/share/keystone/wsgi-keystone.conf连接至/etc/httpd/conf.d/下
[root@node01 ~]# ln -sv /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/
‘/etc/httpd/conf.d/wsgi-keystone.conf’ -> ‘/usr/share/keystone/wsgi-keystone.conf’
[root@node01 ~]# ll /etc/httpd/conf.d/
total 16
-rw-r--r-- 1 root root 2926 Apr 2 2020 autoindex.conf
-rw-r--r-- 1 root root 366 Apr 2 2020 README
-rw-r--r-- 1 root root 1252 Nov 27 2019 userdir.conf
-rw-r--r-- 1 root root 824 Nov 27 2019 welcome.conf
lrwxrwxrwx 1 root root 38 Oct 28 19:30 wsgi-keystone.conf -> /usr/share/keystone/wsgi-keystone.conf
[root@node01 ~]#
提示:以上操作就是把httpd代理keystone的配置导入到httpd中,默认安装keystone以后就会有一个这样的配置文件;我们只需要把这个配置文件软连接到httpd的配置目录下即可;
启动httpd,并设置为开机启动
[root@node01 ~]# systemctl start httpd
[root@node01 ~]# systemctl enable httpd
Created symlink from /etc/systemd/system/multi-user.target.wants/httpd.service to /usr/lib/systemd/system/httpd.service.
[root@node01 ~]# ss -tnl
State Recv-Q Send-Q Local Address:Port Peer Address:Port
LISTEN 0 128 *:22 *:*
LISTEN 0 100 127.0.0.1:25 *:*
LISTEN 0 128 :::80 :::*
LISTEN 0 128 :::22 :::*
LISTEN 0 100 ::1:25 :::*
LISTEN 0 128 :::5000 :::*
[root@node01 ~]#
提示:如果能够看到5000端口正常监听,说明我们导入的配置没有问题;
9、通过OS_TOKEN环境变量导出admin的token,使用OS_URL环境变量导出控制节点api接口地址,使用OS_IDENTITY_API_VERSION环境变量导出api的版本号
[root@node01 ~]# export OS_TOKEN=752e7981c9f3bb1b1a91
[root@node01 ~]# export OS_URL=http://node01:5000/v3
[root@node01 ~]# export OS_IDENTITY_API_VERSION=3
提示:这里的admin_token就是我们刚才在配置文件中配置的token;因为最开始我们只有手动生成一个token进行验证;
10、在导出以上三个环境变量的终端上创建域、用户、项目、角色、服务;
创建default域
[root@node01 ~]# openstack domain create --description "Default Domain" default
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Default Domain |
| enabled | True |
| id | 47c0915c914c49bb8670703e4315a80f |
| name | default |
| tags | [] |
+-------------+----------------------------------+
[root@node01 ~]#
创建一个admin的项目 并把域指向default
[root@node01 ~]# openstack project create --domain default --description "Admin Project" admin
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Admin Project |
| domain_id | 47c0915c914c49bb8670703e4315a80f |
| enabled | True |
| id | b4e56eeb160948c581e98d685133d19a |
| is_domain | False |
| name | admin |
| parent_id | 47c0915c914c49bb8670703e4315a80f |
| tags | [] |
+-------------+----------------------------------+
[root@node01 ~]#
创建admin用户并设置密码为admin
[root@node01 ~]# openstack user create --domain default --password-prompt admin
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | 47c0915c914c49bb8670703e4315a80f |
| enabled | True |
| id | a105f256dc9f42438212e9d96d46b60d |
| name | admin |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[root@node01 ~]#
创建admin角色
[root@node01 ~]# openstack role create admin
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | None |
| id | 7f1f7aa119034c2fbd15b46b90632d18 |
| name | admin |
+-----------+----------------------------------+
[root@node01 ~]#
给admin用户授权,将admin用户授予admin项目的admin角色
[root@node01 ~]# openstack role add --project admin --user admin admin
[root@node01 ~]#
创建一个用于测试的demo项目
[root@node01 ~]# openstack project create --domain default --description "Demo Project" demo
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Demo Project |
| domain_id | 47c0915c914c49bb8670703e4315a80f |
| enabled | True |
| id | 1a918887f38a42c28f9d0d3774f34b16 |
| is_domain | False |
| name | demo |
| parent_id | 47c0915c914c49bb8670703e4315a80f |
| tags | [] |
+-------------+----------------------------------+
[root@node01 ~]#
创建demo用户并设置密码为demo
[root@node01 ~]# openstack user create --domain default --password-prompt demo
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | 47c0915c914c49bb8670703e4315a80f |
| enabled | True |
| id | 5453d68782a34429a7dab7da9c51f0d9 |
| name | demo |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
[root@node01 ~]#
创建一个user角色
[root@node01 ~]# openstack role create user
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | None |
| id | ee2f38096e42409eb47ae67a8c289279 |
| name | user |
+-----------+----------------------------------+
[root@node01 ~]#
把demo用户添加到demo项目,然后赋予user角色权限
[root@node01 ~]# openstack role add --project demo --user demo user
[root@node01 ~]#
验证:查看现有的用户、项目、角色、域是否是我们创建的
[root@node01 ~]# openstack user list
+----------------------------------+-------+
| ID | Name |
+----------------------------------+-------+
| 5453d68782a34429a7dab7da9c51f0d9 | demo |
| a105f256dc9f42438212e9d96d46b60d | admin |
+----------------------------------+-------+
[root@node01 ~]# openstack project list
+----------------------------------+-------+
| ID | Name |
+----------------------------------+-------+
| 1a918887f38a42c28f9d0d3774f34b16 | demo |
| b4e56eeb160948c581e98d685133d19a | admin |
+----------------------------------+-------+
[root@node01 ~]# openstack role list
+----------------------------------+-------+
| ID | Name |
+----------------------------------+-------+
| 7f1f7aa119034c2fbd15b46b90632d18 | admin |
| ee2f38096e42409eb47ae67a8c289279 | user |
+----------------------------------+-------+
[root@node01 ~]# openstack domain list
+----------------------------------+---------+---------+----------------+
| ID | Name | Enabled | Description |
+----------------------------------+---------+---------+----------------+
| 47c0915c914c49bb8670703e4315a80f | default | True | Default Domain |
+----------------------------------+---------+---------+----------------+
[root@node01 ~]#
提示:可以看到当前控制节点上有两个用户,两个项目,两个角色,分别是admin和demo;一个default域;这都是我们刚才创建的;
创建一个service项目,各服务之间与keystone进行访问和认证,service用于给服务创建用户;
[root@node01 ~]# openstack project create --domain default --description "Service Project" service
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Service Project |
| domain_id | 47c0915c914c49bb8670703e4315a80f |
| enabled | True |
| id | 9c9d6f24fc23464a810ef97ce199bffa |
| is_domain | False |
| name | service |
| parent_id | 47c0915c914c49bb8670703e4315a80f |
| tags | [] |
+-------------+----------------------------------+
[root@node01 ~]#
创建一个keystone认证服务
[root@node01 ~]# openstack service create --name keystone --description "OpenStack Identity" identity
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Identity |
| enabled | True |
| id | a32cffed26924a87b21b4e86e00c63b4 |
| name | keystone |
| type | identity |
+-------------+----------------------------------+
[root@node01 ~]#
查看当前服务列表
[root@node01 ~]# openstack service list
+----------------------------------+----------+----------+
| ID | Name | Type |
+----------------------------------+----------+----------+
| a32cffed26924a87b21b4e86e00c63b4 | keystone | identity |
+----------------------------------+----------+----------+
[root@node01 ~]#
11、创建endpoint(注册服务)
创建公共端
[root@node01 ~]# openstack endpoint create --region RegionOne identity public http://controller:5000/v3
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 5293ad18db674ea1b01d8f401cb2cf14 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | a32cffed26924a87b21b4e86e00c63b4 |
| service_name | keystone |
| service_type | identity |
| url | http://controller:5000/v3 |
+--------------+----------------------------------+
[root@node01 ~]#
创建私有端
[root@node01 ~]# openstack endpoint create --region RegionOne identity internal http://controller:5000/v3
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 6593f8d808094b01a6311828f2ef72bd |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | a32cffed26924a87b21b4e86e00c63b4 |
| service_name | keystone |
| service_type | identity |
| url | http://controller:5000/v3 |
+--------------+----------------------------------+
[root@node01 ~]#
创建管理端
[root@node01 ~]# openstack endpoint create --region RegionOne identity admin http://controller:5000/v3
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 3bd05493999b462eb4b4af8d5e5c1fa9 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | a32cffed26924a87b21b4e86e00c63b4 |
| service_name | keystone |
| service_type | identity |
| url | http://controller:5000/v3 |
+--------------+----------------------------------+
[root@node01 ~]#
验证:看看endport 列表是否都已经有我们刚才创建的三个端点?
[root@node01 ~]# openstack endpoint list
+----------------------------------+-----------+--------------+--------------+---------+-----------+---------------------------+
| ID | Region | Service Name | Service Type | Enabled | Interface | URL |
+----------------------------------+-----------+--------------+--------------+---------+-----------+---------------------------+
| 3bd05493999b462eb4b4af8d5e5c1fa9 | RegionOne | keystone | identity | True | admin | http://controller:5000/v3 |
| 5293ad18db674ea1b01d8f401cb2cf14 | RegionOne | keystone | identity | True | public | http://controller:5000/v3 |
| 6593f8d808094b01a6311828f2ef72bd | RegionOne | keystone | identity | True | internal | http://controller:5000/v3 |
+----------------------------------+-----------+--------------+--------------+---------+-----------+---------------------------+
[root@node01 ~]#
提示:如果创建错误或者多创建了,就需要全部删除,重新注册;
到此keystone服务就配置完了;接下来测试keystone是否可以用来做认证服务
验证:重新打开一个终端窗口,导出OS_IDENTITY_API_VERSION环境变量,使用命令的方式验证admin用户密码是admin
[root@node01 ~]# echo $OS_IDENTITY_API_VERSION [root@node01 ~]# export OS_IDENTITY_API_VERSION=3
[root@node01 ~]# echo $OS_IDENTITY_API_VERSION
3
[root@node01 ~]# openstack --os-auth-url http://node01:5000/v3 --os-project-domain-name default --os-user-domain-name default --os-project-name admin --os-username admin token issue
Password:
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| expires | 2020-10-28T13:16:54+0000 |
| id | gAAAAABfmWE2udKuo4ambgxh3RsrzoDwrA8IHa1dx5gYk_sZoU5HmZUM9qHTguwMasYGzRIno0LawlZDbB4i3IJold3sZdAlEZGwiNuPtYJMgP5nikDUR8YrXNPNQNDMjCchDMMN6bWhZ26pQXVEZ0VXcN5v5xOj_bx7nskJ8bnvKWFiRf4ckPQ |
| project_id | b4e56eeb160948c581e98d685133d19a |
| user_id | a105f256dc9f42438212e9d96d46b60d |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[root@node01 ~]#
提示:输入正确的密码会返回一个表,记录的有过期时长,id,和项目id和用户id;如果输入密码错误则不会返回这些内容,其实这些内容主要用来描述返回给用户token属性,我们可以理解它就是返回了这样一个token给我们;
[root@node01 ~]# openstack --os-auth-url http://node01:5000/v3 --os-project-domain-name default --os-user-domain-name default --os-project-name admin --os-username admin token issue
Password:
The request you have made requires authentication. (HTTP 401) (Request-ID: req-79d8afbe-56dc-47f9-ab4e-8065a295923e)
[root@node01 ~]#
提示:输入错误的密码它给我们返回了响应码为401,表示验证未通过;
创建admin用户环境变量脚本
[root@node01 ~]# cat admin.sh
#!/bin/bash
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
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
[root@node01 ~]# chmod a+x admin.sh
[root@node01 ~]#
创建demo用户环境变量脚本
[root@node01 ~]# cat demo.sh
#!/bin/bash
export OS_PROJECT_DOMAIN_NAME=Default
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_NAME=demo
export OS_USERNAME=demo
export OS_PASSWORD=demo
export OS_AUTH_URL=http://controller:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
[root@node01 ~]# chmod a+x demo.sh
[root@node01 ~]#
提示:有了上面两个脚本以后,我们就实现要使用那个用户测试,直接把对应的用户环境变量导出即可;
验证:测试admin用户的环境变量脚本是否可用?
[root@node01 ~]# ll
total 8
-rwxr-xr-x 1 root root 272 Oct 28 20:23 admin.sh
-rwxr-xr-x 1 root root 269 Oct 28 20:24 demo.sh
[root@node01 ~]# source admin.sh
[root@node01 ~]# openstack token issue
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| expires | 2020-10-28T13:29:08+0000 |
| id | gAAAAABfmWQU2Z97wzxv94lLY4hcSWe4X6Udp_OyeYw3_wY54_znLFb4TFLcMnR96-ogNAcJEvXiQcJWdvQJHBObYbR-gAEulagQq2sjXLxedMYLUN4j2y_L4G5NhbaogGKtHed4WMR0N72Js4INyHjKWCwwSd2d4NJpZUe14pQjNX8ihleP09g |
| project_id | b4e56eeb160948c581e98d685133d19a |
| user_id | a105f256dc9f42438212e9d96d46b60d |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[root@node01 ~]#
提示:重新开一个终端,导出admin用户环境变量,然后直接使用openstack token issue命令就能验证admin用户;有了这个环境变量脚本,我们不用输密码和不用写那么长的命令了;
验证demo用户的环境变量脚本
[root@node01 ~]# ll
total 8
-rwxr-xr-x 1 root root 272 Oct 28 20:23 admin.sh
-rwxr-xr-x 1 root root 269 Oct 28 20:24 demo.sh
[root@node01 ~]# source demo.sh
[root@node01 ~]# openstack token issue
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| expires | 2020-10-28T13:31:34+0000 |
| id | gAAAAABfmWSmj5PHp8x3m3szKwZ0_dWSdY-JM-TBbo-bMk4OaTHl3BLNVrglKXRMe5jpbCOBPb5l2AyHWVvzvJdi2Jx4va7PJksJGlx_JluhOx9vry1kjiZoKcW7Ri3Y7qkYFvDcpDHXy0KkYeHSyMW9zjNaFvvJtrPpozgfw7gsghYJNfZoYz0 |
| project_id | 1a918887f38a42c28f9d0d3774f34b16 |
| user_id | 5453d68782a34429a7dab7da9c51f0d9 |
+------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
[root@node01 ~]#
提示:demo用户的环境变量脚本也都能够正常通过验证;到此keystone服务的安装配置测试就完成了;
云计算管理平台之OpenStack认证服务Keystone的更多相关文章
- 云计算管理平台之OpenStack启动虚拟机实例
在前边的博客中,我们主要聊了下openstack的基础环境.核心服务(认证服务keystone/镜像服务glance/计算服务nova/网络服务neutron)的安装配置:回顾请查看前边的博客:今天我 ...
- 云计算管理平台之OpenStack Web管理工具dashboard
在上一篇博客中,我们成功的基于两种网络启动虚拟机:这意味着openstack的核心服务都搭建完成,并正常运行着:有关启动虚拟机实例请参考上一篇博客:今天我们来了解下,基于一个web界面图形工具来管理o ...
- 云计算管理平台之OpenStack镜像服务glance
一.glance简介 openstack中的glance服务是用来存储在openstack上启动虚拟机所需镜像:它主要用于发现.注册及检索虚拟机镜像:它通过提供RESTful风格的api对外提供服务: ...
- 云计算管理平台之OpenStack计算服务nova
一.nova简介 nova是openstack中的计算服务,其主要作用是帮助我们在计算节点上管理虚拟机的核心服务:这里的计算节点就是指用于提供运行虚拟机实例的主机,通常像这种计算节点有很多台,那么虚拟 ...
- 云计算管理平台之OpenStack网络服务neutron
一.简介 neutron的主要作用是在openstack中为启动虚拟机实例提供网络服务,对于neutron来讲,它可以提供两种类型的网络:第一种是provider network,这种网络就是我们常说 ...
- 云计算管理平台之OpenStack块存储服务cinder
一.cinder简介 cinder是openstack环境中的块存储服务,主要为运行在openstack之上的虚拟机提供块存储服务的:所谓块存储就是我们经常用的硬盘呀,U盘啊,SD卡等等这些块设备的, ...
- OpenStack 认证服务 KeyStone连接和用户管理(四)
连接keystone两种方式: 一种使用命令 一种使用环境变量 1.通过环境变量方式连接keystone(适合在初始化场景使用) 配置认证令牌环境变量 export OS_TOKEN=07081849 ...
- OpenStack 认证服务 KeyStone连接和用户管理(五)
一) 创建环境变量链接keyston vim adminrc export OS_USERNAME=admin export OS_PASSWORD=redhat export OS_PROJECT_ ...
- OpenStack 认证服务 KeyStone 服务注册(五)
创建服务实体和API端点 创建服务 openstack service create --name keystone --description "OpenStack Identity&qu ...
随机推荐
- Spring Boot学习(二)搭建一个简易的Spring Boot工程
第一步:新建项目 新建一个SpringBoot工程 修改项目信息 勾选项目依赖和工具 选择好项目的位置,点击[Finish] 第二步:项目结构分析 新建好项目之后的结构如下图所示,少了很多配置文件: ...
- 无所不能的embedding 3. word2vec->Doc2vec[PV-DM/PV-DBOW]
这一节我们来聊聊不定长的文本向量,这里我们暂不考虑有监督模型,也就是任务相关的句子表征,只看通用文本向量,根据文本长短有叫sentence2vec, paragraph2vec也有叫doc2vec的. ...
- matlab中fix, floor, ceil, round 函数的使用方法
转载: https://www.ilovematlab.cn/thread-91895-1-1.html Matlab取整函数有: fix, floor, ceil, round.具体应用方法如下: ...
- Java (二)基于Eclipse配置Commons IO的环境
上一篇:Java (一)下载APACHE Commons IO 一.新建一个Java Project 二.使用鼠标右键点击工程,选择New > Folder 三.在Folder name输入文件 ...
- 【原创】经验分享:一个小小emoji尽然牵扯出来这么多东西?
前言 之前也分享过很多工作中踩坑的经验: 一个线上问题的思考:Eureka注册中心集群如何实现客户端请求负载及故障转移? [原创]经验分享:一个Content-Length引发的血案(almost.. ...
- 关于freemodbus协议中eMBFuncReadHoldingRegister()函数的所谓错误
摘要:网上看到有好心的网友提示,freemodbus协议中的mbfuncholding.c 文件中eMBFuncReadHoldingRegister()函数,有一处错误,即:第185行的" ...
- 2-Java面试-面向对象
Java面试问题-面向对象 Q1.什么是多态? 多态被简要描述为"一个接口,许多实现".多态性是能够在不同上下文中为某事物赋予不同含义或用法的一种特征-具体来说,就是允许诸如变量, ...
- Python 3.9 新特性速览
国庆假期,Python 社区发布了 3.9 版本的第一个 stable release. 相比于 3.8,Python 3.9 新特性众多,但不少特性与大多数 Python"使用者" ...
- map的自动扩容与手动缩容
map的自动扩容与手动缩容 首先还是提出问题:扩容和缩容有什么用?为什么需要扩容和缩容? 在想解答这个问题之前,首先还是需要了解一下go语言中的map go语言中的map与Java中的map实现还是有 ...
- ng2 父子组件传值 - 状态管理
一. 父子组件之间进行直接通话 //父组件html <ul> <app-li [value] = "value" (liClick) = "liClic ...