文章目录
- OpenStackT版创建云主机并连接CRT
- 命令行操作
- (1)创建镜像
- (2)创建实例
- (3)创建网络
- 创建内网
- 创建外网
- (4)创建安全组
- (5)创建路由
- (6)创建云主机
- (7)绑定浮动IP
- (8)登录云主机
- (9)CRT连接
- 图形化操作
- (1)创建镜像
- (2)创建实例
- (3)创建网络
- 创建内网
- 创建外网
- (4)创建安全组
- (5)创建路由
- (6)创建云主机
- (7)绑定浮动IP
- (8)登录云主机
OpenStackT版创建云主机并连接CRT
命令行操作
(1)创建镜像
加载 admin user 的环境变量
source admin-openrc.sh
创建镜像
[root@controller ~]# openstack image create --disk-format qcow2 --container-format bare --file /opt/iaas/images/cirros-0.3.4-x86_64-disk.img cirros
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| checksum | ee1eca47dc88f4879d8a229cc70a07c6 |
| container_format | bare |
| created_at | 2023-09-18T09:28:12Z |
| disk_format | qcow2 |
| file | /v2/images/14b16679-354c-4a3c-810c-72506e859378/file |
| id | 14b16679-354c-4a3c-810c-72506e859378 |
| min_disk | 0 |
| min_ram | 0 |
| name | cirros |
| owner | 4f87bd1fe5e2469f81232a201b136a94 |
| properties | os_hash_algo='sha512', os_hash_value='1b03ca1bc3fafe448b90583c12f367949f8b0e665685979d95b004e48574b953316799e23240f4f739d1b5eb4c4ca24d38fdc6f4f9d8247a2bc64db25d6bbdb2', os_hidden='False' |
| protected | False |
| schema | /v2/schemas/image |
| size | 13287936 |
| status | active |
| tags | |
| updated_at | 2023-09-18T09:28:12Z |
| virtual_size | None |
| visibility | shared |
+------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
(2)创建实例
[root@controller ~]# openstack flavor create --disk 20 --ram 2048 --vcpus 2 --id 66 f1
+----------------------------+-------+
| Field | Value |
+----------------------------+-------+
| OS-FLV-DISABLED:disabled | False |
| OS-FLV-EXT-DATA:ephemeral | 0 |
| disk | 20 |
| id | 66 |
| name | f1 |
| os-flavor-access:is_public | True |
| properties | |
| ram | 2048 |
| rxtx_factor | 1.0 |
| swap | |
| vcpus | 2 |
+----------------------------+-------+
(3)创建网络
创建内网
[root@controller ~]# openstack network create --internal int-net
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2023-09-18T09:28:51Z |
| description | |
| dns_domain | None |
| id | 56c46a33-bdcc-4cee-9320-1f4fa2186d59 |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| location | cloud='', project.domain_id=, project.domain_name='demo', project.id='4f87bd1fe5e2469f81232a201b136a94', project.name='admin', region_name='', zone= |
| mtu | 1450 |
| name | int-net |
| port_security_enabled | True |
| project_id | 4f87bd1fe5e2469f81232a201b136a94 |
| provider:network_type | vxlan |
| provider:physical_network | None |
| provider:segmentation_id | 2 |
| qos_policy_id | None |
| revision_number | 1 |
| router:external | Internal |
| segments | None |
| shared | False |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2023-09-18T09:28:51Z |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
创建内网子网
[root@controller ~]# openstack subnet create --allocation-pool start=10.0.0.100,end=10.0.0.200 --network int-net --gateway 10.0.0.1 --subnet-range 10.0.0.0/24 int-sub
+-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
| allocation_pools | 10.0.0.100-10.0.0.200 |
| cidr | 10.0.0.0/24 |
| created_at | 2023-09-18T09:28:58Z |
| description | |
| dns_nameservers | |
| enable_dhcp | True |
| gateway_ip | 10.0.0.1 |
| host_routes | |
| id | decd6a73-b68c-4011-877e-ca2006954aa6 |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| location | cloud='', project.domain_id=, project.domain_name='demo', project.id='4f87bd1fe5e2469f81232a201b136a94', project.name='admin', region_name='', zone= |
| name | int-sub |
| network_id | 56c46a33-bdcc-4cee-9320-1f4fa2186d59 |
| prefix_length | None |
| project_id | 4f87bd1fe5e2469f81232a201b136a94 |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2023-09-18T09:28:58Z |
+-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
创建外网
[root@controller ~]# openstack network create --provider-network-type flat --provider-physical-network provider --external --share ext-net
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
| admin_state_up | UP |
| availability_zone_hints | |
| availability_zones | |
| created_at | 2023-09-18T09:29:06Z |
| description | |
| dns_domain | None |
| id | 2aad11ac-a91a-4ccd-99b9-de3a2c69c386 |
| ipv4_address_scope | None |
| ipv6_address_scope | None |
| is_default | False |
| is_vlan_transparent | None |
| location | cloud='', project.domain_id=, project.domain_name='demo', project.id='4f87bd1fe5e2469f81232a201b136a94', project.name='admin', region_name='', zone= |
| mtu | 1500 |
| name | ext-net |
| port_security_enabled | True |
| project_id | 4f87bd1fe5e2469f81232a201b136a94 |
| provider:network_type | flat |
| provider:physical_network | provider |
| provider:segmentation_id | None |
| qos_policy_id | None |
| revision_number | 1 |
| router:external | External |
| segments | None |
| shared | True |
| status | ACTIVE |
| subnets | |
| tags | |
| updated_at | 2023-09-18T09:29:06Z |
+---------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
创建外网子网
[root@controller ~]# openstack subnet create --allocation-pool start=192.168.200.100,end=192.168.200.200 --network ext-net --gateway 192.168.200.2 --subnet-range 192.168.200.0/24 ext-sub
+-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
| allocation_pools | 192.168.200.100-192.168.200.200 |
| cidr | 192.168.200.0/24 |
| created_at | 2023-09-18T09:29:12Z |
| description | |
| dns_nameservers | |
| enable_dhcp | True |
| gateway_ip | 192.168.200.2 |
| host_routes | |
| id | cfc2d24a-09f3-4786-a699-9e320ef6454f |
| ip_version | 4 |
| ipv6_address_mode | None |
| ipv6_ra_mode | None |
| location | cloud='', project.domain_id=, project.domain_name='demo', project.id='4f87bd1fe5e2469f81232a201b136a94', project.name='admin', region_name='', zone= |
| name | ext-sub |
| network_id | 2aad11ac-a91a-4ccd-99b9-de3a2c69c386 |
| prefix_length | None |
| project_id | 4f87bd1fe5e2469f81232a201b136a94 |
| revision_number | 0 |
| segment_id | None |
| service_types | |
| subnetpool_id | None |
| tags | |
| updated_at | 2023-09-18T09:29:12Z |
+-------------------+------------------------------------------------------------------------------------------------------------------------------------------------------+
(4)创建安全组
创建安全组group
[root@controller ~]# openstack security group create group
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
| created_at | 2023-09-18T09:30:36Z |
| description | group |
| id | 388476f1-1cf1-46c3-8d2a-8e346aee3600 |
| location | cloud='', project.domain_id=, project.domain_name='demo', project.id='4f87bd1fe5e2469f81232a201b136a94', project.name='admin', region_name='', zone= |
| name | group |
| project_id | 4f87bd1fe5e2469f81232a201b136a94 |
| revision_number | 1 |
| rules | created_at='2023-09-18T09:30:36Z', direction='egress', ethertype='IPv6', id='93d39c18-4735-4eb8-97b6-edafa3f91029', updated_at='2023-09-18T09:30:36Z' |
| | created_at='2023-09-18T09:30:36Z', direction='egress', ethertype='IPv4', id='a2fc2876-eb44-4ed9-a728-a892d46b37a5', updated_at='2023-09-18T09:30:36Z' |
| tags | [] |
| updated_at | 2023-09-18T09:30:36Z |
+-----------------+-------------------------------------------------------------------------------------------------------------------------------------------------------+
放行所有icmp入口出口
[root@controller ~]# openstack security group rule create --ingress --protocol icmp group
[root@controller ~]# openstack security group rule create --egress --protocol icmp group
放行所有tcp入口出口
[root@controller ~]# openstack security group rule create --ingress --protocol tcp group
[root@controller ~]# openstack security group rule create --egress --protocol tcp group
放行所有udp入口出口
[root@controller ~]# openstack security group rule create --ingress --protocol udp group
[root@controller ~]# openstack security group rule create --egress --protocol udp group
(5)创建路由
[root@controller ~]# openstack router create router
[root@controller ~]# openstack router set --external-gateway ext-net router
[root@controller ~]# openstack router add subnet router int-sub
(6)创建云主机
[root@controller ~]# openstack server create --image cirros --flavor 66 --network int-net --security-group group server1
+-------------------------------------+-----------------------------------------------+
| Field | Value |
+-------------------------------------+-----------------------------------------------+
| OS-DCF:diskConfig | MANUAL |
| OS-EXT-AZ:availability_zone | |
| OS-EXT-SRV-ATTR:host | None |
| OS-EXT-SRV-ATTR:hypervisor_hostname | None |
| OS-EXT-SRV-ATTR:instance_name | |
| 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 | k9NCCHbqJxAA |
| config_drive | |
| created | 2023-09-18T09:32:35Z |
| flavor | f1 (66) |
| hostId | |
| id | bc9a8506-d2e8-4357-9a9e-6f691c0e6ac8 |
| image | cirros (14b16679-354c-4a3c-810c-72506e859378) |
| key_name | None |
| name | server1 |
| progress | 0 |
| project_id | 4f87bd1fe5e2469f81232a201b136a94 |
| properties | |
| security_groups | name='388476f1-1cf1-46c3-8d2a-8e346aee3600' |
| status | BUILD |
| updated | 2023-09-18T09:32:36Z |
| user_id | 25ac2dd543554ccfbea43aabbd23182c |
| volumes_attached | |
+-------------------------------------+-----------------------------------------------+
查看云主机
[root@controller ~]# openstack server list
+--------------------------------------+---------+--------+--------------------+--------+--------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+---------+--------+--------------------+--------+--------+
| bc9a8506-d2e8-4357-9a9e-6f691c0e6ac8 | server1 | ACTIVE | int-net=10.0.0.194 | cirros | f1 |
+--------------------------------------+---------+--------+--------------------+--------+--------+
(7)绑定浮动IP
首先创建浮动IP
[root@controller ~]# openstack floating ip create ext-net
+---------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field | Value |
+---------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| created_at | 2023-09-18T09:33:13Z |
| description | |
| dns_domain | None |
| dns_name | None |
| fixed_ip_address | None |
| floating_ip_address | 192.168.200.117 |
| floating_network_id | 2aad11ac-a91a-4ccd-99b9-de3a2c69c386 |
| id | 53a4d0ca-2213-4162-baf4-75ba1c1d3ded |
| location | Munch({'project': Munch({'domain_name': 'demo', 'domain_id': None, 'name': 'admin', 'id': u'4f87bd1fe5e2469f81232a201b136a94'}), 'cloud': '', 'region_name': '', 'zone': None}) |
| name | 192.168.200.117 |
| port_details | None |
| port_id | None |
| project_id | 4f87bd1fe5e2469f81232a201b136a94 |
| qos_policy_id | None |
| revision_number | 0 |
| router_id | None |
| status | DOWN |
| subnet_id | None |
| tags | [] |
| updated_at | 2023-09-18T09:33:13Z |
+---------------------+---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
将浮动IP绑定到云主机上
[root@controller ~]# openstack server add floating ip server1 192.168.200.117
查看云主机
[root@controller ~]# openstack server list
+--------------------------------------+---------+--------+-------------------------------------+--------+--------+
| ID | Name | Status | Networks | Image | Flavor |
+--------------------------------------+---------+--------+-------------------------------------+--------+--------+
| bc9a8506-d2e8-4357-9a9e-6f691c0e6ac8 | server1 | ACTIVE | int-net=10.0.0.194, 192.168.200.117 | cirros | f1 |
+--------------------------------------+---------+--------+-------------------------------------+--------+--------+
云主机和本机是互通的
(8)登录云主机
先查看控制台url地址
[root@controller ~]# openstack console url show server1
+-------+-----------------------------------------------------------------------------------------------+
| Field | Value |
+-------+-----------------------------------------------------------------------------------------------+
| type | novnc |
| url | http://192.168.100.10:6080/vnc_auto.html?path=%3Ftoken%3D73cce687-a2f2-4318-9a24-ce7af1c46149 |
+-------+-----------------------------------------------------------------------------------------------+
网页访问
账户:cirros
密码:cubswin:)
看看是否能ping通controller和compute
(9)CRT连接
图形化操作
(1)创建镜像
第一步:
①项目>>②计算>>③镜像>>④创建镜像
第二步:
第三步:
(2)创建实例
第一步:
①管理员>②计算>③实例类型>④创建实例类型
第二步:
第三步:
(3)创建网络
创建内网
第一步:
①项目>②网络>③网络>④创建网络
第二步:
第三步:
第四步:
第五步:
创建外网
第一步:
①管理员>②网络>③网络>④创建网络
第二步:
第四步:
第五步:
第六步:
(4)创建安全组
第一步:
①项目>②网络>③安全组>④创建安全组
第二步:
第三步:
第四步:
添加所有ICMP 所有TCP 所有UDP入口出口
(5)创建路由
第一步:
①项目>②网络>③路由>④新建路由
第二步:
第三步:
第四步:
第五步:
第六步:
(6)创建云主机
第一步:
①项目>②计算>③实例>④创建实例
第二步:
第三步:
第四步:
第五步:
第六步:
第七步:
(7)绑定浮动IP
第一步:
将创建出来的云主机绑定浮动IP
第二步:
第三步:
第四步:
第五步:
(8)登录云主机
第一步:
第二步: