openstack note (viii) to create a VM instance (command line)

1. Create admin VM instance depends properties (network, subnetwork, VM instance specifications)

  • Creating a virtual network

source admin-openstack.sh

Format:

openstack network create --share --external \
--provider-physical-network <提供者> \
--provider-network-type flat <网络名称>
# --share 允许所有项目都可以使用该网络
# --external 定义连通外部的虚拟网络
# --provider-physical-network 指定物理网络的提供者,由ml2_conf.ini文件的flat_networks确定
# --provider-network-type flat 映射到虚拟主机的网卡eth0,由linuxbridge_agent.ini文件中的physical_interface_mappings确定
openstack network create --share --external --provider-physical-network provider --provider-network-type flat provider
复制代码
  • Create a virtual subnet

Format:

openstack subnet create --network <网络名称>
--allocation-pool start=<起始地址>,end=<结束地址> \
--dns-nameserver <域名服务器> --gateway <网关> \
--subnet-range <子网网段> <子网名称>
# --network 指定网络名称,表示该子网用在哪个网段
# --allocation-pool 指定分配的地址池,start设定起始地址,end设置结束地址
# --dns-nameserver 指定域名服务器,可以用8.8.4.4(google),223.5.5.5(阿里云)等等
# --gateway 指定网关,设定宿主机的网关
# --subnet-range 指定子网范围 openstack subnet create --network provider --allocation-pool start=192.168.188.30,end=192.168.188.50 --dns-nameserver 223.5.5.5 --gateway 192.168.188.2 --subnet-range 192.168.188.0/24 provider 复制代码
  • Creating VM instance specifications
命令格式:
openstack flavor create --id <id号> --vcpus <CPU数量> --ram <内存大小> --disk <磁盘大小> <云主机类型>
openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano
复制代码

2. Create a VM instance

Use demo user

  • Configuration keys
source demo-openstack.sh
#生成秘钥
ssh-keygen -q -N ""
#上传秘钥到openstack
openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
#检查效果 openstack keypair list 复制代码
  • Increase security group
#设置虚拟机ping规则
openstack security group rule create --proto icmp default
#设置虚拟机ssh规则
openstack security group rule create --proto tcp --dst-port 22 default
复制代码

3. Start the virtual machine instance

Format:

openstack server create --flavor <云主机规格> --image <镜像名称> \
--nic net-id=<虚拟网络ID> --security-group <安全组> \
--key-name <秘钥名> <虚拟机实例名>
#参数均为前面设置的配置参数
openstack server create --flavor m1.nano --image cirros --nic net-id=782902ce-436a-4d07-aa24-e7aea94fb6c7 --security-group default --key-name mykey provider-instance
复制代码
  • Check the effect

Gets the virtual machine interface terminal

openstack console url show provider-instance

Browser link url

Here we met Failed to connect to server: problem (code 1006), the open vnc interface, and found the url instead of using a controller ip address, browser suspected resolve the problem. Then modify the C under the windows system: \ Windows \ System32 \ drivers \ etc \ hosts file DNS, the controller is mapped to a control node ip address, the error problem is solved.

 

 

Open vnc interface later found to be black, do not know how to solve, and so on for a while as well. It estimates the physical machine configuration is not too card ...

Ssh connection

ssh [email protected]

to sum up

Individuals consider themselves to be the entry point to learn OpenStack, the open-source software can be said is quite complex and cumbersome, if you want more in-depth study and practice the use of its capability, long way to go.


Author:. Mmd
link: https: //juejin.im/post/5d65e58fe51d4561c83e7c7d

Guess you like

Origin www.cnblogs.com/well-666/p/12151583.html