本章节安装配置keystone身份认证服务

  1. 创建数据库

[root@controller ~]# mysql -uroot -p123456
# 创建keystone数据库
MariaDB [(none)]> CREATE DATABASE keystone;
Query OK, 1 row affected (0.00 sec)
# 授予数据库访问权限
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' \  
 IDENTIFIED BY 'KEYSTONE_DBPASS';
Query OK, 0 rows affected (0.00 sec)
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' \    
 IDENTIFIED BY 'KEYSTONE_DBPASS';
Query OK, 0 rows affected (0.00 sec)
# 用合适的密码替换KEYSTONE_DBPASS。

2.安装软件包

[root@controller ~]# yum install openstack-keystone httpd mod_wsgi -y

3.编辑/etc/keystone/keystone.conf文件

[root@controller ~]# cd /etc/keystone/
[root@controller keystone]# cp keystone.conf keystone.conf.bak
[root@controller keystone]# egrep -v "^#|^$" keystone.conf.bak > keystone.conf
[root@controller keystone]# vim keystone.conf
添加如下内容

[database]
...
connection = mysql+pymysql://keystone:KEYSTONE_DBPASS@controller/keystone
[token]
...
provider = fernet

4.导入数据库

[root@controller ~]# su -s /bin/sh -c "keystone-manage db_sync" keystone

5.初始化Fernet key存储库

[root@controller ~]# keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
[root@controller ~]# keystone-manage credential_setup --keystone-user keystone --keystone-group keystone

6.引导身份认证

# keystone-manage bootstrap --bootstrap-password admin \  
--bootstrap-admin-url http://controller:35357/v3/ \  
--bootstrap-internal-url http://controller:35357/v3/ \  
--bootstrap-public-url http://controller:5000/v3/ \  
--bootstrap-region-id RegionOne

7.配置http服务器

[root@controller ~]# sed -i 's/#ServerName www.example.com:80/ServerName controller/g' /etc/httpd/conf/httpd.conf 
[root@controller ~]# ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/

8.启动http服务

[root@controller ~]# systemctl enable httpd.service
[root@controller ~]# systemctl start httpd.service
[root@controller ~]# netstat -lntp |grep http

9.配置管理用户

[root@controller ~]# export OS_USERNAME=admin
[root@controller ~]# export OS_PASSWORD=admin
[root@controller ~]# export OS_PROJECT_NAME=admin
[root@controller ~]# export OS_USER_DOMAIN_NAME=Default
[root@controller ~]# export OS_PROJECT_DOMAIN_NAME=Default
[root@controller ~]# export OS_AUTH_URL=
[root@controller ~]# export OS_IDENTITY_API_VERSION=3

10.创建用户、域、角色

[root@controller ~]# openstack project create --domain default \
  --description "Service Project" service

云计算之openstack-newton版搭建(三)_第1张图片

[root@controller ~]# openstack project create --domain default  \
 --description "Demo Project" demo

云计算之openstack-newton版搭建(三)_第2张图片

[root@controller ~]# openstack user create --domain default  \
 --password-prompt demo
 密码123456

云计算之openstack-newton版搭建(三)_第3张图片

[root@controller ~]# openstack role create user

云计算之openstack-newton版搭建(三)_第4张图片

[root@controller ~]# openstack role add --project demo --user demo user

没有输出

11.验证

# unset OS_AUTH_URL OS_PASSWORD
# 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 token issue
# 密码admin
# 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 token issue
# 密码123456

云计算之openstack-newton版搭建(三)_第5张图片

12.创建脚本

[root@controller ~]# vim admin-openrc
添加如下内容
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=
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
[root@controller ~]# vim demo-openrc
添加如下内容
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=
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2

13.验证

[root@controller ~]# . admin-openrc 
[root@controller ~]# . demo-openrc 
[root@controller ~]# openstack token issue
+------------+------------------------------------------------------------------------------------------------------------------------------------------+
| Field      | Value                                                                                                                                    |
+------------+------------------------------------------------------------------------------------------------------------------------------------------+
| expires    | 2017-01-11 02:51:34+00:00                                                                                                                |
| id         | gAAAAABYdY-mPA1ksYBZ2r1yay346HB9aoJQyj1WdKTIsKiEjV_2GJfgVU_Yb6R8C4qNjzkwTyEXMITQQWgaawQqDK480YCnQwFsWzj06DhIaKpahb81X8LaPV3uHngL8HSryoRf |
|            | RBmou4S27fu4gjm1HzwMegMjFB05GzaONJcnZDP6kHdQ3JU                                                                                          |
| project_id | 850d3633f2c64438a7ab00239387a7a2                                                                                                         |
| user_id    | 8e91a79dd061453ca6cf02f7487591c0                                                                                                         |
+------------+------------------------------------------------------------------------------------------------------------------------------------------+
[root@controller ~]#