两种姿势玩 OpenStack:Horizon 面板点点点 CLI 敲命令部署云主机 📅 发布时间:2026/9/14 23:09:16 👁 浏览次数: 文章目录OpenStack使用WEB界面实验创建实例类型(规格)上传镜像创建外部网络创建内网创建路由器观察此刻网络拓扑创建实例实例创建成功VNC登录观察此刻网络拓扑instance1 外网通信测试CLI实验创建实例类型(规格)上传镜像创建外部网络创建内网创建路由器观察此刻网络拓扑创建实例实例创建成功观察此刻网络拓扑instance1 外网通信测试OpenStack使用WEB界面实验创建实例类型(规格)上传镜像创建外部网络创建内网创建路由器观察此刻网络拓扑创建实例实例创建成功VNC登录右击在新标签页中打开连接观察此刻网络拓扑instance1 外网通信测试CLI实验还原快照照着WEB一摸一样再来一遍创建实例类型(规格)# 加载环境变量配置文件[rootcontroller ~]# source keystonerc_admin# 创建实例规格flavor[rootcontroller ~(keystone_admin)]# openstack flavor create --helpusage: openstack flavor create[-h][-f{json,shell,table,value,yaml}][-c COLUMN][--noindent][--prefix PREFIX][--max-widthinteger][--fit-width][--print-empty][--idid][--ramsize-mb][--disksize-gb][--ephemeralsize-gb][--swapsize-mb][--vcpusvcpus][--rxtx-factorfactor][--public|--private][--propertykeyvalue][--projectproject][--descriptiondescription][--project-domainproject-domain]flavor-nameCreate new flavor positional arguments:flavor-nameNew flavor name optional arguments: -h,--helpshow thishelpmessage andexit--ididUnique flavor ID;autocreates a UUID(default: auto)--ramsize-mbMemory sizeinMB(default 256M)--disksize-gbDisk sizeinGB(default 0G)--ephemeralsize-gbEphemeral disk sizeinGB(default 0G)--swapsize-mbAdditional swap space sizeinMB(default 0M)--vcpusvcpusNumber of vcpus(default1)--rxtx-factorfactorRX/TX factor(default1.0)--publicFlavor is available to other projects(default)--privateFlavor is not available to other projects--propertykeyvalueProperty toaddforthis flavor(repeat option tosetmultiple properties)--projectprojectAllowprojectto access private flavor(name or ID)(Must be used with--privateoption)--descriptiondescriptionDescriptionforthe flavor.(Supported by API versions2.55-2.latest--project-domainproject-domainDomain the project belongs to(name or ID). This can be usedincasecollisions between project names exist. output formatters: output formatter options-f{json,shell,table,value,yaml},--format{json,shell,table,value,yaml}the output format, defaults to table-cCOLUMN,--columnCOLUMN specify the column(s)to include, can be repeated to show multiple columns json formatter:--noindentwhether to disable indenting the JSON shell formatter: aformata UNIX shell can parse(variablevalue)--prefixPREFIXadda prefix to all variable names table formatter: --max-widthintegerMaximum display width,1to disable. You can also use the CLIFF_MAX_TERM_WIDTH environment variable, but the parameter takes precedence. --fit-width Fit the table to the display width. Impliedif--max- width greater than0. Set the environment variableCLIFF_FIT_WIDTH1to alwaysenable--print-empty Print empty tableifthere is no data to show.# 创建实例规格flavor[rootcontroller ~(keystone_admin)]# openstack flavor create --vcpus 1 --ram 1000 --disk 1 m1.1u.1g------------------------------------------------------------------|Field|Value|------------------------------------------------------------------|OS-FLV-DISABLED:disabled|False||OS-FLV-EXT-DATA:ephemeral|0||disk|1||id|b09812ee-8c91-49b9-b17b-f68bf21ba04c||name|m1.1u.1g||os-flavor-access:is_public|True||properties|||ram|1000||rxtx_factor|1.0||swap|||vcpus|1|------------------------------------------------------------------上传镜像将镜像通过SFTP上传到controller节点/root目录上传镜像到openstack# 创建镜像[rootcontroller ~(keystone_admin)]# openstack image create --file /root/cirros-0.5.2-x86_64-disk.img --disk-format qcow2 --public cirros-0.5.2创建外部网络# 创建网络[rootcontroller ~(keystone_admin)]# openstack network create --project-domain admin --provider-network-type flat --provider-physical-network extnet --external waiwang# 创建子网[rootcontroller ~(keystone_admin)]# openstack subnet create --subnet-range 192.168.108.0/24 --gateway 192.168.108.2 --allocation-pool start192.168.108.100,end192.168.108.200 --network waiwang waiwang_subnet创建内网# 创建网络[rootcontroller ~(keystone_admin)]# openstack network create --project-domain admin neiwang1# 创建子网[rootcontroller ~(keystone_admin)]# openstack subnet create --subnet-range 172.16.0.0/24 --gateway 172.16.0.1 --allocation-pool start172.16.0.100,end172.16.0.200 --dns-nameserver 8.8.8.8 --network neiwang1 neiwang_subnet1创建路由器# 创建路由器[rootcontroller ~(keystone_admin)]# openstack router create router1# 设置路由器配置外部网关[rootcontroller ~(keystone_admin)]# openstack router set --external-gateway waiwang router1# 为路由器添加子网接口[rootcontroller ~(keystone_admin)]# openstack router add subnet router1 neiwang_subnet1观察此刻网络拓扑创建实例# 创建云服务器实例[rootcontroller ~(keystone_admin)]# openstack server create --image cirros-0.5.2 --flavor m1.1u.1g --network neiwang1 instance1实例创建成功查看有哪些实例# 列出所有云服务器实例[rootcontroller ~(keystone_admin)]# openstack server list----------------------------------------------------------------------------- ---------------------------|ID|Name|Status|Networks|Image|Flavor|----------------------------------------------------------------------------- ---------------------------|07e06925-625f-4dbb-8180-e2ea17ba9d04|instance1|ACTIVE|neiwang1172.16.0.136|cirros-0.5.2|m1.1u.1g|----------------------------------------------------------------------------- ---------------------------查看实例instance1详细信息# 查看云服务器实例详情[rootcontroller ~(keystone_admin)]# openstack server show instance1------------------------------------------------------------------------------- ----------------|Field|Value|------------------------------------------------------------------------------- ----------------|OS-DCF:diskConfig|MANUAL||OS-EXT-AZ:availability_zone|nova||OS-EXT-SRV-ATTR:host|compute||OS-EXT-SRV-ATTR:hypervisor_hostname|compute||OS-EXT-SRV-ATTR:instance_name|instance-00000001||OS-EXT-STS:power_state|Running||OS-EXT-STS:task_state|None||OS-EXT-STS:vm_state|active||OS-SRV-USG:launched_at|2024-09-23T03:07:57.000000||OS-SRV-USG:terminated_at|None||accessIPv4|||accessIPv6|||addresses|neiwang1172.16.0.136||config_drive|||created|2024-09-23T03:07:54Z||flavor|m1.1u.1g(b09812ee-8c91-49b9-b17b- f68bf21ba04c)||hostId|f00630fce60ba860032d71e9058332f335ee93e9d368814f519aa57e||id|07e06925-625f-4dbb-8180-e2ea17ba9d04||image|cirros-0.5.2(720f9ec0-d58c-4456-8d50- d6624bf11831)||key_name|None||name|instance1||progress|0||project_id|03e49a46342d48ab9607b4919925e42c||properties|||security_groups|namedefault||status|ACTIVE||updated|2024-09-23T03:08:00Z||user_id|7ef9147a8abe485889ece90dce340ab1||volumes_attached||------------------------------------------------------------------------------- ----------------VNC登录后续可以SSH登录观察此刻网络拓扑instance1 外网通信测试