openstack 之~keystone部署
第一:版本信息
官网http://docs.openstack.org/newton/install-guide-rdo/keystone.html
我们按照Newton这个版本来部署,openstack基本保持每6个月更新一个版本,面对如此快的版本更新,我们其实瞅准了一个版本深入研究下去就好,争取为社区提交代码。
第二:部署keystone
参考部署官网:http://docs.openstack.org/newton/install-guide-rdo/
查看系统信息:
[root@localhost ~]# cat /etc/redhat-release
CentOS Linux release 7.0. (Core)
[root@localhost ~]# uname -a
Linux localhost.localdomain 3.10.-.el7.x86_64 # SMP Mon Jun :: UTC x86_64 x86_64 x86_64 GNU/Linux
准备阶段:
yum -y install centos-release-openstack-newton #安装官方yum源
yum -y upgrade #更新
yum -y install python-openstackclient #安装工具
yum -y install openstack-selinux #安装openstack-selinux包自动管理openstack组件的安全策略
额外补充:
[root@localhost ~]# more /etc/yum.conf
[main]
cachedir=/newton 新建该目录
keepcache=1 把这个原本是0的改为1,是把yum缓存到本地
debuglevel=
logfile=/var/log/yum.log
exactarch=
obsoletes=
gpgcheck=
plugins=
installonly_limit=
bugtracker_url=http://bugs.centos.org/set_project.php?project_id=23&ref=http://bugs.centos.org/bug_report_page.php?category=yum
distroverpkg=centos-release
mkdir /newton
部署数据库
keystone支持ldap和mysql作为后端Driver,用来存放用户相关信息,catalog等,这里我们选用mariadb
yum -y install mariadb mariadb-server python2-PyMySQL
配置
配置文件:/etc/my.cnf.d/openstack.cnf [mysqld]
bind-address = 192.168.1.120 #本机管理网络ip default-storage-engine = innodb #mysql的存储引擎
innodb_file_per_table #独立表空间
max_connections = #最大链接数
collation-server = utf8_general_ci #默认排序规则
character-set-server = utf8 #字符集
启动服务并设置开机自启动且检查状态
[root@localhost ~]# systemctl start mariadb.service
[root@localhost ~]# systemctl enable mariadb.service
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.
[root@localhost ~]# systemctl status mariadb.service
● mariadb.service - MariaDB 10.1 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
Active: active (running) since Mon -- :: EST; 16s ago
Main PID: (mysqld)
Status: "Taking your SQL requests now..."
CGroup: /system.slice/mariadb.service
└─ /usr/libexec/mysqld --basedir=/usr Feb :: localhost.localdomain mysql-prepare-db-dir[]: Please report any problems at http://mariadb.org/jira
Feb :: localhost.localdomain mysql-prepare-db-dir[]: The latest information about MariaDB is available at http://mariadb.org/.
Feb :: localhost.localdomain mysql-prepare-db-dir[]: You can find additional information about the MySQL part at:
Feb :: localhost.localdomain mysql-prepare-db-dir[]: http://dev.mysql.com
Feb :: localhost.localdomain mysql-prepare-db-dir[]: Support MariaDB development by buying support/new features from MariaDB
Feb :: localhost.localdomain mysql-prepare-db-dir[]: Corporation Ab. You can contact us about this at sales@mariadb.com.
Feb :: localhost.localdomain mysql-prepare-db-dir[]: Alternatively consider joining our community based development effort:
Feb :: localhost.localdomain mysql-prepare-db-dir[]: http://mariadb.com/kb/en/contributing-to-the-mariadb-project/
Feb :: localhost.localdomain mysqld[]: -- :: [Note] /usr/libexec/mysqld (mysqld 10.1.-MariaD... ...
Feb :: localhost.localdomain systemd[]: Started MariaDB 10.1 database server.
Hint: Some lines were ellipsized, use -l to show in full.
MariaDB已经启动
初始化数据库
mysql_secure_installation
部署keystone
keystone关于数据库的操作
[root@localhost ~]# mysql -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is
Server version: 10.1.-MariaDB MariaDB Server Copyright (c) , , 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, row affected (0.00 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' \
-> IDENTIFIED BY ''; #新建本地访问keystone账号
Query OK, rows affected (0.00 sec) MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' \
-> IDENTIFIED BY ''; #新建远程访问keystone账号
Query OK, rows affected (0.00 sec)
安装包:
#keystone软件包名openstack-keystone
#安装httpd和mod_wsgi的原因是,社区主推apache+keystone
#openstack-keystone本质就是一款基于wsgi协议的web app,而httpd本质就是一个兼容wsgi协议的web server,所以我们需要为httpd安装mod_wsgi模块
yum -y install openstack-keystone httpd mod_wsgi
配置:/etc/keystone/keystone.conf
#让openstack-keystone能够知道如何连接到后端的数据库keystone
#mysql+pymysql:pymysql是一个python库,使用python可以操作mysql原生sql
[database]
connection = mysql+pymysql://keystone:123@192.168.31.57/keystone #注意123没有引号哈
[token]
provider = fernet #fernet为生成token的方式
初始化数据库keystone
#初始化是因为python的orm对象关系映射,需要初始化来生成数据库表结构
su -s /bin/sh -c "keystone-manage db_sync" keystone
初始化Fernet key仓库
keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
keystone-manage credential_setup --keystone-user keystone --keystone-group keystone
结合apache整合keystone
首先修改主机名
hostnamectl set-hostname controller
设置/etc/hosts
192.168.1.120 controller
配置/etc/httpd/conf/httpd.conf
ServerName controller
为mod_wsgi模块添加配置文件
ln -s /usr/share/keystone/wsgi-keystone.conf /etc/httpd/conf.d/
注:直接复制也可以
启动apache,设置开机自启动
systemctl start httpd.service
systemctl enable httpd.service
第三:keystone操作
一:创建keystone的catalog
配置/etc/keystone/keystone.conf
[DEFAULT]
admin_token =
设置环境变量
#OS_TOKEN=配置文件中的admin_token
#会在filter过滤过程中被admin_token_auth中间间设置is_admin=True
#谁有这个admin_token谁就是管理员了。 export OS_TOKEN= #等于keystone.conf中admin_token的值
export OS_URL=http://192.168.1.120:35357/v3
export OS_IDENTITY_API_VERSION=
为keystone创建catalog
#根据上一步给的权限,创建认证服务实体
[root@localhost ~]# openstack service create \
> --name keystone --description "OpenStack Identity" identity
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | OpenStack Identity |
| enabled | True |
| id | 7ed3a973acd3460883efdc187225ef80 |
| name | keystone |
| type | identity |
+-------------+----------------------------------+
#根据上一步建立的服务实体,创建访问该实体的三个api端点
[root@localhost ~]# openstack endpoint create --region RegionOne \
> identity public http://192.168.1.120:5000/v3
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 37d4397231f74a5b98c48fd1220d7cd0 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7ed3a973acd3460883efdc187225ef80 |
| service_name | keystone |
| service_type | identity |
| url | http://192.168.1.120:5000/v3 |
+--------------+----------------------------------+
[root@localhost ~]# openstack endpoint create --region RegionOne \
> identity internal http://192.168.1.120:5000/v3
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 72b8b7a700124e3f8876c6e74fd7b0c5 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7ed3a973acd3460883efdc187225ef80 |
| service_name | keystone |
| service_type | identity |
| url | http://192.168.1.120:5000/v3 |
+--------------+----------------------------------+
[root@localhost ~]# openstack endpoint create --region RegionOne \
> identity admin http://192.168.1.120:35357/v3
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | b63e63c081b74dc3829cb9ae045f02f7 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | 7ed3a973acd3460883efdc187225ef80 |
| service_name | keystone |
| service_type | identity |
| url | http://192.168.1.120:35357/v3 |
+--------------+----------------------------------+
二:创建域,项目,用户,角色,把四个元素关联到一起
首先建立一个公共的域名:
[root@localhost ~]# openstack domain create --description "Default Domain" default
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Default Domain |
| enabled | True |
| id | 9526862455314cefbf4ad7faa4580582 |
| name | default |
+-------------+----------------------------------+
创建管理员各项信息:
#创建admin项目
[root@localhost ~]# openstack project create --domain default \
> --description "Admin Project" admin
ole add --project admin --user admin admin
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Admin Project |
| domain_id | 9526862455314cefbf4ad7faa4580582 |
| enabled | True |
| id | d2cac6cd998a4463abc5e83ec06f8996 |
| is_domain | False |
| name | admin |
| parent_id | 9526862455314cefbf4ad7faa4580582 |
+-------------+----------------------------------+
#创建admin用户
[root@localhost ~]# openstack user create --domain default \
> --password-prompt admin
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | 9526862455314cefbf4ad7faa4580582 |
| enabled | True |
| id | 97ecd026af9f46349b76c57af5f7f84c |
| name | admin |
| password_expires_at | None |
+---------------------+----------------------------------+
#创建admin角色
[root@localhost ~]# openstack role create admin
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | None |
| id | 81fcdb131f3d4a0d8b4fa3bc95cf7f46 |
| name | admin |
+-----------+----------------------------------+
三者关联(项目、用户、角色)
[root@localhost ~]# openstack role add --project admin --user admin admin
三:使用Bootstrap完成一和二的工作
#为keystone创建catalog
keystone-manage bootstrap --bootstrap-password \
--bootstrap-admin-url http://192.168.1.120:35357/v3/ \
--bootstrap-internal-url http://192.168.1.120:35357/v3/ \
--bootstrap-public-url http://192.168.1.120:5000/v3/ \
--bootstrap-region-id RegionOne
设置环境变量(is_admin不会被设置成True,admin用户会获得一个Token)
export OS_USERNAME=admin
export OS_PASSWORD= #就是keystone-manage中设定的--bootstrap-password
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_AUTH_URL=http://192.168.1.120:35357/v3
export OS_IDENTITY_API_VERSION=
四:创建的项目,普通用户,项目,角色,建立关联
#创建project名为demo
[root@localhost ~]# openstack project create --domain default \
> --description "Demo Project" demo
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Demo Project |
| domain_id | 9526862455314cefbf4ad7faa4580582 |
| enabled | True |
| id | 1d57f06fda06450298d5cf72777be63d |
| is_domain | False |
| name | demo |
| parent_id | 9526862455314cefbf4ad7faa4580582 |
+-------------+----------------------------------+
#创建普通用户demo
[root@localhost ~]# openstack user create --domain default \
> --password-prompt demo
User Password:
Repeat User Password:
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | 9526862455314cefbf4ad7faa4580582 |
| enabled | True |
| id | 8e28f8c353db487eb17477953e34452c |
| name | demo |
| password_expires_at | None |
+---------------------+----------------------------------+
#创建普通用户的角色即user
[root@localhost ~]# openstack role create user
+-----------+----------------------------------+
| Field | Value |
+-----------+----------------------------------+
| domain_id | None |
| id | d0094c83800043529c37401a28815497 |
| name | user |
+-----------+----------------------------------+
#建立三者关联
[root@localhost ~]# openstack role add --project demo --user demo user
五:为后续的服务创建统一租户service
#后面所有的服务公用一个项目service,都是管理员角色admin
#所以实际上后续的服务安装关于keysotne的操作只剩2,
[root@localhost ~]# openstack project create --domain default \
> --description "Service Project" service
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Service Project |
| domain_id | 9526862455314cefbf4ad7faa4580582 |
| enabled | True |
| id | 75026d89c408438086f2314c003fdc8f |
| is_domain | False |
| name | service |
| parent_id | 9526862455314cefbf4ad7faa4580582 |
+-------------+----------------------------------+
小结:后面每搭建一个新的服务都需要在keystone中执行四种操作:1.建项目 2.建用户 3.建角色 4.做关联
第四:验证
准备工作
出于安全考虑,需要关闭临时令牌认证机制(配置文件中的admin_token和keystone-manage的--bootstrap-password都是基于该机制) 该机制会将用户的请求设置is_admin=True,源码分析中会介绍,先暂且理解到这里
编辑/etc/keystone/keystone-paste.ini
这三个
[pipeline:public_api]
[pipeline:admin_api]
[pipeline:api_v3]
中的admin_token_auth都去掉
取消一切设置的环境变量,如
unset OS_AUTH_URL OS_PASSWORD
开始验证:用admin用户
报错了,这个错误的中文意思是:只有认证的用户才可以申请token,我也申请过了,这是什么原因?
原因有两个:第一:主机名/etc/hosts,配置不正确
第二:主机名修改后没有进行重新登录
最好这个第一步就做了,
验证成功
温馨提示:一定要加上--os-identity-api-version 3 咱们用的是v3
用demo用户验证:
验证方法二:
[root@controller ~]# curl -i \
> -H "Content-Type: application/json" \
> -d '
> {
> "auth": {
> "identity": {
> "methods": [
> "password"
> ],
> "password": {
> "user": {
> "domain":{
> "name": "default"
> },
> "name": "admin",
> "password": ""
> }
> }
> },
> "scope": {
> "project": {
> "domain": {
> "name":"default"
> },
> "name": "admin"
> }
> }
> }
> }' \
> http://127.0.0.1:5000/v3/auth/tokens
HTTP/1.1 Created
Date: Mon, Feb :: GMT
Server: Apache/2.4. (CentOS) mod_wsgi/3.4 Python/2.7.
X-Subject-Token: gAAAAABYmJcyCNVmoREAng1Q_KKedkdp3SVMnJdZeH1edN-lQk5OLM0_Nfqar-YeObaVn2Go90jFVCMbRk5UE-rRhDPqW33mlccjD2aTrf0U3cHNAj_dqSJJaXNfCPjpwSH2bopieKeOMaY87NtiUhZunTvvPRORsGUrrSR2KGBxRmM0dNpIX-A
Vary: X-Auth-Token
x-openstack-request-id: req-5ec4e24e-dc11-4d89-99f9-e9dabbe3a948
Content-Length:
Content-Type: application/json {"token": {"is_domain": false, "methods": ["password"], "roles": [{"id": "81fcdb131f3d4a0d8b4fa3bc95cf7f46", "name": "admin"}], "expires_at": "2017-02-06T16:33:00.000000Z", "project": {"domain": {"id": "9526862455314cefbf4ad7faa4580582", "name": "default"}, "id": "d2cac6cd998a4463abc5e83ec06f8996", "name": "admin"}, "catalog": [{"endpoints": [{"region_id": "RegionOne", "url": "http://192.168.1.120:5000/v3", "region": "RegionOne", "interface": "public", "id": "37d4397231f74a5b98c48fd1220d7cd0"}, {"region_id": "RegionOne", "url": "http://192.168.1.120:5000/v3", "region": "RegionOne", "interface": "internal", "id": "72b8b7a700124e3f8876c6e74fd7b0c5"}, {"region_id": "RegionOne", "url": "http://192.168.1.120:35357/v3", "region": "RegionOne", "interface": "admin", "id": "b63e63c081b74dc3829cb9ae045f02f7"}], "type": "identity", "id": "7ed3a973acd3460883efdc187225ef80", "name": "keystone"}], "user": {"domain": {"id": "9526862455314cefbf4ad7faa4580582", "name": "default"}, "id": "97ecd026af9f46349b76c57af5f7f84c", "name": "admin"}, "audit_ids": ["Jw80h1bURZ6u6vYzcRA3xg"], "issued_at": "2017-02-06T15:33:06.000000Z"}}
第五:查看信息
查看catalog信息,admin,internal,public
查看endpoint信息
查看服务列表
查看域列表
查看项目,角色,用户,以及他们的管理信息
第六:编写脚本
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=123
export OS_AUTH_URL=http://192.168.1.120:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
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=123
export OS_AUTH_URL=http://192.168.1.120:35357/v3
export OS_IDENTITY_API_VERSION=3
export OS_IMAGE_API_VERSION=2
小结:我们可以针对不同的用户,都定义成脚本
我们的申请token操作为:
source admin-openrc
openstack token issue
openstack 之~keystone部署的更多相关文章
- openstack之keystone部署
前言 openstack更新频率是挺快的,每六个月更新一次(命名是是以A-Z的方式,Austin,Bexar...Newton).博主建议大家先可一种版本研究,等某一版本研究透彻了,在去研究新的版本. ...
- OpenStack 认证服务 KeyStone部署(三)
Keystone 介绍 Keystone作用: 用户与认证:用户权限与用户行为跟踪: 服务目录:提供一个服务目录,包括所有服务项和相关Api的断点 SOA相关知识 Keystone主要两大功能用户认证 ...
- OpenStack 认证服务 KeyStone部署 (四)
Keystone作用: 用户与认证:用户权限与用户行为跟踪: 服务目录:提供一个服务目录,包括所有服务项和相关Api的断点 SOA相关知识 Keystone主要两大功能用户认证和服务目录(相当于一个注 ...
- openstack(Pike 版)集群部署(二)--- Keystone 部署
一.介绍 参照官网部署:https://docs.openstack.org/keystone/queens/install/ 继续上一博客进行部署:http://www.cnblogs.com/we ...
- 理解 OpenStack + Ceph (1):Ceph + OpenStack 集群部署和配置
本系列文章会深入研究 Ceph 以及 Ceph 和 OpenStack 的集成: (1)安装和部署 (2)Ceph RBD 接口和工具 (3)Ceph 物理和逻辑结构 (4)Ceph 的基础数据结构 ...
- openstack组件手动部署整合
preface:当你完全且正确的配置好整个OpenStack ENV 你将能看到的和体验到的!!! 我们先来看看简单效果吧,祝君能在这条路上走的更远,更好;
- OpenStack之Keystone模块
一.Keystone介绍 OpenStack Identity(Keystone)服务为运行OpenStack Compute上的OpenStack云提供了认证和管理用户.帐号和角色信息服务,并为Op ...
- openstack核心组件——keystone身份认证服务(5)
云计算openstack核心组件——keystone身份认证服务(5) 部署公共环境 ntp openstack mariadb-server rabbitmq-server memcache 1.w ...
- openstack高可用集群21-生产环境高可用openstack集群部署记录
第一篇 集群概述 keepalived + haproxy +Rabbitmq集群+MariaDB Galera高可用集群 部署openstack时使用单个控制节点是非常危险的,这样就意味着单个节 ...
随机推荐
- springboot 传List参数
最近项目有个需求,前台需要传list参数请求controller接口,一开始直接使用ResponseBody注解,但实践下来发现参数没有传到controller. 现将处理方式记录如下: 1.前台 ...
- VM VirtualBox – Cannot register the hard disk
第一打开VirtualBox 文件夹,在地址栏输入cmd 第二, 仔细读下面 VBoxManage.exe internalcommands sethduuid "F:\Virtual ...
- 2018牛客网暑假ACM多校训练赛(第十场)H Rikka with Ants 类欧几里德算法
原文链接https://www.cnblogs.com/zhouzhendong/p/NowCoder-2018-Summer-Round10-H.html 题目传送门 - https://www.n ...
- ajax请求后台,response.sendRedirect失效,无法重定向
今天在写项目的时候,想加一个切换用户,需要清除session并且跳转到登录页面,发起一个ajax请求后,执行完发现无法跳转. 原因在于: (从网上摘录) Ajax只是利用脚本访问对应url获取数据而已 ...
- 应用:计算字符串的长度(一个双字节字符长度计2,ASCII字符计1) String.prototype.len=function(){return this.replace(/[^\x00-\xff]/g,"aa").length;}
应用:计算字符串的长度(一个双字节字符长度计2,ASCII字符计1) String.prototype.len=function(){return this.replace(/[^\x00-\xff] ...
- vue回调函数无法更改model的值
data:{ isUpload:true, } 点击上传函数: getFile(event) { //选择图片 let eventId = event.target.id; let type= tes ...
- Linux上iptables防火墙的基本应用教程
iptables是Linux上常用的防火墙软件,下面vps侦探给大家说一下iptables的安装.清除iptables规则.iptables只开放指定端口.iptables屏蔽指定ip.ip段及解封. ...
- 最佳linux文件WINDOWS上传下载方法
通常,利用SSH管理远程Linux服务器时,经常需要与本地交互文件.当然,我们可以利用FTP方式,比如通过Filezilla客户端软件.不过直接使用SSH软件(SecureCRT.Xshell)自带的 ...
- gradle修改apk包名和apk文件名
需求1:根据渠道不同给包名添加不同的后缀名 方案: //先定义默认包名,用来复用 def packageName = "xxx.xxxx.xxxx" defaultConfig { ...
- 在 Windows 中为高级用户配置 IPv6 的指南
在 Windows 中为高级用户配置 IPv6 的指南 适用于: Windows 10, version 1809Windows Server 2019, all versionsWindows Se ...