03.OpenStack使用

OpenStack使用

WEB界面实验

创建实例类型(规格)

上传镜像

创建外部网络

创建内网

创建路由器

观察此刻网络拓扑

创建实例

实例创建成功

VNC登录

右击,在新标签页中打开连接

观察此刻网络拓扑

instance1 外网通信测试


CLI实验

还原快照,照着WEB一摸一样再来一遍

创建实例类型(规格)

bash 复制代码
[root@controller ~]# source keystonerc_admin
[root@controller ~(keystone_admin)]# openstack flavor create --help
usage: openstack flavor create [-h] [-f {json,shell,table,value,yaml}]
                               [-c COLUMN] [--noindent] [--prefix PREFIX]
                               [--max-width <integer>] [--fit-width]
                               [--print-empty] [--id <id>] [--ram <size-mb>]
                               [--disk <size-gb>] [--ephemeral <size-gb>]
                               [--swap <size-mb>] [--vcpus <vcpus>]
                               [--rxtx-factor <factor>] [--public | --private]
                               [--property <key=value>] [--project <project>]
                               [--description <description>]
                               [--project-domain <project-domain>]
                               <flavor-name>

Create new flavor

positional arguments:
  <flavor-name>         New flavor name

optional arguments:
  -h, --help            show this help message and exit
  --id <id>             Unique flavor ID; 'auto' creates a UUID (default:
                        auto)
  --ram <size-mb>       Memory size in MB (default 256M)
  --disk <size-gb>      Disk size in GB (default 0G)
  --ephemeral <size-gb>
                        Ephemeral disk size in GB (default 0G)
  --swap <size-mb>      Additional swap space size in MB (default 0M)
  --vcpus <vcpus>       Number of vcpus (default 1)
  --rxtx-factor <factor>
                        RX/TX factor (default 1.0)
  --public              Flavor is available to other projects (default)
  --private             Flavor is not available to other projects
  --property <key=value>
                        Property to add for this flavor (repeat option to set
                        multiple properties)
  --project <project>   Allow <project> to access private flavor (name or ID)
                        (Must be used with --private option)
  --description <description>
                        Description for the flavor.(Supported by API versions
                        '2.55' - '2.latest'
  --project-domain <project-domain>
                        Domain the project belongs to (name or ID). This can
                        be used in case collisions 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
  -c COLUMN, --column COLUMN
                        specify the column(s) to include, can be repeated to
                        show multiple columns

json formatter:
  --noindent            whether to disable indenting the JSON

shell formatter:
  a format a UNIX shell can parse (variable="value")

  --prefix PREFIX       add a prefix to all variable names

table formatter:
  --max-width <integer>
                        Maximum display width, <1 to 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. Implied if --max-
                        width greater than 0. Set the environment variable
                        CLIFF_FIT_WIDTH=1 to always enable
  --print-empty         Print empty table if there is no data to show.
[root@controller ~(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

bash 复制代码
[root@controller ~(keystone_admin)]# openstack image create --file /root/cirros-0.5.2-x86_64-disk.img --disk-format qcow2 --public cirros-0.5.2

创建外部网络

bash 复制代码
[root@controller ~(keystone_admin)]# openstack network create --project-domain admin --provider-network-type flat --provider-physical-network extnet --external waiwang
[root@controller ~(keystone_admin)]# openstack subnet create --subnet-range 192.168.108.0/24 --gateway 192.168.108.2 --allocation-pool start=192.168.108.100,end=192.168.108.200 --network waiwang waiwang_subnet

创建内网

bash 复制代码
[root@controller ~(keystone_admin)]# openstack network create --project-domain admin neiwang1

[root@controller ~(keystone_admin)]# openstack subnet create --subnet-range 172.16.0.0/24 --gateway 172.16.0.1 --allocation-pool start=172.16.0.100,end=172.16.0.200 --dns-nameserver 8.8.8.8 --network neiwang1 neiwang_subnet1

创建路由器

bash 复制代码
[root@controller ~(keystone_admin)]# openstack router create router1
[root@controller ~(keystone_admin)]# openstack router set --external-gateway waiwang router1
[root@controller ~(keystone_admin)]# openstack router add subnet router1 neiwang_subnet1

观察此刻网络拓扑

创建实例

bash 复制代码
[root@controller ~(keystone_admin)]# openstack server create --image cirros-0.5.2 --flavor m1.1u.1g --network neiwang1 instance1

实例创建成功

查看有哪些实例

bash 复制代码
[root@controller ~(keystone_admin)]# openstack server list
+--------------------------------------+-----------+--------+-----------------------+--------------+----------+
| ID                                   | Name      | Status | Networks              | Image        | Flavor   |
+--------------------------------------+-----------+--------+-----------------------+--------------+----------+
| 07e06925-625f-4dbb-8180-e2ea17ba9d04 | instance1 | ACTIVE | neiwang1=172.16.0.136 | cirros-0.5.2 | m1.1u.1g |
+--------------------------------------+-----------+--------+-----------------------+--------------+----------+

查看实例instance1详细信息

bash 复制代码
[root@controller ~(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                           | neiwang1=172.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                     | name='default'                                           |
| status                              | ACTIVE                                                   |
| updated                             | 2024-09-23T03:08:00Z                                     |
| user_id                             | 7ef9147a8abe485889ece90dce340ab1                         |
| volumes_attached                    |                                                          |
+-------------------------------------+----------------------------------------------------------+

VNC登录,后续可以SSH登录

观察此刻网络拓扑

instance1 外网通信测试

复制代码
                                  |

±------------------------------------±---------------------------------------------------------+

复制代码
VNC登录,后续可以SSH登录

[外链图片转存中...(img-BiMDaoEQ-1779066099165)]

### 观察此刻网络拓扑

[外链图片转存中...(img-W0W64eWa-1779066099165)]

### instance1 外网通信测试

![外链图片转存失败,源站可能有防盗链机制,建议将图片保存下来直接上传](https://img-home.csdnimg.cn/images/20230724024159.png?origin_url=.%2FOpenStack%E4%BD%BF%E7%94%A8.assets%2Fimage-20250805203806160.png&pos_id=img-u38DciXX-1779066099165)
相关推荐
时光不负努力1 小时前
手写三大核心:Promise、Event Bus、深拷贝
前端
SL_staff1 小时前
从Zoom/腾讯会议迁移到私有化会议系统:数据迁移完整方案
java·架构
星栈1 小时前
被Leptos弹窗逼疯后,我搞了一套零Props方案
前端·前端框架·全栈
不是山谷.:.1 小时前
Axios的【接口防抖 + 请求失败重试 + 弱网提示】三合一高阶版封装
前端·javascript·vue.js·笔记·elementui·typescript
超绝大帅哥1 小时前
babel降级|>, Object.groupBy
前端·javascript
23朵毒蘑菇1 小时前
前端自定义滚动条新星库出现了,看它亮还是不亮
前端·javascript
子兮曰1 小时前
GEO 生成式引擎优化完全指南:让你的内容成为 AI 的默认答案
前端·后端·seo
实心儿儿1 小时前
Linux —— Linux进程信号 - 信号产生
linux·运维·服务器
木易 士心1 小时前
深入理解 OKHttp:设计模式、核心机制与架构优势
android·设计模式·架构