1.创建网络
[root@linux-node1 ~]# openstack network create --share --external --provider-physical-network provider --provider-network-type flat provider
2.创建子网
[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
3. 创建云主机类型
[root@linux-node1 ~]# openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano
4.创建密钥对
[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
5.添加安全组规则
[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
启动实例
[root@linux-node1 ~]# source demo-openstack.sh [root@linux-node1 ~]# openstack flavor list
1.查看可用的镜像
[root@linux-node1 ~]# openstack image list
2.查看可用的网络
[root@linux-node1 ~]# openstack network list
3.查看可用的安全组
[root@linux-node1 ~]# openstack security group list
4.创建虚拟机
[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,而不是名称
5.查看虚拟机
[root@linux-node1 ~]# openstack server list [root@linux-node1 ~]# openstack console url show demo-instance