Keystone组件是云平台上的认证节点。OpenStack各个子项目单独提供着各自的相关服务,如nova提供计算服务,glance提供镜像服务,各个节点互不相干,但实际上组件之间的服务调用都要经过Keystone获取服务列表和服务端点。
1)在controller1创建keystone数据库
```
MariaDB [(none)]> CREATE DATABASE keystone;
```
2)在controller1上创建数据库用户及赋予权限
```
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' IDENTIFIED BY 'yjscloud';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'yjscloud';
```
注意将yjscloud替换为自己的数据库密码
3)在三个节点上分别安装keystone和memcached
```
yum -y install openstack-keystone httpd mod_wsgi python-openstackclient mencached python-memcached openstack-utils
```
4)优化配置memcached
```
vim /etc/sysconfig/memcached
```
```
PORT="11211" #定义端口
USER="memcached" #定义运行memcache的用户
MAXCONN="8192" #定义最大连接数
CACHESIZE="1024" #定义最大内存使用值
OPTIONS="-l 127.0.0.1,::1,10.1.1.150 -t 4 -I 10m" # -l设置服务绑定ip,-t设置线程数,-I调整分配slab页的大小
```
```
scp -p /etc/sysconfig/memcached controller2:/etc/sysconfig/memcached
scp -p /etc/sysconfig/memcached controller3:/etc/sysconfig/memcached
```
**注意!!!OPTIONS中的10.1.1.150改成各个节点对应的IP。**
5)在三个节点上分别启动memcache服务并设置开机启动动
```
systemctl enable memcached.service
systemctl restart memcached.service
systemctl status memcached.service
```
6)配置`/etc/keystone/keystone.conf`文件
```
cp /etc/keystone/keystone.conf /etc/keystone/keystone.conf.bak
>/etc/keystone/keystone.conf
openstack-config --set /etc/keystone/keystone.conf DEFAULT debug false
openstack-config --set /etc/keystone/keystone.conf DEFAULT verbose true
openstack-config --set /etc/keystone/keystone.conf DEFAULT admin_endpoint http://yjscloud.com:35357
openstack-config --set /etc/keystone/keystone.conf DEFAULT public_endpoint http://yjscloud.com:5000
openstack-config --set /etc/keystone/keystone.conf eventlet_server public_bind_host 10.1.1.150
openstack-config --set /etc/keystone/keystone.conf eventlet_server admin_bind_host 10.1.1.150
openstack-config --set /etc/keystone/keystone.conf cache backend oslo_cache.memcache_pool
openstack-config --set /etc/keystone/keystone.conf cache enabled true
openstack-config --set /etc/keystone/keystone.conf cache memcache_servers controller1:11211,controller2:11211,controller3:11211
openstack-config --set /etc/keystone/keystone.conf cache memcache_dead_retry 60
openstack-config --set /etc/keystone/keystone.conf cache memcache_socket_timeout 1
openstack-config --set /etc/keystone/keystone.conf cache memcache_pool_maxsize 1000
openstack-config --set /etc/keystone/keystone.conf cache memcache_pool_unused_timeout 60
openstack-config --set /etc/keystone/keystone.conf catalog template_file /etc/keystone/default_catalog.templates
openstack-config --set /etc/keystone/keystone.conf catalog driver sql
openstack-config --set /etc/keystone/keystone.conf database connection mysql://keystone:yjscloud@yjscloud.com/keystone
openstack-config --set /etc/keystone/keystone.conf database idle_timeout 3600
openstack-config --set /etc/keystone/keystone.conf database max_pool_size 30
openstack-config --set /etc/keystone/keystone.conf database ax_retries -1
openstack-config --set /etc/keystone/keystone.conf database max_overflow 60
openstack-config --set /etc/keystone/keystone.conf identity driver sql
openstack-config --set /etc/keystone/keystone.conf identity caching false
openstack-config --set /etc/keystone/keystone.conf fernet_tokens key_repository /etc/keystone/fernet-keys/
openstack-config --set /etc/keystone/keystone.conf fernet_tokens max_active_keys 3
openstack-config --set /etc/keystone/keystone.conf memcache servers controller1:11211,controller2:11211,controller3:11211
openstack-config --set /etc/keystone/keystone.conf memcache dead_retry 60
openstack-config --set /etc/keystone/keystone.conf memcache socket_timeout 1
openstack-config --set /etc/keystone/keystone.conf memcache pool_maxsize 1000
openstack-config --set /etc/keystone/keystone.conf memcache pool_unused_timeout 60
openstack-config --set /etc/keystone/keystone.conf oslo_messaging_rabbit rabbit_hosts controller1:5672,controller2:5672,controller3:5672
openstack-config --set /etc/keystone/keystone.conf oslo_messaging_rabbit rabbit_userid openstack
openstack-config --set /etc/keystone/keystone.conf oslo_messaging_rabbit rabbit_password yjscloud
openstack-config --set /etc/keystone/keystone.conf oslo_messaging_rabbit rabbit_use_ssl false
openstack-config --set /etc/keystone/keystone.conf oslo_messaging_rabbit rabbit_ha_queues true
openstack-config --set /etc/keystone/keystone.conf oslo_messaging_rabbit rabbit_retry_interval 1
openstack-config --set /etc/keystone/keystone.conf oslo_messaging_rabbit rabbit_retry_backoff 2
openstack-config --set /etc/keystone/keystone.conf oslo_messaging_rabbit rabbit_max_retries 0
openstack-config --set /etc/keystone/keystone.conf token expiration 3600
openstack-config --set /etc/keystone/keystone.conf token caching False
openstack-config --set /etc/keystone/keystone.conf token provider fernet
```
scp到其他节点,注意更改对应的IP,keystone.conf的权限应该为root:keystone
```
scp -p /etc/keystone/keystone.conf controller2:/etc/keystone/keystone.conf
scp -p /etc/keystone/keystone.conf controller3:/etc/keystone/keystone.conf
```
7)配置httpd.conf文件
```
vim /etc/httpd/conf/httpd.conf
```
修改如下配置参数(三个节点都要改):
```
ServerName controller1 #如果是controller2那就写controller2
Listen 8080 #80->8080 haproxy里用了80,不修改启动不了
```
8)配置keystone与httpd结合
```
vim /etc/httpd/conf.d/wsgi-keystone.conf
```
```
Listen 5002
Listen 35358
<VirtualHost *:5002>
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 *:35358>
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>
```
把这个文件拷贝到另外两个节点上;
```
scp -p /etc/httpd/conf.d/wsgi-keystone.conf controller2:/etc/httpd/conf.d/wsgi-keystone.conf
scp -p /etc/httpd/conf.d/wsgi-keystone.conf controller3:/etc/httpd/conf.d/wsgi-keystone.conf
```
9)在controller1上设置数据库同步
```
su -s /bin/sh -c "keystone-manage db_sync" keystone #单行输出的警告信息可以忽略
```
10)三个节点都初始化fernet
```
keystone-manage fernet_setup --keystone-user keystone --keystone-group keystone
keystone-manage credential_setup --keystone-user keystone --keystone-group keystone
```
11)同步三个节点fernet信息,在controller1上操作
```
scp -p /etc/keystone/fernet-keys/* controller2:/etc/keystone/fernet-keys/
scp -p /etc/keystone/fernet-keys/* controller3:/etc/keystone/fernet-keys/
scp -p /etc/keystone/credential-keys/* controller2:/etc/keystone/credential-keys/
scp -p /etc/keystone/credential-keys/* controller3:/etc/keystone/credential-keys/
```
12)三个节点启动httpd,并设置httpd开机启动
```
systemctl enable httpd.service
systemctl restart httpd.service
systemctl status httpd.service
systemctl list-unit-files |grep httpd.service
```
13)在controller1上创建admin用户角色
```
keystone-manage bootstrap \
--bootstrap-password yjscloud \
--bootstrap-username admin \
--bootstrap-project-name admin \
--bootstrap-role-name admin \
--bootstrap-service-name keystone \
--bootstrap-region-id RegionOne \
--bootstrap-admin-url http://yjscloud.com:35357/v3 \
--bootstrap-internal-url http://yjscloud.com:35357/v3 \
--bootstrap-public-url http://yjscloud.com:5000/v3
```
等haproxy列表中的对于服务全部启动时才可以执行下面的命令,否则会报错
这样,就可以在 openstack 命令行里使用 admin 账号登录了。
验证,测试是否已配置合理:
```
openstack project list --os-username admin --os-project-name admin --os-user-domain-id default --os-project-domain-id default --os-identity-api-version 3 --os-auth-url http://yjscloud.com:5000 --os-password yjscloud
```
![8-1-20](http://pded8ke3e.bkt.clouddn.com/8-1-20.png)
14)在controller1创建admin用户环境变量,创建`/root/admin-openrc` 文件并写入如下内容
```
vim /root/admin-openrc
```
添加以下内容:
```
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_DOMAIN_ID=default
export OS_USERNAME=admin
export OS_PROJECT_NAME=admin
export OS_PASSWORD=yjscloud
export OS_IDENTITY_API_VERSION=3
export OS_AUTH_URL=http://yjscloud.com:35357/v3
```
```
scp -p /root/admin-openrc controller2:/root/admin-openrc
scp -p /root/admin-openrc controller3:/root/admin-openrc
openstack endpoint list #查看endpoint,正常情况下是有三个keystone的endpoint
```
15)在controller1上创建service项目
```
source /root/admin-openrc
openstack project create --domain default --description "Service Project" service
```
16)在controller1上创建demo项目
```
openstack project create --domain default --description "Demo Project" demo
```
17)在controller1上创建demo用户
```
openstack user create --domain default demo --password yjscloud
# 注意:yjscloud为demo用户密码
```
![8-1-21](http://pded8ke3e.bkt.clouddn.com/8-1-21.jpg)
18)在controller1创建user角色将demo用户赋予user角色
```
openstack role create user
openstack role add --project demo --user demo user
openstack user list #查看用户
```
![8-1-22](http://pded8ke3e.bkt.clouddn.com/8-1-22.jpg)
19)在controller1上验证keystone
```
unset OS_TOKEN OS_URL
openstack --os-auth-url http://yjscloud.com:35357/v3 --os-project-domain-name default --os-user-domain-name default --os-project-name admin --os-username admin token issue --os-password yjscloud
openstack --os-auth-url http://yjscloud.com:5000/v3 --os-project-domain-name default --os-user-domain-name default --os-project-name demo --os-username demo token issue --os-password yjscloud
````
![8-1-23](http://pded8ke3e.bkt.clouddn.com/8-1-23.jpg)
20)在controller1上创建demo用户环境变量,创建`/root/demo-openrc`文件并写入下列内容:
```
export OS_USER_DOMAIN_ID=default
export OS_PROJECT_DOMAIN_ID=default
export OS_USERNAME=demo
export OS_PROJECT_NAME=demo
export OS_PASSWORD=yjscloud
export OS_IDENTITY_API_VERSION=3
export OS_AUTH_URL=http://yjscloud.com:35357/v3
```
- 献给我的朋友们
- 一、个人对学习的看法
- 二、运维技能图谱
- 三、运维常用技能
- 3.1 Vim(最好用的编辑器)
- 3.2 Nginx & Tengine(Web服务)
- 1. Nginx介绍和部署
- 2. Nginx配置解析
- 3. Nginx常用模块
- 4. Nginx 的session 一致性问题
- 3.3 Tomcat(Web中间件)
- 3.4 Keepalived(负载均衡高可用)
- 3.5 Memcache(分布式缓存)
- 3.6 Zookeeper(分布式协调系统)
- 3.7 KVM(开源虚拟化)
- 1. 虚拟化介绍
- 2. KVM基础
- 3. 设置VNC和时间同步
- 4. kvm虚拟机快照备份
- 5. kvm虚拟机在线扩展磁盘
- 6. kvm虚拟机静态迁移
- 7. kvm虚拟机动态迁移
- 8. kvm虚拟机存储池配置
- 9. cpu添加虚拟化功能
- 3.8 GitLab(版本控制)
- 3.8.1 GitLab安装与汉化
- 3.9 Jenkins(运维自动化)
- 3.10 WAF(Web防火墙)
- 3.10.1初探WAF
- 四、常用数据库
- 4.1 MySQL(关系型数据库)
- 1. MySQL源码安装
- 4.2 Mongodb(适用与大数据分析的数据库)
- 4.3 Redis(非关系数据库)
- 五、自动化运维工具
- 5.1 Cobbler(系统自动化部署)
- 5.2 Ansible(自动化部署)
- 5.3 Puppet(自动化部署)
- 5.4 SaltStack(自动化运维)
- 六、存储
- 6.1 GFS(文件型存储)
- 6.2 Ceph(后端存储)
- 七、运维监控工具
- 7.1 对监控的理解
- 7.2 Zabbix(运维监控)
- 7.2.1 Zabbix简介
- 7.2.2 Zabbix服务部署
- 1. Zabbix服务端部署
- 2. Zabbix客服端部署
- 3. 配置前端展示
- 4. zabbix告警配置
- 7.2.3 Zabbix监控服务
- 1. 监控网络设备
- 2. 自定义Nginx监控
- 7.3 云镜(安全监控)
- 7.4 ELK(日志收集展示)
- 八、运维云平台
- 8.1 OpenStack(开源云操作系统)
- 8.1.1 OpenStack简介
- 8.1.2 实验架构设计
- 8.1.3 集群环境准备
- 8.1.4 controller节点部署
- 1. 安装Mariadb Galera Cluster集群
- 2. 安装RabbitMQ Cluster集群
- 3. 安装Pacemaker
- 4. 安装HAProxy
- 5. 安装配置Keystone
- 6. 安装配置glance
- 1. 制作镜像模板
- 7. 安装配置nova
- 8. 安装配置neutron
- 1. 配置虚拟机网络
- 9. 安装Dashboard
- 10. 安装配置cinder
- 8.1.5 compute节点部署
- 1. 安装相关软件包
- 2. 安装Neutron
- 3. 配置cinder
- 4. 创建第一个虚拟机
- 8.1.6 OpenStack报错处理
- 1. cinder僵尸卷删除
- 8.1.7 快速孵化虚拟机方案
- 8.1.8 Kolla容器化部署OpenStack
- 1. 单点部署
- 2. 多节点部署
- 8.2 Tstack(腾讯云平台)
- 8.3 K8s(微服务容器化)
- 九、运维编程技能
- 9.1 Shell(运维必会语言)
- 9.2 Python(万能的胶水语言)
- 十、Devops运维
- 10.1 理念
- 10.2 Devops实战