用命令测试安装好的OpenStack环境

OpenStack三个节点icehouse-gre模式部署一文部署了一套OpenStack环境,接下来使用命令测试一遍。

首先要明确几个概念:

外网:可分配floating ip绑定到虚拟机,外部就可以访问虚拟机。

虚拟网络(内部网络,私有网络):虚拟机的虚拟网卡所在的私有网络。

子网:用户创建的每个网络至少要有一个子网(也可以有多个子网)

路由:用户创建的每个网络至少有一个路由,该路由的接口要关联这个网络

fixed ip:虚拟机网卡在虚拟网络上的ip

floating ip:虚拟网络对应的外部网络上的ip

interface:一个网络接口

端口:子网有多个端口(一般会有MAC地址和IP地址),在GRE模式中子网中一般会有qdhcp端口,qrouter端口和为虚拟机实例分配的端口,它们的ip地址属于这个子网

一、查看nova和neutron服务,确保都是笑脸

#Nova-manage service list

  View Code

#neutron agent-list

  View Code

二、创建租户和用户

创建租户

# keystone tenant-create --name TenantA

  View Code

创建用户

# keystone user-create --name=UserA --pass=password --tenant-id TenantA --email=usera@test.com

  View Code

为租户添加用户

#keystone user-role-add --tenant TenantA  --user UserA --role Member

  View Code

三、准备neutron网络

创建外网

# neutron net-create Ext-Net --provider:network_type gre --provider:segmentation_id 1 --router:external true

  View Code

创建外网的子网

# 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

  View Code

接下来创建租户的子网和虚拟路由

创建租户网络

# neutron --os-tenant-name TenantA  --os-username UserA --os-password password  --os-auth-url=http://localhost:5000/v2.0 net-create tenantA-Net

  View Code

创建租户子网

# 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

  View Code

创建租户虚拟路由

neutron --os-tenant-name TenantA --os-username UserA --os-password password  --os-auth-url=http://localhost:5000/v2.0 router-create tenant-R1

  View Code

增加路由接口

(替换${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}

  View Code

给路由增加网关

# neutron router-gateway-set tenant-R1 Ext-Net

  View Code

到此为止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

  View Code

默认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

  View Code

# 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

  View Code

# 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

  View Code

五、起虚拟机

查看镜像:

# glance index

  View Code

起虚拟机,替换{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

  View Code

检查虚拟机状态为ACTIVE

# nova --os-tenant-name TenantA --os-username UserA --os-password password  --os-auth-url=http://localhost:5000/v2.0 list

  View Code

六、为虚拟机分配浮动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

  View Code

查看floating-ip

# nova --os-tenant-name TenantA --os-username UserA --os-password password  --os-auth-url=http://localhost:5000/v2.0  floating-ip-list

  View Code

我创建了一个新的浮动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

  View Code

检查虚拟机状态,现在就可以看到浮动ip了。

# nova --os-tenant-name TenantA --os-username UserA --os-password password --os-auth-url=http://localhost:5000/v2.0 list

  View Code

七、SSH到虚拟机(虚拟机状态为ACTIVE,密码是cubswin:))

替换{put_floating_ip_here}为虚拟机的浮动IP

ssh cirros@{put_floating_ip_here}
复制代码
root@controller:~# ssh cirros@10.1.101.82
The authenticity of host '10.1.101.82 (10.1.101.82)' can't be established.
RSA key fingerprint is da:a3:1a:60:f1:e9:3a:e2:a7:6c:35:cb:f8:9b:b7:65.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.1.101.82' (RSA) to the list of known hosts.
cirros@10.1.101.82's password: 
$ 
$ 
$ 
$ ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8): 56 data bytes
64 bytes from 8.8.8.8: seq=3 ttl=35 time=295.980 ms
64 bytes from 8.8.8.8: seq=7 ttl=35 time=299.047 ms
复制代码
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值