openstack学习-创建一台云主机(七)

一、创建基础环境

1、检查网络是否正常

[root@linux-node1 ~]# openstack  network  agent  list
+--------------------------------------+--------------------+-------------------------+-------------------+-------+-------+---------------------------+
| ID                                   | Agent Type         | Host                    | Availability Zone | Alive | State | Binary                    |
+--------------------------------------+--------------------+-------------------------+-------------------+-------+-------+---------------------------+
| 0edfdc1a-f5be-44fe-86d8-4b56b85b1deb | Linux bridge agent | linux-node1.example.com | None              | :-)   | UP    | neutron-linuxbridge-agent |
| 281896e5-6946-4192-95f1-f2d7b8b9d2bc | DHCP agent         | linux-node1.example.com | nova              | :-)   | UP    | neutron-dhcp-agent        |
| bf75c379-beb3-4a5a-b003-5b136e4fcdf9 | Metadata agent     | linux-node1.example.com | None              | :-)   | UP    | neutron-metadata-agent    |
| ee34827e-2af6-40ce-9791-ad13902095ce | Linux bridge agent | linux-node2.example.com | None              | :-)   | UP    | neutron-linuxbridge-agent |
+--------------------------------------+--------------------+-------------------------+-------------------+-------+-------+---------------------------+

2、创建网络

[root@linux-node1 ~]# openstack network create  --share --external \
  --provider-physical-network provider \
  --provider-network-type flat provider

3、查看网络是否创建成功

[root@linux-node1 ~]# openstack  network  list
+--------------------------------------+----------+---------+
| ID                                   | Name     | Subnets |
+--------------------------------------+----------+---------+
| 12d6ee7f-ffd5-4887-b884-8aa74d1ac576 | provider |         |
+--------------------------------------+----------+---------+
[root@linux-node1 ~]# 

4、创建子网

[root@linux-node1 ~]# openstack subnet create --network provider \
  --allocation-pool start=192.168.56.100,end=192.168.56.200 \
  --dns-nameserver 223.5.5.5  --gateway 192.168.56.2 \
  --subnet-range 192.168.56.0/24 provider-subnet

5、 创建云主机类型

[root@linux-node1 ~]# openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano

6、创建密钥对

[root@linux-node1 ~]# source demo-openstack.sh
[root@linux-node1 ~]# ssh-keygen -q -N ""
[root@linux-node1 ~]# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
[root@linux-node1 ~]# openstack keypair list

7、添加安全组规则

[root@linux-node1 ~]# openstack security group rule create --proto icmp default
 [root@linux-node1 ~]# openstack security group rule create --proto tcp --dst-port 22 default

 二、查看创建的实例

 1、查看云主机类型

[root@linux-node1 ~]# source demo-openstack.sh
[root@linux-node1 ~]# openstack flavor list

 

2、查看可用的镜像 

[root@linux-node1 ~]# openstack image list

 

 3、查看可用的网络

[root@linux-node1 ~]# openstack network list

 

 4、查看可用的安全组

[root@linux-node1 ~]# openstack security group list

 

三、创建虚拟机

[root@linux-node1 ~]# openstack server create --flavor m1.nano --image cirros \
--nic net-id=5c4d0706-24cd-4d42-ba78-36a05b6c81c8 --security-group default \
--key-name mykey demo-instance
#注意指定网络的时候需要使用ID,而不是名称

 

四、查看虚拟机

[root@linux-node1 ~]# openstack server list
[root@linux-node1 ~]# openstack console url show demo-instance

 

posted @ 2018-09-20 16:16  凉生墨客  阅读(834)  评论(0编辑  收藏