用命令测试安装好的OpenStack环境
2016-08-16 16:38
218 查看
首先要明确几个概念:
外网:可分配floating ip绑定到虚拟机,外部就可以访问虚拟机。
虚拟网络(内部网络,私有网络):虚拟机的虚拟网卡所在的私有网络。
子网:用户创建的每个网络至少要有一个子网(也可以有多个子网)
路由:用户创建的每个网络至少有一个路由,该路由的接口要关联这个网络
fixed ip:虚拟机网卡在虚拟网络上的ip
floating ip:虚拟网络对应的外部网络上的ip
interface:一个网络接口
端口:子网有多个端口(一般会有MAC地址和IP地址),在GRE模式中子网中一般会有qdhcp端口,qrouter端口和为虚拟机实例分配的端口,它们的ip地址属于这个子网
#Nova-manage service list
#neutron agent-list
创建租户
# keystone tenant-create --name TenantA
创建用户
# keystone user-create --name=UserA --pass=password --tenant-id TenantA --email=usera@test.com
为租户添加用户
#keystone user-role-add --tenant TenantA --user UserA --role Member
创建外网
# neutron net-create Ext-Net --provider:network_type gre --provider:segmentation_id 1 --router:external true
创建外网的子网
# neutron subnet-create --allocation-pool start=10.1.101.80,end=10.1.101.100 --gateway 10.1.101.254 Ext-Net 10.1.101.0/24 --enable_dhcp=False
接下来创建租户的子网和虚拟路由
创建租户网络
# neutron --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 net-create tenantA-Net
创建租户子网
# neutron --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 subnet-create tenantA-Net 10.0.0.0/24
创建租户虚拟路由
neutron --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 router-create tenant-R1
增加路由接口
(替换${subnet_id}为子网ID)
neutron --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 router-interface-add tenant-R1 ${subnet_id}
给路由增加网关
# neutron router-gateway-set tenant-R1 Ext-Net
到此为止UserA看到的网络拓扑如下:
安全组规则会影响到外面ping虚拟机和ssh登录虚拟机,所以在controller节点中为openstack设置好ICMP和TCP规则。
获得TenantA的default安全组规则
# neutron --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 security-group-list
默认default规则:
设置nova中default的 ICMP/TCP/UDP安全组规则
# nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 secgroup-add-rule default tcp 1 65535 0.0.0.0/0
# nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 secgroup-add-rule default udp 1 65535 0.0.0.0/0
# nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 secgroup-add-rule default icmp -1 -1 0.0.0.0/0
查看镜像:
# glance index
起虚拟机,替换{the cirros ID from Glance}为镜像ID
#root@controller:~# nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 boot --flavor 1 --image{the cirros
ID from Glance} vm001
检查虚拟机状态为ACTIVE
# nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 list
创建一个浮动IP
# neutron --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 floatingip-create Ext-Net
查看floating-ip
# nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 floating-ip-list
我创建了一个新的浮动IP10.1.101.82,分配的是10.1.101.82
分配浮动IP给虚拟机,替换{the vm id}为虚拟机ID
# nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 floating-ip-associate {the vm id} 10.1.101.82
检查虚拟机状态,现在就可以看到浮动ip了。
# nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 list
替换{put_floating_ip_here}为虚拟机的浮动IP
外网:可分配floating ip绑定到虚拟机,外部就可以访问虚拟机。
虚拟网络(内部网络,私有网络):虚拟机的虚拟网卡所在的私有网络。
子网:用户创建的每个网络至少要有一个子网(也可以有多个子网)
路由:用户创建的每个网络至少有一个路由,该路由的接口要关联这个网络
fixed ip:虚拟机网卡在虚拟网络上的ip
floating ip:虚拟网络对应的外部网络上的ip
interface:一个网络接口
端口:子网有多个端口(一般会有MAC地址和IP地址),在GRE模式中子网中一般会有qdhcp端口,qrouter端口和为虚拟机实例分配的端口,它们的ip地址属于这个子网
一、查看nova和neutron服务,确保都是笑脸
#Nova-manage service list
二、创建租户和用户
创建租户# keystone tenant-create --name TenantA
# keystone user-create --name=UserA --pass=password --tenant-id TenantA --email=usera@test.com
#keystone user-role-add --tenant TenantA --user UserA --role Member
三、准备neutron网络
创建外网# neutron net-create Ext-Net --provider:network_type gre --provider:segmentation_id 1 --router:external true
# neutron subnet-create --allocation-pool start=10.1.101.80,end=10.1.101.100 --gateway 10.1.101.254 Ext-Net 10.1.101.0/24 --enable_dhcp=False
创建租户网络
# neutron --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 net-create tenantA-Net
# neutron --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 subnet-create tenantA-Net 10.0.0.0/24
neutron --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 router-create tenant-R1
(替换${subnet_id}为子网ID)
neutron --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 router-interface-add tenant-R1 ${subnet_id}
# neutron router-gateway-set tenant-R1 Ext-Net
四、安全组规则
安全组规则会影响到外面ping虚拟机和ssh登录虚拟机,所以在controller节点中为openstack设置好ICMP和TCP规则。获得TenantA的default安全组规则
# neutron --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 security-group-list
设置nova中default的 ICMP/TCP/UDP安全组规则
# nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 secgroup-add-rule default tcp 1 65535 0.0.0.0/0
五、起虚拟机
查看镜像:# glance index
#root@controller:~# nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 boot --flavor 1 --image{the cirros
ID from Glance} vm001
# nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 list
六、为虚拟机分配浮动IP
创建一个浮动IP# neutron --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 floatingip-create Ext-Net
# nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 floating-ip-list
分配浮动IP给虚拟机,替换{the vm id}为虚拟机ID
# nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 floating-ip-associate {the vm id} 10.1.101.82
# nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 list
七、SSH到虚拟机(虚拟机状态为ACTIVE,密码是cubswin:))
替换{put_floating_ip_here}为虚拟机的浮动IP相关文章推荐
- 用命令测试安装好的OpenStack环境
- [Openstack]一键安装Openstack测试环境
- docker实战1 (docker-toolbox的安装,docker基础命令详解[运行,容器导入/导出,镜像导入/导出,数据卷,网络],构建100个docker实例的测试环境)
- 网上最新的devstack安装教程【一键部署openstack测试环境】
- 已解决:好用的集成PHP环境 一键安装包PHPNow--Win7下安装phpnow的方法出现[ Apache_pn ] 错误的解决 !(亲自测试通过)
- win本机测试环境MangoDB安装笔记
- RHEL4 AS-U4命令模式下安装图形化环境
- Qt for Maemo开发环境安装及测试
- 在开测试环境下,如何利用makecert.exe命令创建各种certificate
- Thrift 学习笔记2——Windows环境下Thrift的安装、编译以及测试
- windows7搭建本机与虚拟机网站测试环境----回环网卡的安装
- 在测试环境下安装和配置MOSS 2007
- sphinx 安装与测试 linux 环境
- android 开发环境安装和测试中常出现的问题
- 安装MANTIS测试环境后,解决页面显示警告时区设置不正常的方法
- 教你如何安装配置动态数据中心测试环境
- ubuntu中rar及编译环境安装(ln命令介绍)
- [转]安装 mogilefs 测试系统,在一台机器上,用于测试环境
- linux下gcc编译环境安装与测试
- 已解决:好用的集成PHP环境 一键安装包PHPNow--Win7下安装phpnow的方法出现[ Apache_pn ] 错误的解决 !(亲自测试通过)