OpenStack组件介绍
KeyStone (OpenStack Identity Service)
Keystone(OpenStackIdentity Service)是OpenStack框架中,负责身份验证、服务规则和服务 令牌的功能,它实现了OpenStack的Identity
API。
Keystone可以分解为两个核心功能,单点登录和服务发现。Keystone类似一个服务总线,或者说是
整个Openstack框架的注册表,其他服务通过Keystone来注册其服务的Endpoint(服务访问的 URL)
,任何服务之间相互的调用,都需要经过Keystone的身份验证,以获得目标服务的Endpoint 来找到目标服务。
keystone组件基本概念
User
Tenant
Role
Service
(nova
,glance
,swift
等服务需要在keystone
上注册)Endpoint
(service
暴露出来的访问地址)Token
(访问资源的令牌,具有时效性)
keystone在创建vm访问流程示例
keystone常用命令介绍
查看
Tenant/Project
列表1
keystone tenant-list
创建一个
租户
,指定名字$TenantName
$ keystone tenant-create --name $TenantName
1
2
3
4
5
* 删除一个`tanant`,需指定`tenant id`
* ```shell
$ keystone tenant-delete $TenantName列出所有角色
$ keystone role-list
1
2
3
4
5
* 创建角色,角色名为`$RoleName`
* ```shell
$ keystone role-create --name $RoleName将指定用户
$UserName
以指定的角色$RoleName
(通过$ keystone role-list
获得), 加入指定$ TenantName
(
通过keystone tenant-list
获得)1
keystone user-role-add --user $UserName --role $RoleName --tenant $TenantName
创建某一个
tenant
下的用户# 使用tenant_id keystone tenant-list 查看tenant_id keystone user-create --name $UserName --tenant $TenantID --pass $PassWrod --emai $UserEmail
1
2
3
4
5
* 查看用户列表
* ```shell
$ keystone user-list获取用户详细信息,需要先获取
user_id
,然后指定tenant_id
$ keystone user-get $UserID
1
2
3
4
5
* 更新用户名密码
* ```Shell
$ keystone user-password-update --pass $NewPassword $UserName查看服务注册信息
$ keystone service-list
1
2
3
4
5
* 查看服务访问路径
```shell
$ keystone endpoint-list
keystone服务及日志
启动KeyStone
服务
1 | systemctl status openstack-keystone |
keystone
日志存放位置
1 | /var/log/keystone/keystone.log |
nova(OpenStack Compute Service)
组件基本概念介绍
server
(instance
)
Flavor
Image
rebuild
: remove all data on the server and replace it with the specified image.the server id and ip address remain
the same
resize
: converts an existing server to a different flavor
nova相关服务介绍
- nova-api: 负责接受和响应终端用户有关虚拟机和云硬盘的请求,
nova-api
是整个nova
的入口。它
接受用户请求,将指令发送至消息队列,由相应的服务执行相关的指令消息。 - nova-conductor: 提供数据库访问和其他
Openstack
服务方法,处理不同版本的服务的兼容性问题,
同时处理需要长时间处理的情况,如instance
在线迁移等。 - nova-scheduler: 通过追踪资源使用情况,提供完成
request
的最佳的host
。*( This service provides compute request
scheduling by tracking available resources, and finding the host that can best fulfill the request)* - nova-compute: 是主要的执行守护进程,职责是基于各种虚拟化技术
Hyperivisor
实现创建和终止 虚拟机。nova-compute
有两个工作,接受消息队列中的执行指令,并执行相关指令,如部署虚拟机。 维护数据库相关模型的状态数据。
Nova
架构
虚拟机创建过程
nova-api
对外统一提供标准化接口,各子模块,如计算资源,存储资源和网络资源子模块通过相应的API
接口服务对外提供服务。
- Dashboard or CLI gets the user credential and does the REST call to Keystone for authentication.
- Keystone authenticate the credentials and generate & send back auth-token which will be used for sending
request to other Components through REST-call.- Dashboard or CLI convert the new instance request specified in ‘launch instance’ or ‘nova-boot’ form to
REST API request and send it to nova-api.- nova-api receive the request and sends the request for validation auth-token and access permission to *
keystone*.- Keystone validates the token and sends updated auth headers with roles and permissions.
- nova-api interacts with nova-database.
- Creates initial db entry for new instance.
- nova-api sends the rpc.call request to nova-scheduler excepting to get updated instance entry with host
ID specified.- nova-scheduler picks the request from the queue.
- nova-scheduler interacts with nova-database to find an appropriate host via filtering and weighing.
- Returns the updated instance entry with appropriate host ID after filtering and weighing.
- nova-scheduler sends the rpc.cast request to nova-compute for ‘launching instance’ on appropriate host .
- nova-compute picks the request from the queue.
- nova-compute send the rpc.call request to nova-conductor to fetch the instance information such as host
ID and flavor( Ram , CPU ,Disk).- nova-conductor picks the request from the queue.
- nova-conductor interacts with nova-database.
- Return the instance information.
- nova-compute picks the instance information from the queue.
- nova-compute does the REST call by passing auth-token to glance-api to get the Image URI by Image ID from
glance and upload image from image storage.- glance-api validates the auth-token with keystone.
- nova-compute get the image metadata.
- nova-compute does the REST-call by passing auth-token to Network API to allocate and configure the network
such that instance gets the IP address.- quantum-server validates the auth-token with keystone.
- nova-compute get the network info.
- nova-compute does the REST call by passing auth-token to Volume API to attach volumes to instance.
- cinder-api validates the auth-token with keystone.
- nova-compute gets the block storage info.
- nova-compute generates data for hypervisor driver and executes request on Hypervisor( via libvirt or **api
**).The table represents the Instance state at various steps during the provisioning :
Status Task Power state Steps Build scheduling None 3-12 Build networking None 22-24 Build block_device_mapping None 25-27 Build spawing None 28 Active none Running
vm状态的介绍
Initialized(building)
:初始化,虚拟机在准备创建active
:虚拟机运行中Paused
:虚拟机暂停,依然占用计算和内存资源Suspended
:虚拟机挂起,不占用计算和内存资源Stop
: 虚拟机停止运行Resized
: 虚拟机在源节点停止,在目标结点运行
nova命令行介绍
1 | 查看Nova服务列表 |
nova日志的查看
1 | Nova日志目录 |
Glance( OpenStack Image Service)
什么是Glance
glance
即image service
(镜像服务),是为虚拟机的创建提供镜像服务
为什么要有Glance?
基于openstack
是构建基本的Iaas
平台对外提供虚机,而虚机在创建的时候必须为其选择操作系统,glance
服务器就是为该选择提供不同的系统镜像
功能
glance
服务使用户能够发现,注册,检索虚拟机的镜像,它提供一个能够查询虚拟机镜像元数据和检索真实镜像的REST API
具体的,REST API
的体现就是一个URI
,而在glance
中通过一个URI
地址来唯一标示一个镜像的形式如 下:
1 |
|
glance命令介绍
1 | 创建一个镜像 |
glance日志查看
镜像服务Glance的日志默认存放在/var/log/glance目录中
1 | Glance API相关的日志 |
Neutron(OpenStack Network Service)
neutron基本概念介绍
传统的网络管理方式很大程度上依赖于管理员手工配置和维护各种网络硬件设备;而云环境下的网络
已经变得非常复杂,特别是在多租户场景里,用户随时都可能需要创建、修改和删除网络,网络的连 通性和隔离已经不太可能通过手工配置来保证了。
如何快速响应业务的需求对网络管理提出了更高的要求。传统的网络管理方式已经很难胜任这项工作,
而“软件定义网络(software-defined networking
, SDN
)”所具有的灵活性和自动化优势使其成为 云时代网络管理的主流。
网络服务Neutron
的设计目标是实现“网络即服务(Networking as a Service
)”。为了达到这一目标,在设 计上遵循了基于 SDN
实现网络虚拟化的原则,在实现上充分利用了Linux
系统上的各种网络相关的技术。
网络服务Neutron
为整个OpenStack
环境提供网络支持,包括
- 二层交换
- 三层路由
- 负载均衡
- 防火墙
- VPN
- etc…
Neutorn的常用命令
1 | 列出当前租户所有的网络: |
neutron查看日志
网络服务Neutron的日志默认存放在/var/log/neutron目录中
1 | 关于dhcp-agent的日志 |
参考资料
OpenStack组件介绍