openstack V版 命令行云主机发放
本文最后更新于87 天前,其中的信息可能已经过时,如有错误请发送邮件到2639131093@qq.com

环境准备

1. 本教程适用于 openstack victoria 版的图形化云主机发放,你可以查看我发布的前置教程

packstack 安装 openstack -v 版 centos stream

Packstack 安装 openstack–V 版 centos 8

2. 请确保你的环境配置

若你选择的是 packstack 安装的 openstack victoria,你需要配置物理网络

[root@controller ml2]# pwd
/etc/neutron/plugins/ml2
 
[root@controller ml2]# vim ml2_conf.ini 

3.查看用户变量

[root@controller ~(keystone_admin)]# cat keystonerc_admin     ##查看用户环境变量
unset OS_SERVICE_TOKEN
    export OS_USERNAME=admin
    export OS_PASSWORD='redhat'
    export OS_REGION_NAME=RegionOne
    export OS_AUTH_URL=http://192.168.100.128:5000/v3
    export PS1='[\u@\h \W(keystone_admin)]\$ '
    
export OS_PROJECT_NAME=admin
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_IDENTITY_API_VERSION=3
    [root@controller ~(keystone_admin)]# 
[root@controller ~(keystone_admin)]# source keystonerc_admin   ##加载环境变量
[root@controller ~(keystone_admin)]# 

管理员用户下

创建项目

[root@controller ~(keystone_admin)]# openstack project create chencuo    ##创建名为chencuo的项目
+-------------+----------------------------------+
| Field       | Value                            |
+-------------+----------------------------------+
| description |                                  |
| domain_id   | default                          |
| enabled     | True                             |
| id          | b8bf06fc744347788603994ab9a85760 |
| is_domain   | False                            |
| name        | chencuo                          |
| options     | {}                               |
| parent_id   | default                          |
| tags        | []                               |
+-------------+----------------------------------+
[root@controller ~(keystone_admin)]# openstack project list     ##查看项目列表
+----------------------------------+----------+
| ID                               | Name     |
+----------------------------------+----------+
| 8c5563f26cbd401e8d531456275304e5 | admin    |
| b8bf06fc744347788603994ab9a85760 | chencuo  |
| f8f20f8ff267427e8b166e8f3576ca9a | services |
+----------------------------------+----------+

创建用户

[root@controller ~(keystone_admin)]# openstack user create --password 123456 --project chencuo chencuo
##创建用户指定密码为123456,指定项目为chencuo,创建的用户叫chencuo
+---------------------+----------------------------------+
| Field               | Value                            |
+---------------------+----------------------------------+
| default_project_id  | b8bf06fc744347788603994ab9a85760 |
| domain_id           | default                          |
| enabled             | True                             |
| id                  | b0fdb1184a064a69a7d20fb1c85db5af |
| name                | chencuo                          |
| options             | {}                               |
| password_expires_at | None                             |
+---------------------+----------------------------------+
[root@controller ~(keystone_admin)]# openstack user list   ##用户列表
+----------------------------------+------------+
| ID                               | Name       |
+----------------------------------+------------+
| bb72b62b60f04496afeb066c3a1512ee | admin      |
| 42ff7554856e4912b7583c194d7035c5 | heat_admin |
| 5a0a143565fd434c8d4aa97018b5b297 | glance     |
| af0925d1577148daa4ed59101c4d1024 | cinder     |
| a7cd5850d9e348f6a89289f058029df2 | nova       |
| cf621b8e58e94b038c0f0f47dc360bdf | placement  |
| 0c65e062555b4822a7f5766b2f7a435d | neutron    |
| 946145b289724225876449b4a930011a | swift      |
| 002c3b03773d4cd2ab0e107d4131fbf4 | heat       |
| 9a8f9921c7c64dd6aa13e6c0fbd29724 | heat-cfn   |
| e8602990b8a94995ab28d03209e38dbf | gnocchi    |
| 63ffe94c316f4ec4855b4055cb2b961d | ceilometer |
| 5b6889742cca47d28d627bfa08134163 | aodh       |
| b0fdb1184a064a69a7d20fb1c85db5af | chencuo    |
+----------------------------------+------------+

绑定用户与项目

[root@controller ~(keystone_admin)]# openstack role list    ##查看角色
+----------------------------------+------------------+
| ID                               | Name             |
+----------------------------------+------------------+
| 27cf4be93baa464da30508d8922853b8 | member           |
| 33b9ba483ac245dc8825cb004a247cc8 | heat_stack_owner |
| 778a5af2d5ed4738868ab9b1121d40ba | _member_         |
| 9d4556d5db4d45ae8e67d3af43bde797 | heat_stack_user  |
| a3b83e027a29460b881138354deca9a0 | ResellerAdmin    |
| ab2810ceed1b4efeb67b68dac008bfc5 | SwiftOperator    |
| dca9ac360a124cfaaf20988693d7c12d | reader           |
| ecc3f36fad1b4923943ab48604cf41e5 | admin            |
+----------------------------------+------------------+
[root@controller ~(keystone_admin)]# openstack role add --user chencuo --project chencuo _member_
##将chencuo用户绑定于chencuo项目,指定角色为_member_

创建规格

[root@controller ~(keystone_admin)]# openstack flavor list    ##查看所有规格
+----+-----------+-------+------+-----------+-------+-----------+
| ID | Name      |   RAM | Disk | Ephemeral | VCPUs | Is Public |
+----+-----------+-------+------+-----------+-------+-----------+
| 1  | m1.tiny   |   512 |    1 |         0 |     1 | True      |
| 2  | m1.small  |  2048 |   20 |         0 |     1 | True      |
| 3  | m1.medium |  4096 |   40 |         0 |     2 | True      |
| 4  | m1.large  |  8192 |   80 |         0 |     4 | True      |
| 5  | m1.xlarge | 16384 |  160 |         0 |     8 | True      |
+----+-----------+-------+------+-----------+-------+-----------+
[root@controller ~(keystone_admin)]# openstack flavor create --ram 1024 --disk 1 --vcpus 1 m2.tiny
##创建规格,根磁盘1GB,vcp1个,1024mb内存
+----------------------------+--------------------------------------+
| Field                      | Value                                |
+----------------------------+--------------------------------------+
| OS-FLV-DISABLED:disabled   | False                                |
| OS-FLV-EXT-DATA:ephemeral  | 0                                    |
| disk                       | 1                                    |
| id                         | 96fe769d-8e30-4c9f-b37c-73d00808a28e |
| name                       | m2.tiny                              |
| os-flavor-access:is_public | True                                 |
| properties                 |                                      |
| ram                        | 1024                                 |
| rxtx_factor                | 1.0                                  |
| swap                       |                                      |
| vcpus                      | 1                                    |
+----------------------------+--------------------------------------+
[root@controller ~(keystone_admin)]# openstack flavor list  ##再次查看规格
+--------------------------------------+-----------+-------+------+-----------+-------+-----------+
| ID                                   | Name      |   RAM | Disk | Ephemeral | VCPUs | Is Public |
+--------------------------------------+-----------+-------+------+-----------+-------+-----------+
| 1                                    | m1.tiny   |   512 |    1 |         0 |     1 | True      |
| 2                                    | m1.small  |  2048 |   20 |         0 |     1 | True      |
| 3                                    | m1.medium |  4096 |   40 |         0 |     2 | True      |
| 4                                    | m1.large  |  8192 |   80 |         0 |     4 | True      |
| 5                                    | m1.xlarge | 16384 |  160 |         0 |     8 | True      |
| 96fe769d-8e30-4c9f-b37c-73d00808a28e | m2.tiny   |  1024 |    1 |         0 |     1 | True      |
+--------------------------------------+-----------+-------+------+-----------+-------+-----------+

创建镜像

使用winscp等远程连接工具,将镜像传入控制节点中

[root@controller ~(keystone_admin)]# mv cirros-0.6.1-x86_64-disk.img /tmp/
[root@controller ~(keystone_admin)]# ls /tmp/cirros-0.6.1-x86_64-disk.img 
/tmp/cirros-0.6.1-x86_64-disk.img
[root@controller ~(keystone_admin)]# openstack image create --disk-format qcow2 --container-format bare --public --file /tmp/cirros-0.6.1-x86_64-disk.img centos 
##指定镜像规格为 QCOW2,公有,裸格式,名称为centos
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| Field            | Value                                                                                                                                      |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
| container_format | bare                                                                                                                                       |
| created_at       | 2024-08-26T12:04:44Z                                                                                                                       |
| disk_format      | qcow2                                                                                                                                      |
| file             | /v2/images/b23335c5-6b40-495b-9623-08e7e66d0885/file                                                                                       |
| id               | b23335c5-6b40-495b-9623-08e7e66d0885                                                                                                       |
| min_disk         | 0                                                                                                                                          |
| min_ram          | 0                                                                                                                                          |
| name             | centos                                                                                                                                     |
| owner            | 8c5563f26cbd401e8d531456275304e5                                                                                                           |
| properties       | os_hidden='False', owner_specified.openstack.md5='', owner_specified.openstack.object='images/centos', owner_specified.openstack.sha256='' |
| protected        | False                                                                                                                                      |
| schema           | /v2/schemas/image                                                                                                                          |
| status           | queued                                                                                                                                     |
| tags             |                                                                                                                                            |
| updated_at       | 2024-08-26T12:04:44Z                                                                                                                       |
| visibility       | public                                                                                                                                     |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------+
[root@controller ~(keystone_admin)]# openstack image list   ##查看镜像
+--------------------------------------+--------+--------+
| ID                                   | Name   | Status |
+--------------------------------------+--------+--------+
| b23335c5-6b40-495b-9623-08e7e66d0885 | centos | active |
+--------------------------------------+--------+--------+

创建公网

[root@controller ~(keystone_admin)]# openstack network create --provider-network-type flat --provider-physical-network extnet --external --share --project chencuo public
##创建网络,提供者为flat,物理网络为extnet,external解释网络为外部网络,共享,绑定的项目为chencuo,网络名称为public
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | UP                                   |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2024-08-26T12:12:21Z                 |
| description               |                                      |
| dns_domain                | None                                 |
| id                        | b61073d3-1d4b-4bcd-a506-46319b52cc42 |
| ipv4_address_scope        | None                                 |
| ipv6_address_scope        | None                                 |
| is_default                | False                                |
| is_vlan_transparent       | None                                 |
| mtu                       | 1500                                 |
| name                      | public                               |
| port_security_enabled     | True                                 |
| project_id                | b8bf06fc744347788603994ab9a85760     |
| provider:network_type     | flat                                 |
| provider:physical_network | extnet                               |
| provider:segmentation_id  | None                                 |
| qos_policy_id             | None                                 |
| revision_number           | 1                                    |
| router:external           | External                             |
| segments                  | None                                 |
| shared                    | True                                 |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      |                                      |
| updated_at                | 2024-08-26T12:12:22Z                 |
+---------------------------+--------------------------------------+
[root@controller ~(keystone_admin)]# openstack network list   ##查看网络列表
+--------------------------------------+--------+---------+
| ID                                   | Name   | Subnets |
+--------------------------------------+--------+---------+
| b61073d3-1d4b-4bcd-a506-46319b52cc42 | public |         |
+--------------------------------------+--------+---------+

公网子网

[root@controller ~(keystone_admin)]# openstack subnet create –subnet-range 192.168.100.0/24 –gateway 192.168.100.2 –dhcp –allocation-pool start=192.168.100.20,end=192.168.100.30 –network public public_subnet

创建公网子网,网关为192.168.100.2,开启dhcp,地址池为20-30ip,指定所归属的网络为public,名称为public_subnet
+———————-+————————————–+
| Field | Value |
+———————-+————————————–+
| allocation_pools | 192.168.100.20-192.168.100.30 |
| cidr | 192.168.100.0/24 |
| created_at | 2024-08-26T12:16:44Z |
| description | |
| dns_nameservers | |
| dns_publish_fixed_ip | None |
| enable_dhcp | True |
| gateway_ip | 192.168.100.2 |
| host_routes | |
| id | eb9ad192-0829-49f7-a578-3cb9919310a2 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| name | public_subnet |
| network_id | b61073d3-1d4b-4bcd-a506-46319b52cc42 |
| prefix_length | None |
| project_id | 8c5563f26cbd401e8d531456275304e5 |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2024-08-26T12:16:44Z |
+———————-+————————————–+
[root@controller ~(keystone_admin)]# openstack subnet list ##查看子网列表
+————————————–+—————+————————————–+——————+
| ID | Name | Network | Subnet |
+————————————–+—————+————————————–+——————+
| eb9ad192-0829-49f7-a578-3cb9919310a2 | public_subnet | b61073d3-1d4b-4bcd-a506-46319b52cc42 | 192.168.100.0/24 |
+————————————–+—————+————————————–+——————+

自定义用户

设置变量文件

[root@controller ~(keystone_admin)]# cp keystonerc_admin keystonerc_chencuo
[root@controller ~(keystone_admin)]# vim keystonerc_
keystonerc_admin    keystonerc_chencuo  
[root@controller ~(keystone_admin)]# vim keystonerc_chencuo 
[root@controller ~(keystone_admin)]# cat keystonerc_chencuo 
unset OS_SERVICE_TOKEN
    export OS_USERNAME=chencuo
    export OS_PASSWORD='123456'
    export OS_REGION_NAME=RegionOne
    export OS_AUTH_URL=http://192.168.100.128:5000/v3
    export PS1='[\u@\h \W(keystone_chencuo)]\$ '
    
export OS_PROJECT_NAME=chencuo
export OS_USER_DOMAIN_NAME=Default
export OS_PROJECT_DOMAIN_NAME=Default
export OS_IDENTITY_API_VERSION=3
export OS_PASSWORD='你设置的密码'
    
##更改以下变量
export OS_USERNAME=你自定义用户名称
export PS1='[\u@\h \W(keystone_自定义用户名称)]\$ '
export OS_PROJECT_NAME=自定义用户名称

加载自定义用户

[root@controller ~(keystone_admin)]# source keystonerc_chencuo 

创建私网

[root@controller ~(keystone_chencuo)]# openstack network create private  ##创建私网
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | UP                                   |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2024-08-26T12:36:20Z                 |
| description               |                                      |
| dns_domain                | None                                 |
| id                        | 1c241efe-8c21-4faa-a194-0eb69937f6f1 |
| ipv4_address_scope        | None                                 |
| ipv6_address_scope        | None                                 |
| is_default                | False                                |
| is_vlan_transparent       | None                                 |
| mtu                       | 1442                                 |
| name                      | private                              |
| port_security_enabled     | True                                 |
| project_id                | b8bf06fc744347788603994ab9a85760     |
| provider:network_type     | None                                 |
| provider:physical_network | None                                 |
| provider:segmentation_id  | None                                 |
| qos_policy_id             | None                                 |
| revision_number           | 1                                    |
| router:external           | Internal                             |
| segments                  | None                                 |
| shared                    | False                                |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      |                                      |
| updated_at                | 2024-08-26T12:36:20Z                 |
+---------------------------+--------------------------------------+
[root@controller ~(keystone_chencuo)]# openstack network list   ##查看网络列表
+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 1c241efe-8c21-4faa-a194-0eb69937f6f1 | private |                                      |
| b61073d3-1d4b-4bcd-a506-46319b52cc42 | public  | eb9ad192-0829-49f7-a578-3cb9919310a2 |
+--------------------------------------+---------+--------------------------------------+

创建私网子网

[root@controller ~(keystone_chencuo)]# openstack subnet create --subnet-range 192.168.88.0/24 --gateway 192.168.88.254 --dhcp --network private private_subnet
## 指定网段为88网段,网关88.254,开启dhcp,指定所对应的网络为private,私网子网名称为private_subnet
+----------------------+--------------------------------------+
| Field                | Value                                |
+----------------------+--------------------------------------+
| allocation_pools     | 192.168.88.1-192.168.88.253          |
| cidr                 | 192.168.88.0/24                      |
| created_at           | 2024-08-26T12:41:23Z                 |
| description          |                                      |
| dns_nameservers      |                                      |
| dns_publish_fixed_ip | None                                 |
| enable_dhcp          | True                                 |
| gateway_ip           | 192.168.88.254                       |
| host_routes          |                                      |
| id                   | 9403b16d-cb2f-46b7-ba81-6eced5a8ed4a |
| ip_version           | 4                                    |
| ipv6_address_mode    | None                                 |
| ipv6_ra_mode         | None                                 |
| name                 | private_subnet                       |
| network_id           | 1c241efe-8c21-4faa-a194-0eb69937f6f1 |
| prefix_length        | None                                 |
| project_id           | b8bf06fc744347788603994ab9a85760     |
| revision_number      | 0                                    |
| segment_id           | None                                 |
| service_types        |                                      |
| subnetpool_id        | None                                 |
| tags                 |                                      |
| updated_at           | 2024-08-26T12:41:23Z                 |
+----------------------+--------------------------------------+
[root@controller ~(keystone_chencuo)]# openstack network list  ##查看网络列表
+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 1c241efe-8c21-4faa-a194-0eb69937f6f1 | private | 9403b16d-cb2f-46b7-ba81-6eced5a8ed4a |
| b61073d3-1d4b-4bcd-a506-46319b52cc42 | public  | eb9ad192-0829-49f7-a578-3cb9919310a2 |
+--------------------------------------+---------+--------------------------------------+

创建路由

[root@controller ~(keystone_chencuo)]# openstack router create router01   ##创建路由为router01
+-------------------------+--------------------------------------+
| Field                   | Value                                |
+-------------------------+--------------------------------------+
| admin_state_up          | UP                                   |
| availability_zone_hints |                                      |
| availability_zones      |                                      |
| created_at              | 2024-08-26T12:44:21Z                 |
| description             |                                      |
| external_gateway_info   | null                                 |
| flavor_id               | None                                 |
| id                      | b84c9f6b-3dd2-4eb4-baf0-e8ee534cd471 |
| name                    | router01                             |
| project_id              | b8bf06fc744347788603994ab9a85760     |
| revision_number         | 1                                    |
| routes                  |                                      |
| status                  | ACTIVE                               |
| tags                    |                                      |
| updated_at              | 2024-08-26T12:44:21Z                 |
+-------------------------+--------------------------------------+
[root@controller ~(keystone_chencuo)]# openstack router list   ##查看路由列表
+--------------------------------------+----------+--------+-------+----------------------------------+
| ID                                   | Name     | Status | State | Project                          |
+--------------------------------------+----------+--------+-------+----------------------------------+
| b84c9f6b-3dd2-4eb4-baf0-e8ee534cd471 | router01 | ACTIVE | UP    | b8bf06fc744347788603994ab9a85760 |
+--------------------------------------+----------+--------+-------+----------------------------------+

创建路由网关

[root@controller ~(keystone_chencuo)]# openstack router set router01 --external-gateway public
##创建router01的路由网关,外部接口为public
[root@controller ~(keystone_chencuo)]# openstack router show router01  ##展示router01路由
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field                   | Value                                                                                                                                                                                      |
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| admin_state_up          | UP                                                                                                                                                                                         |
| availability_zone_hints |                                                                                                                                                                                            |
| availability_zones      |                                                                                                                                                                                            |
| created_at              | 2024-08-26T12:44:21Z                                                                                                                                                                       |
| description             |                                                                                                                                                                                            |
| external_gateway_info   | {"network_id": "b61073d3-1d4b-4bcd-a506-46319b52cc42", "external_fixed_ips": [{"subnet_id": "eb9ad192-0829-49f7-a578-3cb9919310a2", "ip_address": "192.168.100.30"}], "enable_snat": true} |
| flavor_id               | None                                                                                                                                                                                       |
| id                      | b84c9f6b-3dd2-4eb4-baf0-e8ee534cd471                                                                                                                                                       |
| interfaces_info         | []                                                                                                                                                                                         |
| name                    | router01                                                                                                                                                                                   |
| project_id              | b8bf06fc744347788603994ab9a85760                                                                                                                                                           |
| revision_number         | 3                                                                                                                                                                                          |
| routes                  |                                                                                                                                                                                            |
| status                  | ACTIVE                                                                                                                                                                                     |
| tags                    |                                                                                                                                                                                            |
| updated_at              | 2024-08-26T12:46:46Z                                                                                                                                                                       |
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

创建路由子接口

[root@controller ~(keystone_chencuo)]# openstack router add subnet router01 private_subnet
##为路由添加私网子接口
[root@controller ~(keystone_chencuo)]# openstack router show router01  ##再次查看路由信息
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field                   | Value                                                                                                                                                                                      |
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| admin_state_up          | UP                                                                                                                                                                                         |
| availability_zone_hints |                                                                                                                                                                                            |
| availability_zones      |                                                                                                                                                                                            |
| created_at              | 2024-08-26T12:44:21Z                                                                                                                                                                       |
| description             |                                                                                                                                                                                            |
| external_gateway_info   | {"network_id": "b61073d3-1d4b-4bcd-a506-46319b52cc42", "external_fixed_ips": [{"subnet_id": "eb9ad192-0829-49f7-a578-3cb9919310a2", "ip_address":  "192.168.100.30"}], "enable_snat": true} |
| flavor_id               | None                                                                                                                                                                                       |
| id                      | b84c9f6b-3dd2-4eb4-baf0-e8ee534cd471                                                                                                                                                       |
| interfaces_info         | [{"port_id": "01e44837-2a01-411a-9918-43eee690f6a1", "ip_address": "192.168.88.254", "subnet_id": "9403b16d-cb2f-46b7-ba81-6eced5a8ed4a"}]                                                 |
| name                    | router01                                                                                                                                                                                   |
| project_id              | b8bf06fc744347788603994ab9a85760                                                                                                                                                           |
| revision_number         | 4                                                                                                                                                                                          |
| routes                  |                                                                                                                                                                                            |
| status                  | ACTIVE                                                                                                                                                                                     |
| tags                    |                                                                                                                                                                                            |
| updated_at              | 2024-08-26T12:51:36Z                                                                                                                                                                       |
+-------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+

配置安全组

[root@controller ~(keystone_chencuo)]# openstack security group list  ##查看安全组
+--------------------------------------+---------+-------------+----------------------------------+------+
| ID                                   | Name    | Description | Project                          | Tags |
+--------------------------------------+---------+-------------+----------------------------------+------+
| 33bafc38-071e-40ac-a210-107391e8c454 | default | 缺省安全组  | b8bf06fc744347788603994ab9a85760 | []   |
+--------------------------------------+---------+-------------+----------------------------------+------+
[root@controller ~(keystone_chencuo)]# openstack security group rule list  ##查看安全组规则
+--------------------------------------+-------------+-----------+-----------+------------+--------------------------------------+--------------------------------------+
| ID                                   | IP Protocol | Ethertype | IP Range  | Port Range | Remote Security Group                | Security Group                       |
+--------------------------------------+-------------+-----------+-----------+------------+--------------------------------------+--------------------------------------+
| 3b8132d6-81a5-4b1c-8c18-6268a410defe | None        | IPv4      | 0.0.0.0/0 |            | 33bafc38-071e-40ac-a210-107391e8c454 | 33bafc38-071e-40ac-a210-107391e8c454 |
| 6a3d3995-1879-4250-990c-c5f58cd7a00d | None        | IPv4      | 0.0.0.0/0 |            | None                                 | 33bafc38-071e-40ac-a210-107391e8c454 |
| 89a2a8b6-7c3b-4adf-bbd6-e6a9e7aa3790 | None        | IPv6      | ::/0      |            | None                                 | 33bafc38-071e-40ac-a210-107391e8c454 |
| f08e2312-2820-4670-8005-07dfe889b4b2 | None        | IPv6      | ::/0      |            | 33bafc38-071e-40ac-a2[root@[[root@controller ~(keys[[[[[[root@controller ~(keystone_chencuo)]# openstack security group rule create --protocol icmp --ingress default
## 添加安全组规程icmp规则
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2024-08-26T12:56:57Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | 82eea13f-4e34-4f9e-bfcc-55b8b0a378aa |
| name              | None                                 |
| port_range_max    | None                                 |
| port_range_min    | None                                 |
| project_id        | b8bf06fc744347788603994ab9a85760     |
| protocol          | icmp                                 |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 0                                    |
| security_group_id | 33bafc38-071e-40ac-a210-107391e8c454 |
| tags              | []                                   |
| updated_at        | 2024-08-26T12:56:57Z                 |
+-------------------+--------------------------------------+
[root@controller ~(keystone_chencuo)]# openstack security group rule create --protocol tcp --dst-port 22:22 --ingress default
## 添加安全组规则ssh
+-------------------+--------------------------------------+
| Field             | Value                                |
+-------------------+--------------------------------------+
| created_at        | 2024-08-26T12:57:16Z                 |
| description       |                                      |
| direction         | ingress                              |
| ether_type        | IPv4                                 |
| id                | fb20901f-7e24-4502-9f57-6377175714ef |
| name              | None                                 |
| port_range_max    | 22                                   |
| port_range_min    | 22                                   |
| project_id        | b8bf06fc744347788603994ab9a85760     |
| protocol          | tcp                                  |
| remote_group_id   | None                                 |
| remote_ip_prefix  | 0.0.0.0/0                            |
| revision_number   | 0                                    |
| security_group_id | 33bafc38-071e-40ac-a210-107391e8c454 |
| tags              | []                                   |
| updated_at        | 2024-08-26T12:57:16Z                 |
+-------------------+--------------------------------------+
[root@controller ~(keystone_chencuo)]# openstack security group rule list  ##再次查看安全组规则
+--------------------------------------+-------------+-----------+-----------+------------+--------------------------------------+--------------------------------------+
| ID                                   | IP Protocol | Ethertype | IP Range  | Port Range | Remote Security Group                | Security Group                       |
+--------------------------------------+-------------+-----------+-----------+------------+--------------------------------------+--------------------------------------+
| 3b8132d6-81a5-4b1c-8c18-6268a410defe | None        | IPv4      | 0.0.0.0/0 |            | 33bafc38-071e-40ac-a210-107391e8c454 | 33bafc38-071e-40ac-a210-107391e8c454 |
| 6a3d3995-1879-4250-990c-c5f58cd7a00d | None        | IPv4      | 0.0.0.0/0 |            | None                                 | 33bafc38-071e-40ac-a210-107391e8c454 |
| 82eea13f-4e34-4f9e-bfcc-55b8b0a378aa | icmp        | IPv4      | 0.0.0.0/0 |            | None                                 | 33bafc38-071e-40ac-a210-107391e8c454 |
| 89a2a8b6-7c3b-4adf-bbd6-e6a9e7aa3790 | None        | IPv6      | ::/0      |            | None                                 | 33bafc38-071e-40ac-a210-107391e8c454 |
| f08e2312-2820-4670-8005-07dfe889b4b2 | None        | IPv6      | ::/0      |            | 33bafc38-071e-40ac-a210-107391e8c454 | 33bafc38-071e-40ac-a210-107391e8c454 |
| fb20901f-7e24-4502-9f57-6377175714ef | tcp         | IPv4      | 0.0.0.0/0 | 22:22      | None                                 | 33bafc38-071e-40ac-a210-107391e8c454 |
+--------------------------------------+-------------+-----------+-----------+------------+--------------------------------------+--------------------------------------+

发放云主机

获取实例所需参数

[root@controller ~(keystone_chencuo)]# openstack flavor list  ##查看规格
+--------------------------------------+-----------+-------+------+-----------+-------+-----------+
| ID                                   | Name      |   RAM | Disk | Ephemeral | VCPUs | Is Public |
+--------------------------------------+-----------+-------+------+-----------+-------+-----------+
| 1                                    | m1.tiny   |   512 |    1 |         0 |     1 | True      |
| 2                                    | m1.small  |  2048 |   20 |         0 |     1 | True      |
| 3                                    | m1.medium |  4096 |   40 |         0 |     2 | True      |
| 4                                    | m1.large  |  8192 |   80 |         0 |     4 | True      |
| 5                                    | m1.xlarge | 16384 |  160 |         0 |     8 | True      |
| 96fe769d-8e30-4c9f-b37c-73d00808a28e | m2.tiny   |  1024 |    1 |         0 |     1 | True      |
+--------------------------------------+-----------+-------+------+-----------+-------+-----------+
[root@controller ~(keystone_chencuo)]# openstack image list  ##查看镜像
+--------------------------------------+--------+--------+
| ID                                   | Name   | Status |
+--------------------------------------+--------+--------+
| b23335c5-6b40-495b-9623-08e7e66d0885 | centos | active |
+--------------------------------------+--------+--------+
[root@controller ~(keystone_chencuo)]# openstack security group list  ##查看安全组规则
+--------------------------------------+---------+-------------+----------------------------------+------+
| ID                                   | Name    | Description | Project                          | Tags |
+--------------------------------------+---------+-------------+----------------------------------+------+
| 33bafc38-071e-40ac-a210-107391e8c454 | default | 缺省安全组  | b8bf06fc744347788603994ab9a85760 | []   |
+--------------------------------------+---------+-------------+----------------------------------+------+
[root@controller ~(keystone_chencuo)]# openstack network list  ##查看网络列表
+--------------------------------------+---------+--------------------------------------+
| ID                                   | Name    | Subnets                              |
+--------------------------------------+---------+--------------------------------------+
| 1c241efe-8c21-4faa-a194-0eb69937f6f1 | private | 9403b16d-cb2f-46b7-ba81-6eced5a8ed4a |
| b61073d3-1d4b-4bcd-a506-46319b52cc42 | public  | eb9ad192-0829-49f7-a578-3cb9919310a2 |
+--------------------------------------+---------+--------------------------------------+

发放云主机

[root@controller ~(keystone_chencuo)]# openstack server create --flavor m2.tiny --image centos --min 1 --security-group default --nic net-id=1c241efe-8c21-4faa-a194-0eb69937f6f1 chencuodadi
## 指定规格为m2.tiny,指定镜像centos,镜像卷数为1,安全组为default,网络为私网的id,请根据自己的实际更改
+-----------------------------+------------------------------------------------+
| Field                       | Value                                          |
+-----------------------------+------------------------------------------------+
| OS-DCF:diskConfig           | MANUAL                                         |
| OS-EXT-AZ:availability_zone |                                                |
| OS-EXT-STS:power_state      | NOSTATE                                        |
| 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                   | 4gpo7trxiGN7                                   |
| config_drive                |                                                |
| created                     | 2024-08-26T13:08:34Z                           |
| flavor                      | m2.tiny (96fe769d-8e30-4c9f-b37c-73d00808a28e) |
| hostId                      |                                                |
| id                          | ab1200e5-8285-4b37-a8e0-98a461f1a591           |
| image                       | centos (b23335c5-6b40-495b-9623-08e7e66d0885)  |
| key_name                    | None                                           |
| name                        | chencuodadi                                    |
| progress                    | 0                                              |
| project_id                  | b8bf06fc744347788603994ab9a85760               |
| properties                  |                                                |
| security_groups             | name='33bafc38-071e-40ac-a210-107391e8c454'    |
| status                      | BUILD                                          |
| updated                     | 2024-08-26T13:08:35Z                           |
| user_id                     | b0fdb1184a064a69a7d20fb1c85db5af               |
| volumes_attached            |                                                |
+-----------------------------+------------------------------------------------+
[root@controller ~(keystone_chencuo)]# 
[root@controller ~(keystone_chencuo)]# opoenstack server list
bash: opoenstack: 未找到命令...
[root@controller ~(keystone_chencuo)]# openstack server list   ##查看实例列表
+--------------------------------------+-------------+--------+-----------------------+--------+---------+
| ID                                   | Name        | Status | Networks              | Image  | Flavor  |
+--------------------------------------+-------------+--------+-----------------------+--------+---------+
| ab1200e5-8285-4b37-a8e0-98a461f1a591 | chencuodadi | ACTIVE | private=192.168.88.50 | centos | m2.tiny |
+--------------------------------------+-------------+--------+-----------------------+--------+---------+

绑定EIP

分配EIP

[root@controller ~(keystone_chencuo)]# openstack floating ip create public  ##分配public浮动ip
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| created_at          | 2024-08-26T13:14:18Z                 |
| description         |                                      |
| dns_domain          | None                                 |
| dns_name            | None                                 |
| fixed_ip_address    | None                                 |
| floating_ip_address | 192.168.100.25                       |
| floating_network_id | b61073d3-1d4b-4bcd-a506-46319b52cc42 |
| id                  | 1664702a-b3f1-43b8-8d3c-5da33d36381f |
| name                | 192.168.100.25                       |
| port_details        | None                                 |
| port_id             | None                                 |
| project_id          | b8bf06fc744347788603994ab9a85760     |
| qos_policy_id       | None                                 |
| revision_number     | 0                                    |
| router_id           | None                                 |
| status              | DOWN                                 |
| subnet_id           | None                                 |
| tags                | []                                   |
| updated_at          | 2024-08-26T13:14:18Z                 |
+---------------------+--------------------------------------+
[root@controller ~(keystone_chencuo)]# openstack floating ip list ##查看浮动ip
+--------------------------------------+---------------------+------------------+------+--------------------------------------+----------------------------------+
| ID                                   | Floating IP Address | Fixed IP Address | Port | Floating Network                     | Project                          |
+--------------------------------------+---------------------+------------------+------+--------------------------------------+----------------------------------+
| 1664702a-b3f1-43b8-8d3c-5da33d36381f | 192.168.100.25      | None             | None | b61073d3-1d4b-4bcd-a506-46319b52cc42 | b8bf06fc744347788603994ab9a85760 |
+--------------------------------------+---------------------+------------------+------+--------------------------------------+----------------------------------+
[root@controller ~(keystone_chencuo)]# openstack server add floating ip chencuodadi  192.168.100.25
## 为chencuodadi 添加 25的浮动ip,浮动ip从分配处查看

访问测试

虚拟机ping实例

[root@controller ~(keystone_chencuo)]# ping 192.168.100.25
PING 192.168.100.25 (192.168.100.25) 56(84) bytes of data.
64 bytes from 192.168.100.25: icmp_seq=1 ttl=63 time=34.3 ms
64 bytes from 192.168.100.25: icmp_seq=2 ttl=63 time=3.34 ms
^C
--- 192.168.100.25 ping statistics ---
2 packets transmitted, 2 received, 0% packet loss, time 1001ms
rtt min/avg/max/mdev = 3.339/18.807/34.276/15.469 ms

虚拟机远程连接实例

[root@controller ~(keystone_chencuo)]# ssh cirros@192.168.100.25
The authenticity of host '192.168.100.25 (192.168.100.25)' can't be established.
ECDSA key fingerprint is SHA256:aRZmboueSAIBu6Z/ME10YK8uadrEwm9pfDcAIr85DlA.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added '192.168.100.25' (ECDSA) to the list of known hosts.
cirros@192.168.100.25's password: 
Permission denied, please try again.
cirros@192.168.100.25's password: 
$ ifconfig 
eth0      Link encap:Ethernet  HWaddr FA:16:3E:D0:24:FD  
          inet addr:192.168.88.50  Bcast:192.168.88.255  Mask:255.255.255.0
          inet6 addr: fe80::f816:3eff:fed0:24fd/64 Scope:Link
          UP BROADCAST RUNNING MULTICAST  MTU:1442  Metric:1
          RX packets:142 errors:0 dropped:0 overruns:0 frame:0
          TX packets:163 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:17188 (16.7 KiB)  TX bytes:14931 (14.5 KiB)

lo        Link encap:Local Loopback  
          inet addr:127.0.0.1  Mask:255.0.0.0
          inet6 addr: ::1/128 Scope:Host
          UP LOOPBACK RUNNING  MTU:65536  Metric:1
          RX packets:0 errors:0 dropped:0 overruns:0 frame:0
          TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
          collisions:0 txqueuelen:1000 
          RX bytes:0 (0.0 B)  TX bytes:0 (0.0 B)
文末附加内容
暂无评论

发送评论 编辑评论


				
|´・ω・)ノ
ヾ(≧∇≦*)ゝ
(☆ω☆)
(╯‵□′)╯︵┴─┴
 ̄﹃ ̄
(/ω\)
∠( ᐛ 」∠)_
(๑•̀ㅁ•́ฅ)
→_→
୧(๑•̀⌄•́๑)૭
٩(ˊᗜˋ*)و
(ノ°ο°)ノ
(´இ皿இ`)
⌇●﹏●⌇
(ฅ´ω`ฅ)
(╯°A°)╯︵○○○
φ( ̄∇ ̄o)
ヾ(´・ ・`。)ノ"
( ง ᵒ̌皿ᵒ̌)ง⁼³₌₃
(ó﹏ò。)
Σ(っ °Д °;)っ
( ,,´・ω・)ノ"(´っω・`。)
╮(╯▽╰)╭
o(*////▽////*)q
>﹏<
( ๑´•ω•) "(ㆆᴗㆆ)
😂
😀
😅
😊
🙂
🙃
😌
😍
😘
😜
😝
😏
😒
🙄
😳
😡
😔
😫
😱
😭
💩
👻
🙌
🖕
👍
👫
👬
👭
🌚
🌝
🙈
💊
😶
🙏
🍦
🍉
😣
Source: github.com/k4yt3x/flowerhd
颜文字
Emoji
小恐龙
花!
上一篇
下一篇