安装keystone认证服务
1、创建keystone数据库
#mysql -uroot -phncgo110 -e "CREATE DATABASE keystone;"
注意将hncgo110替换为自己的数据库密码
2、创建数据库用户及赋予权限
#mysql -uroot -phncgo110 -e "GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'hncgo110';"
#mysql -uroot -phncgo110 -e "GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'hncgo110';"
注意将hncgo110替换为自己的数据库用户密码
3、生成一个随机值在初始的配置中作为管理员的令牌
#openssl rand -hex 10
将生成的token记录下来,在后边的配置中需要使用
4、安装keystone相关软件包
#yum install openstack-keystone httpd mod_wsgi openstack-utils -y
文档中都是使用快速的配置方法,所以必须安装Openstack-utils
5、配置/etc/keystone/keystone.conf文件
#openstack-config --set /etc/keystone/keystone.conf DEFAULT admin_token ed54174f9f7b1545a535
##将ed54174f9f7b1545a535替换成自己的Token
#openstack-config --set /etc/keystone/keystone.conf database connection mysql+pymysql://keystone:hncgo110@192.168.31.100/keystone
##替换自己的数据库IP地址和相应的密码
6、初始化身份认证服务的数据库并设置toden存放的位置
#su -s /bin/sh -c "keystone-manage db_sync" keystone
#openstack-config --set /etc/keystone/keystone.conf token provider fernet
#openstack-config --set /etc/keystone/keystone.conf token driver memcache
7、初始化Fernet keys
#keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
8、配置http服务
#sed -i "s/#ServerName www.example.com:80/ServerName 192.168.31.100/" /etc/httpd/conf/httpd.conf
##配置对应的IP地址,以供web进行访问
9、用下面的内容创建文件 /etc/httpd/conf.d/wsgi-keystone.conf,keystone的http配置文件
#vim /etc/httpd/conf.d/wsgi-keystone.conf
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
ErrorLogFormat "%{cu}t %M"
ErrorLog /var/log/httpd/keystone-error.log
CustomLog /var/log/httpd/keystone-access.log combined
<Directory /usr/bin>
Require all granted
</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
ErrorLogFormat "%{cu}t %M"
ErrorLog /var/log/httpd/keystone-error.log
CustomLog /var/log/httpd/keystone-access.log combined
<Directory /usr/bin>
Require all granted
</Directory>
</VirtualHost>
10、启动 Apache HTTP 服务并配置其随系统启动
#systemctl enable httpd.service
#systemctl start httpd.service
#systemctl status httpd.service
#systemctl list-unit-files |grep httpd.service
11、导入环境变量
#export OS_TOKEN=ed54174f9f7b1545a535
#export OS_URL=http://192.168.31.100:35357/v3
#export OS_IDENTITY_API_VERSION=3
########替换自己的Token
12、创建域‘‘default’’默认域
#openstack domain create --description "Default Domain" default
13、创建admin项目
#openstack project create --domain default --description "Admin Project" admin
14、创建用户输入admin密码
#openstack user create --domain default admin --password admin
密码设置为:admin 根据实际情况设置相应的密码
15、创建 admin 角色
#openstack role create admin
16、添加admin
角色到 admin 项目和用户上
#openstack role add --project admin --user admin admin
17、创建service项目
#openstack project create --domain default --description "Service Project" service
18、创建demo项目
#openstack project create --domain default --description "Demo Project" demo
19、创建demo用户并设置Demo密码
#openstack user create --domain default demo --password demo
密码设置为:demo 根据实际情况设置相应的密码
20、创建user角色
#openstack role create user
21、添加 user角色到
demo 项目和用户
#openstack role add --project demo --user demo user
22、创建keystone实体和身份认证服务
#openstack service create --name keystone --description "OpenStack Identity" identity
23、创建认证服务的 API 端点
#openstack endpoint create --region RegionOne identity public http://192.168.31.100:5000/v3
#openstack endpoint create --region RegionOne identity internal http://192.168.31.100:5000/v3
#openstack endpoint create --region RegionOne identity admin http://192.168.31.100:35357/v3
24重置OS_TOKEN
和OS_URL
环境变量
#unset OS_TOKEN OS_URL
25、测试是否可以使用admin账户进行登陆认证
#openstack --os-auth-url http://192.168.31.100:35357/v3 --os-project-domain-name default --os-user-domain-name default --os-project-name admin --os-username admin token issue --os-password admin
26、测试是否可以使用demo账户进行登陆认证
#openstack --os-auth-url http://192.168.31.100:5000/v3 --os-project-domain-name default --os-user-domain-name default --os-project-name demo --os-username demo token issue --os-password demo
27、创建admin用户环境变量,创建/root/admin-openrc 文件并写入如下内容
#vim /root/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=http://192.168.31.100:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
####修改admin用户的密码及对应的IP地址
28、创建demo用户环境变量,创建/root/demo-openrc 文件并写入下列内容
vim /root/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=demo
export OS_AUTH_URL=http://192.168.31.100:5000/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
####修改demo用户的密码及对应的IP地址
29、验证
#source /root/admin-openrc
#openstack token issue