【openstack N版】——创建云主机

一.启动实例

1.1 已准备服务介绍

  • MySql:为各个服务提供数据存储。
  • RabbitMQ:为各个服务之间通信提供交通枢纽。
  • keystone:为各个服务之间通信提供认证和服务注册。
  • Glance:为虚拟机提供镜像管理。
  • Nova:为虚拟机提供计算资源。
  • Neutron:为虚拟机提供网络资源。

1.2 网络(flat)

1.2.1创建虚拟网络
1 #share 允许所有项目使用虚拟网络
2 [[email protected] ~]# openstack network create  --share 3 --provider-physical-network public 4 --provider-network-type flat public+---------------------------+--------------------------------------+| Field                     | Value                                |+---------------------------+--------------------------------------+| admin_state_up            | UP                                   || availability_zone_hints   |                                      || availability_zones        |                                      || created_at                | 2017-03-01T03:10:38Z                 || description               |                                      || headers                   |                                      || id                        | 0cdd6694-d53d-4f85-b04a-bc3b6dfa6cbc || ipv4_address_scope        | None                                 || ipv6_address_scope        | None                                 || mtu                       | 1500                                 || name                      | public                               || port_security_enabled     | True                                 || project_id                | d24a61dd3ecb43cb9e8a5f6539c6a2bb     || project_id                | d24a61dd3ecb43cb9e8a5f6539c6a2bb     || provider:network_type     | flat                                 || provider:physical_network | public                               || provider:segmentation_id  | None                                 || revision_number           | 3                                    || router:external           | Internal                             || shared                    | True                                 || status                    | ACTIVE                               || subnets                   |                                      || tags                      | []                                   || updated_at                | 2017-03-01T03:10:38Z                 |+---------------------------+--------------------------------------+
1.2.2查看已创建网络
1 #新版本命令
2 [[email protected] ~]# openstack network list
3 #老版本命令
4 [[email protected] ~]# neutron net-list
5 #结果都是一样的+--------------------------------------+--------+---------+| ID                                   | Name   | Subnets |+--------------------------------------+--------+---------+| 0cdd6694-d53d-4f85-b04a-bc3b6dfa6cbc | public |         |+--------------------------------------+--------+---------+
1.2.3创建子网
 1 #创建子网
 2 [[email protected] ~]# openstack subnet create --network public  3 --allocation-pool start=192.168.56.100,end=192.168.56.200  4 --dns-nameserver 192.168.56.2 --gateway 192.168.56.2  5 --subnet-range 192.168.56.0/24 public-subnet
 6 #注解
 7 public:是之前配置文件中flat_networks自定义的名称
 8 start:dhcp起始地址
 9 end:dhcp终止地址
10 nameserver:DNS
11 gateway:网关
12 subnet:网段/子网
13 public-subnet:子网名称+-------------------+--------------------------------------+| Field             | Value                                |+-------------------+--------------------------------------+| allocation_pools  | 192.168.56.100-192.168.56.200        || cidr              | 192.168.56.0/24                      || created_at        | 2017-03-01T03:12:36Z                 || description       |                                      || dns_nameservers   | 192.168.56.2                         || enable_dhcp       | True                                 || gateway_ip        | 192.168.56.2                         || headers           |                                      || host_routes       |                                      || id                | 3b307841-211f-4c8e-91f5-a9f051bb1248 || ip_version        | 4                                    || ipv6_address_mode | None                                 || ipv6_ra_mode      | None                                 || name              | public-subnet                        || network_id        | 0cdd6694-d53d-4f85-b04a-bc3b6dfa6cbc || project_id        | d24a61dd3ecb43cb9e8a5f6539c6a2bb     || project_id        | d24a61dd3ecb43cb9e8a5f6539c6a2bb     || revision_number   | 2                                    || service_types     | []                                   || subnetpool_id     | None                                 || updated_at        | 2017-03-01T03:12:36Z                 |+-------------------+--------------------------------------+
1.2.4检查子网
1 #新版本命令
2 [[email protected] ~]# openstack subnet list+--------------------------------------+---------------+--------------------------------------+-----------------+| ID                                   | Name          | Network                              | Subnet          |+--------------------------------------+---------------+--------------------------------------+-----------------+| 3b307841-211f-4c8e-91f5-a9f051bb1248 | public-subnet | 0cdd6694-d53d-4f85-b04a-bc3b6dfa6cbc | 192.168.56.0/24 |+--------------------------------------+---------------+--------------------------------------+-----------------+
3 #老版本命令
4 [[email protected] ~]# neutron subnet-list+--------------------------------------+---------------+-----------------+------------------------------------------------------+| id                                   | name          | cidr            | allocation_pools                                     |+--------------------------------------+---------------+-----------------+------------------------------------------------------+| 3b307841-211f-4c8e-91f5-a9f051bb1248 | public-subnet | 192.168.56.0/24 | {"start": "192.168.56.100", "end": "192.168.56.200"} |+--------------------------------------+---------------+-----------------+------------------------------------------------------+

1.3创建云主机类型

1 #先创建一个小的云主机类型,给官方提供镜像做测试
2 [[email protected] ~]# openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano
3 #注解
4 id:主机类型ID
5 vcpus:虚拟cpu数量
6 ram:虚拟内存大小(MB)
7 disk:虚拟磁盘大小(GB)
8 m1.nano:主机类型名称(可随便更改)+----------------------------+---------+| Field                      | Value   |+----------------------------+---------+| OS-FLV-DISABLED:disabled   | False   || OS-FLV-EXT-DATA:ephemeral  | 0       || disk                       | 1       || id                         | 0       || name                       | m1.nano || os-flavor-access:is_public | True    || properties                 |         || ram                        | 64      || rxtx_factor                | 1.0     || swap                       |         || vcpus                      | 1       |+----------------------------+---------+
1.3.1查看云主机类型
1 [[email protected] ~]# openstack flavor list+----+---------+-----+------+-----------+-------+-----------+| ID | Name    | RAM | Disk | Ephemeral | VCPUs | Is Public |+----+---------+-----+------+-----------+-------+-----------+| 0  | m1.nano |  64 |    1 |         0 |     1 | True      |+----+---------+-----+------+-----------+-------+-----------+

1.4创建秘钥对

1 #创建ssh的秘钥对
2 [[email protected] ~]# ssh-keygen -q -N ""
3 #直接敲回车
4 Enter file in which to save the key (/root/.ssh/id_rsa):
5 #用openstack使用此秘钥对
6 [[email protected] ~]# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey+-------------+-------------------------------------------------+| Field       | Value                                           |+-------------+-------------------------------------------------+| fingerprint | f9:81:41:cc:48:f0:69:37:34:a6:52:08:6f:60:28:14 || name        | mykey                                           || user_id     | 45b086bdc6b746c5b0bfd62f779fe6a5                |+-------------+-------------------------------------------------+
1.4.1查看键值对
1 [[email protected] ~]#  openstack keypair list+-------+-------------------------------------------------+| Name  | Fingerprint                                     |+-------+-------------------------------------------------+| mykey | f9:81:41:cc:48:f0:69:37:34:a6:52:08:6f:60:28:14 |+-------+-------------------------------------------------+

1.5创建安全组规则

1 #开启icmp协议,允许ping
2 [[email protected] ~]# openstack security group rule create --proto icmp default+-------------------+--------------------------------------+| Field             | Value                                |+-------------------+--------------------------------------+| created_at        | 2017-03-01T03:49:22Z                 || description       |                                      || direction         | ingress                              || ethertype         | IPv4                                 || headers           |                                      || id                | 044c66be-4db9-4f8c-8b6f-59c02c0c962c || port_range_max    | None                                 || port_range_min    | None                                 || project_id        | d24a61dd3ecb43cb9e8a5f6539c6a2bb     || project_id        | d24a61dd3ecb43cb9e8a5f6539c6a2bb     || protocol          | icmp                                 || remote_group_id   | None                                 || remote_ip_prefix  | 0.0.0.0/0                            || revision_number   | 1                                    || security_group_id | a9c0f076-3e8a-4344-ad7b-e94b51798116 || updated_at        | 2017-03-01T03:49:22Z                 |+-------------------+--------------------------------------+
3 #开启22端口,允许ssh
4 [[email protected] ~]# openstack security group rule create --proto tcp --dst-port 22 default+-------------------+--------------------------------------+| Field             | Value                                |+-------------------+--------------------------------------+| created_at        | 2017-03-01T03:50:33Z                 || description       |                                      || direction         | ingress                              || ethertype         | IPv4                                 || headers           |                                      || id                | 6b48884c-dfc5-444c-8fb2-4ec157945e4e || port_range_max    | 22                                   || port_range_min    | 22                                   || project_id        | d24a61dd3ecb43cb9e8a5f6539c6a2bb     || project_id        | d24a61dd3ecb43cb9e8a5f6539c6a2bb     || protocol          | tcp                                  || remote_group_id   | None                                 || remote_ip_prefix  | 0.0.0.0/0                            || revision_number   | 1                                    || security_group_id | a9c0f076-3e8a-4344-ad7b-e94b51798116 || updated_at        | 2017-03-01T03:50:33Z                 |+-------------------+--------------------------------------+
1.5.1查看安全组规则
1 [[email protected] ~]# openstack security group list+--------------------------------------+---------+------------------------+----------------------------------+| ID                                   | Name    | Description            | Project                          |+--------------------------------------+---------+------------------------+----------------------------------+| a9c0f076-3e8a-4344-ad7b-e94b51798116 | default | Default security group | d24a61dd3ecb43cb9e8a5f6539c6a2bb |+--------------------------------------+---------+------------------------+----------------------------------+

1.6启动虚拟机

 1 #启动之前首先要查看网络ID并记下
 2 [[email protected] ~]# openstack network list+--------------------------------------+--------+--------------------------------------+| ID                                   | Name   | Subnets                              |+--------------------------------------+--------+--------------------------------------+| 0cdd6694-d53d-4f85-b04a-bc3b6dfa6cbc | public | 3b307841-211f-4c8e-91f5-a9f051bb1248 |+--------------------------------------+--------+--------------------------------------+
 3 #创建虚拟机,并启动
 4 [[email protected] ~]# openstack server create --flavor m1.nano --image cirros  5    --nic net-id=0cdd6694-d53d-4f85-b04a-bc3b6dfa6cbc --security-group default  6    --key-name mykey demo-instance
 7 #注:如果只有一个网络,则不需要填写net-id,openstack会默认选择
 8 #注解
 9 flavor:云主机类型名称
10 image:镜像名称
11 nic net-id:网络ID
12 security-group:安全组
13 key-name:秘钥对
14 demo-instance:云主机名称
1.6.1查看云主机
1 [[email protected] ~]# openstack server list+--------------------------------------+---------------+--------+-----------------------+------------+| ID                                   | Name          | Status | Networks              | Image Name |+--------------------------------------+---------------+--------+-----------------------+------------+| 24202ab8-9f13-4555-b8e3-6ff799223e67 | demo-instance | ACTIVE | public=192.168.56.110 | cirros     |+--------------------------------------+---------------+--------+-----------------------+------------+

1.7获取VNC的url

1 [[email protected] ~]# openstack console url show demo-instance+-------+------------------------------------------------------------------------------------+| Field | Value                                                                              |+-------+------------------------------------------------------------------------------------+| type  | novnc                                                                              || url   | http://192.168.56.11:6080/vnc_auto.html?token=844e8352-a2ca-4c3f-8690-753529d59b80 |+-------+------------------------------------------------------------------------------------+
1.71访问VNC的url

打开浏览器输入:http://192.168.56.11:6080/vnc_auto.html?token=844e8352-a2ca-4c3f-8690-753529d59b80即可访问

注:以上操作,完全可以在dashboard上创建

二.创建云主机流程介绍

2.1创建云主机步骤

第一步:dashboard或者client带着用户名和密码请求keystone服务

第二步:keystone服务验证用户名和密码,验证成功后返回token给dashboard或者client

第三步:dashboard或者client带着keystone服务返回的token请求nova-api

第四步:nova-api带着token访问keystone服务验证token是否正确

第五步:keystone验证token正确后,返回结果给nova-api

第六步:nova-api将要创建的虚拟机资源信息写入DB

第七步:nova-api将要创建虚拟机的请求写入rabbitMQ消息队列,建立沟通枢纽

第八步:nova-scheduler发现消息队列中的创建虚拟机信息后访问DB

第九步:nova-scheduler从DB中获取到创建虚拟机所需资源并且计算,调度,决定将虚拟机创建在哪个计算节点上

第十步:将计算结果返回给消息队列

第十一步:nova-compute从消息队列中获取nova-scheduler计算的结果

第十二步:nova-compute通过nova-conductor(中间件)与DB交互来获取要创建的虚拟机所需要的资源信息

第十三步:nova-compute带着token去请求glance获取镜像资源,glance会将token交给keystone服务验证

第十四步:如果token验证成功,则将glance的镜像资源交给nova-compute

第十五步:nova-compute带着token去请求neutron获取网络资源,neutron会将token交给keystone服务验证

第十六步:如果token验证成功,则将neutron的网络资源交给nova-compute

第十七步:nova-compute带着token去请求cinder获取存储资源,cinder会将token交给keystone服务验证

第十八步:如果token验证成功,则将cinder的存储资源交给nova-compute

所有步骤都操作成功后,nova-compute就会将虚拟机创建在scheduler计算后的节点上。

2.2创建云主机流程图

【开源是一种精神,分享是一种美德】

— By GoodCook

— 笔者QQ:253097001

— 欢迎大家随时来交流

—原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。

时间: 2024-10-25 07:48:14

【openstack N版】——创建云主机的相关文章

Openstack创建云主机的流程-小小白(linuxzkq)

博主自从之前换了工作到现在,因为工作太忙的原因,已经好久没有更新博客了,深表歉意,还望大家理解...... 今天正好有点时间,整理下Openstack创建云主机的流程,大神勿喷. 一.流程图 二.虚拟机创建流程如下 客户(用户)端通过命令行CLI或Dashboard Horizon使用自己的用户名密码请求认证组件keystone进行用户的验证: keystone通过查询在keystone的数据库user表中是否存在user的相关信息,包括password加密后的hash值,并返回一个token_

Openstack之路(六)创建云主机实例

创建云主机网络 在控制节点上,加载admin凭证来获取管理员能执行的命令访问权限 [[email protected] ~]# source admin-openrc 创建网络 [[email protected] ~]# openstack network create --share --external --provider-physical-network provider --provider-network-type flat provider +------------------

Openstack之路(八)创建云主机镜像

准备CentOS-7.x镜像,可以从网上直接下载,我这里准备的镜像是CentOS-7.2-x86_64 [[email protected] ~]# ls -l /tmp/CentOS-7-x86_64-DVD-1511.iso -rw-r--r-- 1 root root 4329570304 Jan 7 2016 /tmp/CentOS-7-x86_64-DVD-1511.iso 安装相关软件 [[email protected] ~]# yum -y install qemu-kvm li

Ceph与OpenStack整合(仅为云主机提供云盘功能)

1. Ceph与OpenStack整合(仅为云主机提供云盘功能) 创建: linhaifeng,最新修改: 大约1分钟以前 ceph ceph osd pool create volumes 128 128 ceph auth get-or-create client.cinder mon 'allow r' osd 'allow class-read object_prefix rbd_children, allow rwx pool=volumes, allow rwx pool=vms,

openstack 调用API 实现云主机的IO 控制,CGroup 策略

# vim: tabstop=4 shiftwidth=4 softtabstop=4 # Copyright (c) 2011 X.commerce, a business unit of eBay Inc. # Copyright 2010 United States Government as represented by the # Administrator of the National Aeronautics and Space Administration. # All Righ

zstack 创建云主机 (三)

扁平网络 Flat Network 1. 介绍 扁平网络在私有云网络环境中非常的流行.它的网络拓扑很简单,所有的云主机都是直接接在公司内部的一个大二层的网络上.扁平网络也非常容易搭建.由于所有的云主机和物理主机都在一个二层广播域,在这个二层网络上的云主机可以通过数据中心的核心路由器链接到Internet.在这个教程里,我们假定您拥有一个可以访问Internet的IP网络. 2. 前提 我们假定您已经根据安装手册里的方法成功的安装并且启动了ZStack.您可以在Chrome浏览器或者FireFox

使用aliyun cli工具快速创建云主机

参考文档: https://help.aliyun.com/document_detail/25484.html?spm=a2c4g.11186623.3.2.b57vQp 步骤 创建AccessID 下载aliyun-cli工具 建议整 golang 版本, 一个二进制,没有任何依赖 配置AccessID 还是前面那个链接,配置阿里云CLI段落 创建云主机(创建后是未启动状态) 指令 aliyun ecs CreateInstance --ImageId="ubuntu_16_0402_64_

openstack Queens版企业云自动化部署(openvswith+vxlan)

openstack开源社区最新版本Q版本相比之前版本增加了许多新的功能,例如地址中继,集群,以及负载均衡在dashboard中做了集成,网络方面相比之前做了很大的变化,所以很多小伙版在安装的时候在网络地方出怎么配置浮动地址就是不能使用,还有的小伙伴安装之后无法给云主机挂载数据卷,以及云主机无法动态的调整,鉴于这些问题 先上线了一个openvswitch+vxlan网络模式的课程,喜欢的小伙伴可以速来围观.视频地址:http://edu.51cto.com/course/14799.html 原文

Openstack新建云主机的流程

前言 前天晚上没睡觉,所以昨天睡得很早,导致今天4点就起来了 时间是人最宝贵的财富,于是我打消了钻在被子里刷剧的念头,爬起来整理一下在Openstack中新建一个云主机的流程. Openstack可以让你在登录dashboard之后只需要点一下"创建主机"的按钮,选择相应配置,在几十秒内就可以创建好一台云主机供你使用,这么牛逼的事情是怎么做到的呢? 别着急,听我跟你慢慢道来 新建一个云主机流程总览图 图中流程-1 首先你访问dashboard之后,显示的是一个登录页面,人家horizo