创建过程

  1. 创建虚拟网络
  2. 创建m1.nano规格的主机(相等于定义虚拟机的硬件配置)
  3. 生成一个密钥对(openstack的原理是不使用密码连接,而是使用密钥对进行连接)
  4. 增加安全组规则(用iptables做的安全组)
  5. 启动一个实例(启动虚拟机有三种类型:1.命令CLI 2.api 3.Dashboard)实际上Dashboard也是通过api进行操作
  6. 虚拟网络分为提供者网络和私有网络,提供者网络就是跟主机在同一个网络里,私有网络自定义路由器等,跟主机不在一个网络

一.)创建网络

1.1.节点操作,创建网络

[root@controller ~]# source admin-openrc 

[root@controller ~]# neutron net-create --shared --provider:physical_network provider --provider:network_type flat public-net
Created a new network:
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | True |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2018-04-13T12:03:41Z |
| description | |
| id | c7e2a252-775d-48e1-a748-11089994f455 |
| ipv4_address_scope | |
| ipv6_address_scope | |
| mtu | 1500 |
| name | public-net |
| port_security_enabled | True |
| project_id | 24a37179b1844e8897e77a0c44cc8d25 |
| provider:network_type | flat |
| provider:physical_network | provider |
| provider:segmentation_id | |
| revision_number | 3 |
| router:external | False |
| shared | True |
| status | ACTIVE |
| subnets | |
| tags | |
| tenant_id | 24a37179b1844e8897e77a0c44cc8d25 |
| updated_at | 2018-04-13T12:03:41Z |
+---------------------------+--------------------------------------+

上图中tenant_id 等于 project_id,查看项目列表如下图

[root@controller ~]# openstack project list

+----------------------------------+---------+
| ID | Name |
+----------------------------------+---------+
| 24a37179b1844e8897e77a0c44cc8d25 | admin |
| a1c365af1dcb4811a96d10381d3b5606 | service |
| dece6a569ea74a43a50119d04edec8c8 | demo |
+----------------------------------+---------

1.2 检查是否创建成功

[root@controller ~]# neutron net-list
+--------------------------------------+------------+---------+
| id | name | subnets |
+--------------------------------------+------------+---------+
| c7e2a252-775d-48e1-a748-11089994f455 | public-net | |
+--------------------------------------+------------+---------+

  

1.3 创建子网

[root@controller ~]# neutron subnet-create --name public-subnet \
> --allocation-pool start=10.0.0.100,end=10.0.0.200 \
> --dns-nameserver 233.5.5.5 --gateway 10.0.0.2 \
> public-net 10.0.0.0/24
Created a new subnet:
+-------------------+----------------------------------------------+
| Field | Value |
+-------------------+----------------------------------------------+
| allocation_pools | {"start": "10.0.0.100", "end": "10.0.0.200"} |
| cidr | 10.0.0.0/24 |
| created_at | 2018-04-13T12:08:37Z |
| description | |
| dns_nameservers | 233.5.5.5 |
| enable_dhcp | True |
| gateway_ip | 10.0.0.2 |
| host_routes | |
| id | 4c5d0667-f711-4eb1-a750-0ae4143976b9 |
| ip_version | 4 |
| ipv6_address_mode | |
| ipv6_ra_mode | |
| name | public-subnet |
| network_id | c7e2a252-775d-48e1-a748-11089994f455 |
| project_id | 24a37179b1844e8897e77a0c44cc8d25 |
| revision_number | 2 |
| service_types | |
| subnetpool_id | |
| tenant_id | 24a37179b1844e8897e77a0c44cc8d25 |
| updated_at | 2018-04-13T12:08:37Z |
+-------------------+----------------------------------------------+

 参数说明

neutron subnet-create 子网创建
--name (名称)
--allocation—pool 分配地址池
start=开始IP地址
end=结束IP地址
dns-nameserver DNS地址,233.5..5是阿里公共DNS地址
--gateway 网关
public-net 提供者的网络名称(要跟上面创建网络的名称对应起来)

1.4 检查是否关联成功

[root@controller ~]# neutron net-list

+--------------------------------------+------------+--------------------------------------------------+
| id | name | subnets |
+--------------------------------------+------------+--------------------------------------------------+
| c7e2a252-775d-48e1-a748-11089994f455 | public-net | 4c5d0667-f711-4eb1-a750-0ae4143976b9 10.0.0.0/24 |
+--------------------------------------+------------+--------------------------------------------------+
[root@controller ~]#
[root@controller ~]# neutron subnet-list
+--------------------------------------+---------------+-------------+----------------------------------------------+
| id | name | cidr | allocation_pools |
+--------------------------------------+---------------+-------------+----------------------------------------------+
| 4c5d0667-f711-4eb1-a750-0ae4143976b9 | public-subnet | 10.0.0.0/24 | {"start": "10.0.0.100", "end": "10.0.0.200"} |
+--------------------------------------+---------------+-------------+----------------------------------------------+

  

1.5 创建m1.nano规格的主机(自定义云主机规格)

默认的最小规格的主机需要512 MB内存。我们推荐创建只需要64 MB的m1.nano规格的主机。若单纯为了测试的目的,请使用m1.nano规格的主机来加载CirrOS镜像。

[root@controller ~]# openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 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 |
+----------------------------+---------+
参数说明:
openstack flavor create 创建主机
--id 主机ID
--vcpus cpu数量
--ram 64(默认是MB,可以写成G)
--disk 磁盘(默认单位是G)

  

1.6 查看创建结果

[root@controller ~]# openstack flavor list
+----+---------+-----+------+-----------+-------+-----------+
| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |
+----+---------+-----+------+-----------+-------+-----------+
| 0 | m1.nano | 64 | 1 | 0 | 1 | True |
+----+---------+-----+------+-----------+-------+-----------+

1.7 生成秘钥

大部分云镜像支持公共密钥认证而不是传统的密码认证。在启动实例前,必须添加一个公共密钥到计算服务。

[root@controller ~]# source admin-openrc
[root@controller ~]# ssh-keygen -q -N ""
Enter file in which to save the key (/root/.ssh/id_rsa):

1.8 将密钥放在openstack上

[root@controller ~]# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
+-------------+-------------------------------------------------+
| Field | Value |
+-------------+-------------------------------------------------+
| fingerprint | e7:bb:a1:e5:a1:ef:1a:e7:ea:59:b2:67:cb:4c:5f:85 |
| name | mykey |
| user_id | ff64ec1a3fa7461d890b9757401d475d |
+-------------+-------------------------------------------------+

1.9 验证公钥的添加

[root@controller ~]# openstack keypair list
+-------+-------------------------------------------------+
| Name | Fingerprint |
+-------+-------------------------------------------------+
| mykey | e7:bb:a1:e5:a1:ef:1a:e7:ea:59:b2:67:cb:4c:5f:85 |
+-------+-------------------------------------------------+

1.10 增加安全组规则
允许 ICMP (ping)

默认情况下, default安全组适用于所有实例并且包括拒绝远程访问实例的防火墙规则。对诸如CirrOS这样的Linux镜像,我们推荐至少允许ICMP (ping) 和安全shell(SSH)规则。

[root@controller ~]# openstack security group rule create --proto icmp default
+-------------------+--------------------------------------+
| Field | Value |
+-------------------+--------------------------------------+
| created_at | 2018-04-13T12:16:28Z |
| description | |
| direction | ingress |
| ethertype | IPv4 |
| headers | |
| id | f45624e2-bd78-4131-82c6-c09ccdfbe317 |
| port_range_max | None |
| port_range_min | None |
| project_id | 24a37179b1844e8897e77a0c44cc8d25 |
| project_id | 24a37179b1844e8897e77a0c44cc8d25 |
| protocol | icmp |
| remote_group_id | None |
| remote_ip_prefix | 0.0.0.0/0 |
| revision_number | 1 |
| security_group_id | b40c315f-9625-4877-a9f4-3b52b1f750d1 |
| updated_at | 2018-04-13T12:16:28Z |
+-------------------+--------------------------------------+

允许安全 shell (SSH) 的访问

openstack security group rule create --proto tcp --dst-port 22 default

1.11 查看网络的ID

[root@controller ~]# openstack network list
+--------------------------------------+------------+--------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+------------+--------------------------------------+
| c7e2a252-775d-48e1-a748-11089994f455 | public-net | 4c5d0667-f711-4eb1-a750-0ae4143976b9 |
+--------------------------------------+------------+--------------------------------------+

1.12  创建一个实例

[root@controller ~]# openstack server create --flavor m1.nano --image cirros \
> --nic net-id=c7e2a252-775d-48e1-a748-11089994f455 --security-group default \
> --key-name mykey xuli-instance +--------------------------------------+-----------------------------------------------+
| Field | Value |
+--------------------------------------+-----------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | |
| OS-EXT-SRV-ATTR:host | None |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None |
| OS-EXT-SRV-ATTR:instance_name | |
| OS-EXT-STS:power_state | NOSTATE |
| OS-EXT-STS:task_state | scheduling |
| OS-EXT-STS:vm_state | building |
| OS-SRV-USG:launched_at | None |
| OS-SRV-USG:terminated_at | None |
| accessIPv4 | |
| accessIPv6 | |
| addresses | |
| adminPass | rYP39r4N8th6 |
| config_drive | |
| created | 2018-04-13T12:19:11Z |
| flavor | m1.nano (0) |
| hostId | |
| id | d403e69a-adfc-41b6-937d-75156c080ce0 |
| image | cirros (c952e002-680e-45e1-9337-08d2c3a9abe6) |
| key_name | mykey |
| name | xuli-instance |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| project_id | 24a37179b1844e8897e77a0c44cc8d25 |
| properties | |
| security_groups | [{u'name': u'default'}] |
| status | BUILD |
| updated | 2018-04-13T12:19:12Z |
| user_id | ff64ec1a3fa7461d890b9757401d475d |
+--------------------------------------+-----------------------------------------------+

1.14 查看虚拟机 

[root@controller ~]# openstack server list

+--------------------------------------+------+---------+-----------------------+------------+
| ID | Name | Status | Networks | Image Name |
+--------------------------------------+------+---------+-----------------------+------------+
| b47c5250-20d7-4a05-a555-e59714a08959 | GGG | SHUTOFF | public-net=10.0.0.111 | |
| 1df453d3-c393-4277-8221-f73a1dc69709 | RRR | SHUTOFF | public-net=10.0.0.107 | |
| 3da5bba5-beae-435c-a9b6-cc774951e678 | QQQ | SHUTOFF | public-net=10.0.0.110 | |
+--------------------------------------+------+---------+-----------------------+------------+

1.15 查看虚拟机的URL地址

[root@controller ~]# openstack console url show GGG
+-------+---------------------------------------------------------------------------------+
| Field | Value |
+-------+---------------------------------------------------------------------------------+
| type | novnc |
| url | http://10.0.0.101:6080/vnc_auto.html?token=433f2e28-b480-4d35-96b2-5ac068f699e3 |
+-------+---------------------------------------------------------------------------------+

可以复制上面URL地址,在浏览器访问

1.16 异常排查

如果无法创建虚拟机,我们需要查看控制节点和计算节点所有服务的日志,同时也要查看iptables、selinux、时间同步等

grep 'ERROR' /var/log/nova/*
grep 'ERROR' /var/log/neutron/*
grep 'ERROR' /var/log/glance/*
grep 'ERROR' /var/log/keystone/*

检查

source admin-openstack.sh
nova service-list
neutron agent-list
nova image-list

创建 OpenStack云主机 (十五)的更多相关文章

  1. 创建 OpenStack云主机(十一)

    创建过程 创建虚拟网络 创建m1.nano规格的主机(相等于定义虚拟机的硬件配置) 生成一个密钥对(openstack的原理是不使用密码连接,而是使用密钥对进行连接) 增加安全组规则(用iptable ...

  2. 创建 OpenStack云主机

    创建过程 创建虚拟网络 创建m1.nano规格的主机(相等于定义虚拟机的硬件配置) 生成一个密钥对(openstack的原理是不使用密码连接,而是使用密钥对进行连接) 增加安全组规则(用iptable ...

  3. OpenStack 云主机深入了解(十四)

    云主机深入了解 1.云主机在计算节点以进程方式运行 2.监听vnc的端口,vnc默认端口从5900开始, 多台云主机,端口递增 3.云主机桥接网卡,与宿主机联通网络 提示:在openstack环境下, ...

  4. Openstack 云主机深入了解 (十六)

    一)云主机深入了解 1.云主机在计算节点以进程方式运行 2.监听vnc的端口,vnc默认端口从5900开始, 多台云主机,端口递增 3.云主机桥接网卡,与宿主机联通网络 提示:在openstack环境 ...

  5. 数据包从物理网卡流经 Open vSwitch 进入 OpenStack 云主机的流程

    目录 文章目录 目录 前言 数据包从物理网卡进入虚拟机的流程 物理网卡处理 如何将网卡收到的数据写入到内核内存? 中断下半部分软中断处理 数据包在内核态 OvS Bridge(Datapath)中的处 ...

  6. openstack云主机硬盘复制查询

        假定客户在自己的电脑上创建文件后 #宿主机查看客户使用的是哪个磁盘 [root@compute1 ~]# lvs LV VG Attr LSize Pool Origin Data% Meta ...

  7. 恒创科技 基于openStack云主机

    https://www.henghost.com/cloud-vps.shtml?s=gg&gclid=CKaXuOyr79UCFY-TvQodMJ8BCw

  8. openstack云主机冷迁移

    1:开启nova计算节点之间互信 冷迁移需要nova计算节点之间使用nova用户互相免密码访问 默认nova用户禁止登陆,开启所有计算节点的nova用户登录shell. usermod -s /bin ...

  9. Openstack入门篇(十五)之如何创建生产使用的openstack镜像

    在linux-node1节点上: [root@linux-node1 ~]# yum install -y openstack-nova-compute [root@linux-node1 ~]# y ...

随机推荐

  1. [vim]大小写转换

    http://babybandf.blog.163.com/blog/static/619935320110121134826/ ~ 将光标下的字母改变大小写 3~ 将光标位置开始的3个字母改变其大小 ...

  2. IAR ------ 扩展关键字__weak

    __weak作用:允许多个同名函数同时存在,但是最多只有一个没有__weak修饰.如果有non-weak函数(没__weak修饰),则此函数被使用,否则从__weak修饰的函数中选择其中一个. 下图来 ...

  3. Struts整合ExtJS

    1准备工作: 除了平时引入的struts2的jar包以外,还需要引入struts2-json-plugin-2.1.8.1.jar:json-lib-2.1.jar这两个包. 2.建立我们的model ...

  4. [Luogu 2341] HAOI2006 受欢迎的牛

    [Luogu 2341] HAOI2006 受欢迎的牛 智能推的水题,一看是省选题就给做了,做一半才发现 Tarjan 算法忘干净了. Tarjan 求出SCC,算出每一个 SCC 包含原图的点数(s ...

  5. 元类编程--property动态属性

    from datetime import date, datetime class User: def __init__(self, name, birthday): self.name = name ...

  6. ClassCastException: org.apache.tomcat.websocket.server.WsServerContainer cannot be cast to javax.websocket.server.ServerContainer

    21:09:22.221 [MessageBroker-3] INFO c.t.s.s.impl.StockNewsServiceImpl - [2017-12-16 21:09:22] execut ...

  7. bzoj 1927 网络流

    首先我们可以知道这道题中每个点只能经过一次,那么我们引入附加源汇source,sink,那么我们可以将每个点拆成两个点,分别表示对于图中这个节点我们的进和出,那么我们可以连接(source,i,1,0 ...

  8. Maven学习笔记(一)

    我们暂且可以把Maven理解成是一个项目构建与依赖管理的工具   为什么选用maven? 约定(惯例)优先原则,默认限定了项目目录结构 提供三方依赖管理(解决了依赖维护的问题) 提供了一致的项目构建管 ...

  9. Python ctypes的byref和pointer有啥区别

    byref(n)返回的相当于C的指针右值&n,本身没有被分配空间: >>> from ctypes import *>>> n = c_int(0)> ...

  10. 在电脑中配置adb

    在环境变量的系统变量path中添加SDK中platform_tools和tools的路径 如果出现version说明配置成功