一、新建数据库及用户(控制节点)
# mysql -uroot -p12345678
MariaDB [(none)]> CREATE DATABASE keystone;
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'keystone123';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'keystone123';
MariaDB [(none)]> flush privileges;
MariaDB [(none)]> exit;
二、安装keystone(控制节点)
安装软件包:
# yum install -y openstack-keystone httpd mod_wsgi
修改keystone配置文件:
vim /etc/keystone/keystone.conf
编辑模式下(冒号)
删除#开头行 %g/^#/d
删除空白行 %g/^$/d
[database]
connection = mysql+pymysql://keystone:keystone123@localhost/keystone
[token]
provider = fernet #配置Fernet UUID令牌的提供者
初始化数据库:
# su -s /bin/sh -c "keystone-manage db_sync" keystone
初始化Fernet密钥存储库:
# keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
# keystone-manage credential_setup --keystone-user keystone --keystone-group keystone
配置引导标识服务:
keystone-manage bootstrap --bootstrap-password 123456
--bootstrap-admin-url http://10.10.11.11:35357/v3/
--bootstrap-internal-url http://10.10.11.11:5000/v3/
--bootstrap-public-url http://10.10.11.11:5000/v3/
--bootstrap-region-id RegionOne
#记住RegionOne
配置apache httpd
# vim /etc/httpd/conf/httpd.conf
#修改ServerName
ServerName 10.10.11.11:80
配置wsgi模块软件连接
# ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/
启动httpd
# systemctl enable httpd.service
# systemctl start httpd.service
# systemctl status httpd.service
查看35357和5000端口有没有被监听
# netstat -anpt | grep http
tcp6 0 0 :::5000 :::* LISTEN 7449/httpd
tcp6 0 0 :::80 :::* LISTEN 7449/httpd
tcp6 0 0 :::35357 :::* LISTEN 7449/httpd
三、创建域、项目、用户、角色(控制节点)
使用环境变量:
# vim set_env
export OS_PROJECT_NAME=admin
export OS_USERNAME=admin
export OS_PASSWORD=123456
export OS_AUTH_URL=http://10.10.11.11:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
# source set_env
创建一个服务项目,名称是“service”,该服务项目包含唯一用户,它是添加到环境的所有服务的用户:
# openstack project create --domain default --description "Service Project" service
查看:
# openstack project list
注意,其中的admin项目是自动创建的,不需要手工创建。
创建demo项目:
# openstack project create --domain default --description "Demo Project" demo
创建“demo”用户并设置密码:
# openstack user create --domain default --password-prompt demo #创建demo用户并输入密码demo123
创建“user”角色:
# openstack role create user
为“demo”项目的“demo”用户添加“user”角色:
# openstack role add --project demo --user demo user
四、测试令牌是否正常
# unset OS_AUTH_URL OS_PASSWORD
尝试用admin用户请求一个令牌看是否正常
# openstack --os-auth-url http://10.10.11.11:35357/v3
--os-project-domain-name default --os-user-domain-name default
--os-project-name admin --os-username admin token issue
输入密码:123456
尝试用demo用户请求一个令牌看是否正常
# openstack --os-auth-url http://10.10.11.11:5000/v3
--os-project-domain-name default --os-user-domain-name default
--os-project-name demo --os-username demo token issue
输入密码:demo123
五、为admin和demo用户创建环境变量脚本
# 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=123456
export OS_AUTH_URL=http://10.10.11.11:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
# 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=demo123
export OS_AUTH_URL=http://10.10.11.11:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
测试脚本使用
# source admin-openrc
# openstack token issue #admin用户请求令牌
# source demo-openrc
# openstack token issue #demo用户请求令牌
六、keystone服务正常测试
从各节点访问keystone服务,验证是否正常
# curl http://10.10.11.11:35357/v3
# curl http://10.10.11.11:35357/v3
查看创建的Identity服务及其endpoint:
# source admin-openrc
# openstack service list
# openstack endpoint list