创建 OpenStack云主机 (十五)
创建过程
- 创建虚拟网络
- 创建m1.nano规格的主机(相等于定义虚拟机的硬件配置)
- 生成一个密钥对(openstack的原理是不使用密码连接,而是使用密钥对进行连接)
- 增加安全组规则(用iptables做的安全组)
- 启动一个实例(启动虚拟机有三种类型:1.命令CLI 2.api 3.Dashboard)实际上Dashboard也是通过api进行操作
- 虚拟网络分为提供者网络和私有网络,提供者网络就是跟主机在同一个网络里,私有网络自定义路由器等,跟主机不在一个网络
一.)创建网络
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云主机 (十五)的更多相关文章
- 创建 OpenStack云主机(十一)
创建过程 创建虚拟网络 创建m1.nano规格的主机(相等于定义虚拟机的硬件配置) 生成一个密钥对(openstack的原理是不使用密码连接,而是使用密钥对进行连接) 增加安全组规则(用iptable ...
- 创建 OpenStack云主机
创建过程 创建虚拟网络 创建m1.nano规格的主机(相等于定义虚拟机的硬件配置) 生成一个密钥对(openstack的原理是不使用密码连接,而是使用密钥对进行连接) 增加安全组规则(用iptable ...
- OpenStack 云主机深入了解(十四)
云主机深入了解 1.云主机在计算节点以进程方式运行 2.监听vnc的端口,vnc默认端口从5900开始, 多台云主机,端口递增 3.云主机桥接网卡,与宿主机联通网络 提示:在openstack环境下, ...
- Openstack 云主机深入了解 (十六)
一)云主机深入了解 1.云主机在计算节点以进程方式运行 2.监听vnc的端口,vnc默认端口从5900开始, 多台云主机,端口递增 3.云主机桥接网卡,与宿主机联通网络 提示:在openstack环境 ...
- 数据包从物理网卡流经 Open vSwitch 进入 OpenStack 云主机的流程
目录 文章目录 目录 前言 数据包从物理网卡进入虚拟机的流程 物理网卡处理 如何将网卡收到的数据写入到内核内存? 中断下半部分软中断处理 数据包在内核态 OvS Bridge(Datapath)中的处 ...
- openstack云主机硬盘复制查询
假定客户在自己的电脑上创建文件后 #宿主机查看客户使用的是哪个磁盘 [root@compute1 ~]# lvs LV VG Attr LSize Pool Origin Data% Meta ...
- 恒创科技 基于openStack云主机
https://www.henghost.com/cloud-vps.shtml?s=gg&gclid=CKaXuOyr79UCFY-TvQodMJ8BCw
- openstack云主机冷迁移
1:开启nova计算节点之间互信 冷迁移需要nova计算节点之间使用nova用户互相免密码访问 默认nova用户禁止登陆,开启所有计算节点的nova用户登录shell. usermod -s /bin ...
- Openstack入门篇(十五)之如何创建生产使用的openstack镜像
在linux-node1节点上: [root@linux-node1 ~]# yum install -y openstack-nova-compute [root@linux-node1 ~]# y ...
随机推荐
- mesos安装、配置和运行
环境:rhel6.6 安装: 安装依赖包 yum install -y tar wget git which nss yum groupinstall -y "Development Too ...
- C#学习之泛型继承和静态成员
想要理解这里有必要先将泛型类学习充分.这里讲解的是泛型类继承类的类型和静态成员. 在前面C#学习之泛型中,创建的LinkList<T>类实现了IEnumerable<T>接口. ...
- 51Nod 1381 硬币游戏 | 概率(数学期望)
Input 第一行给出一个整数T,表示有T组数据(1<=T<=10000). 第2行到T+1,每行给出一个整数R.(0< R <= 10,000,000,000) Output ...
- 其他:OI竞赛中的文件操作
本文介绍三种方法进行文件输入输出,都非常实用 第一种方法是采用重定向的形式进行输入输出,很方便 freopen("input.txt","r",stdin); ...
- MyBatis框架的使用及源码分析(二) 配置篇 SqlSessionFactoryBuilder,XMLConfigBuilder
在 <MyBatis框架中Mapper映射配置的使用及原理解析(一) 配置与使用> 的demo中看到了SessionFactory的创建过程: SqlSessionFactory sess ...
- Tomcat报错java.lang.ClassNotFoundException: 2localhost.org.apache.juli.FileHandler
Can't load log handler "1catalina.org.apache.juli.FileHandler" java.lang.ClassNotFoundExce ...
- Java——Iterate through a HashMap
遍历Map import java.util.*; public class IterateHashMap { public static void main(String[] args) { Map ...
- HDFS不存在绝对路径,无法找到文件所在具体位置
This is set in the dfs.datanode.data.dir property, which defaults to file://${hadoop.tmp.dir}/dfs/da ...
- 高精度模板_C++
高精度压位,压9位 read:读入 write:输出 copy:赋值 change:交换 empty:清0 cmp:比较大小,相当于小于号 plus:加法 dec:减法 multy:乘法 除法实在不会 ...
- 什么是AMD规范
AMD规范全称是Asynchronous Module Definition,即异步模块加载机制.从它的规范描述页面看,AMD很短也很简单,但它却完整描述了模块的定义,依赖关系,引用关系以及加载机制. ...