回顾下前几节用到的东西
MySQL:为各个服务提供数据存储
RabbitmQ:为各个服务之间提供通信提供交通枢纽
Keystone:为各个服务之间通信提供认证和服务注册
Glance:为虚拟机提供镜像管理
Nova:为虚拟机提供计算资源
Neutron:为虚拟机提供网络
1、创建单一扁平网络
在控制节点上,加载 admin 凭证来获取管理员能执行的命令访问权限:
source admin-openstack.sh ,提供者网络必须使用admin创建,如果source demo-openstack.sh ,不会创建成功
执行命令语法如下
下面命令把provider改成public,表示物理网卡是public这个,这个是映射的那个public,它对应eth0
neutron net-create --shared --provider:physical_network provider
--provider:network_type flat provider
[root@linux-node1 ~]# source admin-openstack.sh
[root@linux-node1 ~]# neutron net-create --shared --provider:physical_network public --provider:network_type flat public-net
Created a new network:
+---------------------------+--------------------------------------+
| Field | Value |
+---------------------------+--------------------------------------+
| admin_state_up | True |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2017-08-06T05:10:04 |
| description | |
| id | dc3a90b3-b3ca-4c3d-8d7a-24587907659e |
| ipv4_address_scope | |
| ipv6_address_scope | |
| mtu | 1500 |
| name | public-net |
| port_security_enabled | True |
| provider:network_type | flat |
| provider:physical_network | public |
| provider:segmentation_id | |
| router:external | False |
| shared | True |
| status | ACTIVE |
| subnets | |
| tags | |
| tenant_id | fa594a6ca4b84c5b985628641dd751fe |
| updated_at | 2017-08-06T05:10:05 |
+---------------------------+--------------------------------------+
[root@linux-node1 ~]# neutron net-list
+--------------------------------------+------------+---------+
| id | name | subnets |
+--------------------------------------+------------+---------+
| dc3a90b3-b3ca-4c3d-8d7a-24587907659e | public-net | |
+--------------------------------------+------------+---------+
1、创建nano套餐类型
默认的最小规格的主机需要512 MB内存。对于环境中计算节点内存不足4 GB的,我们推荐创建只需要64 MB的m1.nano规格的主机。
若单纯为了测试的目的,请使用m1.nano规格的主机来加载CirrOS镜像
硬盘是1GB,内存64MB,cpu是1个
[root@linux-node1 ~]# 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 |
| ram | 64 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 1 |
+----------------------------+---------+
[root@linux-node1 ~]# openstack keypair list
+-------+-------------------------------------------------+
| Name | Fingerprint |
+-------+-------------------------------------------------+
| mykey | 70:da:5c:31:9d:d8:2b:11:eb:ff:20:fa:c3:46:b6:ce |
+-------+-------------------------------------------------+
2、增加安全组规则
默认情况下,它有一个default安全组,这个安全组阻止了所有访问,这里添加icmp和ssh
3、列出可用镜像、网络、安全组等
创建之前先列出可用类型和列出可用镜像:
[root@linux-node1 ~]# source demo-openstack.sh[root@linux-node1 ~]# openstack network list
+--------------------------------------+------------+--------------------------------------+
| ID | Name | Subnets |
+--------------------------------------+------------+--------------------------------------+
| dc3a90b3-b3ca-4c3d-8d7a-24587907659e | public-net | a7bf2ec3-9b29-47c0-afa8-2497beb996d2 |
+--------------------------------------+------------+--------------------------------------+
列出可用的安全组
[root@linux-node1 ~]# openstack security group list
+--------------------------------------+---------+------------------------+----------------------------------+
| ID | Name | Description | Project |
+--------------------------------------+---------+------------------------+----------------------------------+
| 8d7a8277-185b-4949-a8f8-ef6e87483138 | default | Default security group | 6c91006efd3e4424b5dc3cf302110a79 |
+--------------------------------------+---------+------------------------+----------------------------------+
4、创建实例
创建实例的语法如下
openstack server create --flavor m1.tiny --image cirros \
--nic net-
id
=PROVIDER_NET_ID --security-group default \
--key-name mykey provider-instance
如果你选择选项1并且你的环境只有一个网络,你可以省去–nic 选项因为OpenStack会自动选择这个唯一可用的网络。
net-id就是openstack network list 显示的id, 不是subnet的id
执行过程如下:
[root@linux-node1 ~]# openstack server create --flavor m1.nano --image cirros --nic net-id=dc3a90b3-b3ca-4c3d-8d7a-24587907659e --security-group default --key-name mykey provider-instance
+--------------------------------------+-----------------------------------------------+
| Field | Value |
+--------------------------------------+-----------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | |
| OS-EXT-STS:power_state | 0 |
| 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 | aoJ9NBmihaz7 |
| config_drive | |
| created | 2017-08-06T06:10:59Z |
| flavor | m1.nano (0) |
| hostId | |
| id | 3365c4b4-d487-4778-ad28-e2c675f085eb |
| image | cirros (11a785ae-509e-40cd-85c3-18af791ef66a) |
| key_name | mykey |
| name | provider-instance |
| os-extended-volumes:volumes_attached | [] |
| progress | 0 |
| project_id | 6c91006efd3e4424b5dc3cf302110a79 |
| properties | |
| security_groups | [{u'name': u'default'}] |
| status | BUILD |
| updated | 2017-08-06T06:11:52Z |
| user_id | 4770f06c75bc40b8a4d2ce6fc0f24286 |
+--------------------------------------+-----------------------------------------------+
[root@linux-node2 ~]# virsh list
Id Name State
----------------------------------------------------
1 instance-00000001 running
grep 'ERROR' /var/log/glance/*
grep 'ERROR' /var/log/keystone/*
grep 'ERROR' /var/log/nova/*
[root@linux-node1 ~]#
grep 'ERROR' /var/log/neutron/*
[root@linux-node1 ~]# openstack server list
+--------------------------------------+-------------------+--------+--------------------------+
| ID | Name | Status | Networks |
+--------------------------------------+-------------------+--------+--------------------------+
| 3365c4b4-d487-4778-ad28-e2c675f085eb | provider-instance | ACTIVE | public-net=192.168.1.101 |
+--------------------------------------+-------------------+--------+--------------------------+
查看计算节点端口启动情况,有个5900端口,就是vnc的
[root@linux-node2 ~]# netstat -lntp查看下连接情况
计算节点的5900端口和控制节点的6080端口
[root@linux-node2 ~]# lsof -i:5900