《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》,点击传送门,即可获取!
不理解的可以给我留言
3、构建实验
1、安装Mariadb
以下安装均是在controller节点安装
1、安装mariadb 软件包
yum -y install mariadb mariadb-server MySQL-python net-tools vim
2、编辑/etc/yum.cnf 软件,设置绑定IP,默认数据库引擎及默认字符集为UTF-8
[root@controller ~]# vim /etc/my.cnf
[mysqld]
…
…
…
bind-address = 192.168.222.5
default-storage-engine = innodb
innodb_file_per_table
collation-server = utf8_general_ci
init-connect = ‘SET NAMES utf8’
character-set-server = utf8
…
…
3、重启服务
systemctl restart mariadb
systemctl enable mariadb
mysql_secure_installation
2、 安装消息队列
1、功能:协调操作和状态信息服务
2、常用的消息代理软件
RabbitMQ
Qpid
ZeroMQ
3、在controller 节点安装RabbitMQ并配置
[root@controller ~]# yum -y install rabbitmq-server
[root@controller ~]# systemctl enable rabbitmq-server && systemctl start rabbitmq-server
ln -s ‘/usr/lib/systemd/system/rabbitmq-server.service’ ‘/etc/systemd/system/multi-user.target.wants/rabbitmq-server.service’
CREATE DATABASE keystone;
GRANT ALL PRIVILEGES ON keystone.* TO ‘keystone’@‘localhost’ IDENTIFIED BY ‘KEYSTONE_DBPASS’;
GRANT ALL PRIVILEGES ON keystone.* TO ‘keystone’@‘%’ IDENTIFIED BY ‘KEYSTONE_DBPASS’;
生成一个随机值作为管理令牌在初始配置
opensslrand -hex 10:
69ee876515186f15d6e2
安装软件包
yum install openstack-keystone python-keystoneclient
vim /etc/keystone/keystone.conf
[DEFAULT]
…
admin_token= 刚才生成的随机值
[database]
…
connection =mysql://keystone:KEYSTONE_DBPASS@controller.nice.com/keystone
[token]
…
provider = keystone.token.providers.uuid.Providerdriver = keystone.token.persistence.backends.sql.Token
[DEFAULT]
…
verbose = True
4、配置keystone用户、租户、角色()
[root@controller ~]# keystone-manage pki_setup --keystone-user keystone --keystone-group keystone
[root@controller ~]# chown -R keystone:keystone /var/log/keystone/
[root@controller ~]# chown -R keystone:keystone /etc/keystone/ssl/
[root@controller ~]# chmod -R o-rwx /etc/keystone/ssl/
[root@controller ~]# su -s /bin/sh -c “keystone-manage db_sync” keystone
启动identity服务并设置开机启动
[root@controller ~]# systemctl enable openstack-keystone.service
ln -s ‘/usr/lib/systemd/system/openstack-keystone.service’ ‘/etc/systemd/system/multi-user.target.wants/openstack-keystone.service’
[root@controller ~]# systemctl start openstack-keystone.service
计划任务,每小时删除过期的令牌
[root@controller ~]# (crontab-l -u keystone 2>&1 | grep -q token_flush) || echo '@hourly /usr/bin/keystone-manage token_flush>/var/log/keystone/
keystone-tokenflush.log 2>&1’ >> /var/spool/cron/keystone
配置管理员令牌、端点
[root@controller ~]# export OS_SERVICE_TOKEN=69ee876515186f15d6e2
[root@controller ~]# export OS_SERVICE_ENDPOINT=http://controller.nice.com:35357/v2.0
一、创建用于管理的租户,用户和角色
1创建admin租户
[root@controller ~]# keystone tenant-create --name admin --description “Admin Tenant”
±------------±---------------------------------+
| Property | Value |
±------------±---------------------------------+
| description | Admin Tenant |
| enabled | True |
| id | dc4de4d7ecda4ed898b5e0d82809d2ad |
| name | admin |
±------------±---------------------------------+
2创建admin用户
[root@controller ~]# keystone user-create --name admin --pass ADMIN_PASS --email EMAIL_ADDRESS
±---------±---------------------------------+
| Property | Value |
±---------±---------------------------------+
| email | EMAIL_ADDRESS |
| enabled | True |
| id | 4486fd5b469945de95c8b98fc66f4eb5 |
| name | admin |
| username | admin |
±---------±---------------------------------+
3 创建admin角色
[root@controller ~]# keystone role-create --name admin
±---------±---------------------------------+
| Property | Value |
±---------±---------------------------------+
| id | 09f18f69a9ad44648660189411af5448 |
| name | admin |
±---------±---------------------------------+
4添加admin租户和用户到admin角色
[root@controller ~]# keystone user-role-add --tenant admin --user admin --role admin
5创建用于dashboard访问的“member”角色
[root@controller ~]# keystone role-create --name member
±---------±---------------------------------+
| Property | Value |
±---------±---------------------------------+
| id | bec56706ca954a17ab5ffd81e042d7e0 |
| name | member |
±---------±---------------------------------+
6添加admin租户和用户到_member_角色
[root@controller ~]# keystone user-role-add --tenant admin --user admin --role member
二、创建demo进行演示
1创建一个用于演示的demo租户和用户
[root@controller ~]# keystone tenant-create --name demo --description “Demo Tenant”
±------------±---------------------------------+
| Property | Value |
±------------±---------------------------------+
| description | Demo Tenant |
| enabled | True |
| id | ab56bdec367e478cbdfbd1769f9c1649 |
| name | demo |
±------------±---------------------------------+
2创建的demo用户
[root@controller ~]# keystone user-create --name demo --pass DEMO_PASS --email EMAIL_ADDRESS
±---------±---------------------------------+
| Property | Value |
±---------±---------------------------------+
| email | EMAIL_ADDRESS |
| enabled | True |
| id | 47adadf9db2d4ac98c2c9af7a28555bd |
| name | demo |
| username | demo |
±---------±---------------------------------+
3添加demo租户和用户到_member_角色
[root@controller ~]# keystone user-role-add --tenant demo --user demo --role member
三、OpenStack服务业需要一个租户,用户和角色和其他服务进行交互。因此我们创建一个service的租户
[root@controller ~]# keystone tenant-create --name service --description “Service Tenant”
±------------±---------------------------------+
| Property | Value |
±------------±---------------------------------+
| description | Service Tenant |
| enabled | True |
| id | bd2246ec33d5486dac0fc5f55fc4c50c |
| name | service |
±------------±---------------------------------+
四、创建服务实体和API端点
1为identity服务创建一个服务实体
[root@controller ~]# keystone service-create --name keystone --type identity --description “OpenStackIdentity”
±------------±---------------------------------+
| Property | Value |
±------------±---------------------------------+
| description | OpenStackIdentity |
| enabled | True |
| id | a66eb07187a5482d9a591c8b0381e0b9 |
| name | keystone |
| type | identity |
±------------±---------------------------------+
2OpenStack为每个服务提供了三个API端点:admin(管理),internal(内部),public(公共)为identity服务创建API端点
[root@controller ~]# keystone endpoint-create --service-id $(keystone service-list | awk ‘/ identity / {print $2}’) --publicurl http://controller.nice.com:5000/v2.0 --internalurl http://controller.nice.com:5000/v2.0 --adminurl http://controller.nice.com:35357/v2.0 --region regionOne
±------------±--------------------------------------+
| Property | Value |
±------------±--------------------------------------+
| adminurl | http://controller.nice.com:35357/v2.0 |
| id | d25caf7e941d49d4a2a3d0ff98d09f97 |
| internalurl | http://controller.nice.com:5000/v2.0 |
| publicurl | http://controller.nice.com:5000/v2.0 |
| region | regionOne |
| service_id | a66eb07187a5482d9a591c8b0381e0b9 |
±------------±--------------------------------------+
五、确认操作
1、删除OS_SERVICE_TOKEN 和OS_SERVICE_ENDPOINT 临时变量
[root@controller ~]# unset OS_SERVICE_TOKEN OS_SERVICE_ENDPOINT
2、使用admin租户和用户请求认证令牌
[root@controller ~]# keystone --os-tenant-name admin --os-username admin --os-password ADMIN_PASS --os-auth-url http://controller.nice.com:35357/v2.0 token-get
±----------±---------------------------------+
| Property | Value |
±----------±---------------------------------+
| expires | 2020-07-24T11:01:42Z |
| id | f8c98c7983fd46da97208caf4bcac9a8 |
| tenant_id | dc4de4d7ecda4ed898b5e0d82809d2ad |
| user_id | 4486fd5b469945de95c8b98fc66f4eb5 |
±----------±---------------------------------+
3、以admin租户和用户的身份查看租户列表
[root@controller ~]# keystone --os-tenant-name admin --os-username admin --os-password ADMIN_PASS --os-auth-url http://controller.nice.com:35357/v2.0 tenant-list
±---------------------------------±--------±--------+
| id | name | enabled |
±---------------------------------±--------±--------+
| dc4de4d7ecda4ed898b5e0d82809d2ad | admin | True |
| ab56bdec367e478cbdfbd1769f9c1649 | demo | True |
| bd2246ec33d5486dac0fc5f55fc4c50c | service | True |
±---------------------------------±--------±--------+
4、以admin租户和用户的身份查看用户列表
[root@controller ~]# keystone --os-tenant-name admin --os-username admin --os-password ADMIN_PASS --os-auth-url http://controller.nice.com:35357/v2.0 user-list
±---------------------------------±------±--------±--------------+
最后
手绘了下图所示的kafka知识大纲流程图(xmind文件不能上传,导出图片展现),但都可提供源文件给每位爱学习的朋友
《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》,点击传送门,即可获取!
-±--------+
4、以admin租户和用户的身份查看用户列表
[root@controller ~]# keystone --os-tenant-name admin --os-username admin --os-password ADMIN_PASS --os-auth-url http://controller.nice.com:35357/v2.0 user-list
±---------------------------------±------±--------±--------------+
最后
手绘了下图所示的kafka知识大纲流程图(xmind文件不能上传,导出图片展现),但都可提供源文件给每位爱学习的朋友
[外链图片转存中…(img-kIlK1sAY-1714737054146)]
《一线大厂Java面试题解析+核心总结学习笔记+最新讲解视频+实战项目源码》,点击传送门,即可获取!