启动一个实例

This section creates the necessary virtual networks to support launching instances. Networking option 1 includes one provider (external) network with one instance that uses it. Networking option 2 includes one provider network with one instance that uses it and one self-service (private) network with one instance that uses it.

The instructions in this section use command-line interface (CLI) tools on the controller node. However, you can follow the instructions on any host that the tools are installed.

For more information on the CLI tools, see the OpenStackClient documentation for Pike, the OpenStackClient documentation for Queens, or the OpenStackClient documentation for Rocky.

To use the dashboard, see the Dashboard User Documentation for Pike, the Dashboard User Documentation for Queens, or the Dashboard User Documentation for Rocky.

创建虚拟网络

Create virtual networks for the networking option that you chose when configuring Neutron. If you chose option 1, create only the provider network. If you chose option 2, create the provider and self-service networks.

在你完成自己环境中合适网络的创建后,你可以继续后面的步骤来准备创建实例。

创建m1.nano类型

默认的最小规格的主机需要512 MB内存。对于环境中计算节点内存不足4 GB的,我们推荐创建只需要64 MB的``m1.nano``规格的主机。若单纯为了测试的目的,请使用``m1.nano``规格的主机来加载CirrOS镜像

$ openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano

+----------------------------+---------+
| Field                      | Value   |
+----------------------------+---------+
| OS-FLV-DISABLED:disabled   | False   |
| OS-FLV-EXT-DATA:ephemeral  | 0       |
| disk                       | 1       |
| id                         | 0       |
| name                       | m1.nano |
| os-flavor-access:is_public | True    |
| properties                 |         |
| ram                        | 64      |
| rxtx_factor                | 1.0     |
| swap                       |         |
| vcpus                      | 1       |
+----------------------------+---------+

生成一个键值对

大部分云镜像支持 :term:`public key authentication`而不是传统的密码登陆。在启动实例前,你必须添加一个公共密钥到计算服务。

  1. 导入``demo``项目凭证

    $ . demo-openrc
    
  2. Generate a key pair and add a public key:

    $ ssh-keygen -q -N ""
    $ openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
    
    +-------------+-------------------------------------------------+
    | Field       | Value                                           |
    +-------------+-------------------------------------------------+
    | fingerprint | ee:3d:2e:97:d4:e2:6a:54:6d:0d:ce:43:39:2c:ba:4d |
    | name        | mykey                                           |
    | user_id     | 58126687cbcc4888bfa9ab73a2256f27                |
    +-------------+-------------------------------------------------+
    

    备注

    另外,你可以跳过执行 ssh-keygen 命令而使用已存在的公钥。

  3. 验证公钥的添加:

    $ openstack keypair list
    
    +-------+-------------------------------------------------+
    | Name  | Fingerprint                                     |
    +-------+-------------------------------------------------+
    | mykey | ee:3d:2e:97:d4:e2:6a:54:6d:0d:ce:43:39:2c:ba:4d |
    +-------+-------------------------------------------------+
    

增加安全组规则

默认情况下, ``default``安全组适用于所有实例并且包括拒绝远程访问实例的防火墙规则。对诸如CirrOS这样的Linux镜像,我们推荐至少允许ICMP (ping) 和安全shell(SSH)规则。

  • 添加规则到 default 安全组。

    • Permit ICMP (ping):

      $ openstack security group rule create --proto icmp default
      
      +-------------------+--------------------------------------+
      | Field             | Value                                |
      +-------------------+--------------------------------------+
      | created_at        | 2017-03-30T00:46:43Z                 |
      | description       |                                      |
      | direction         | ingress                              |
      | ether_type        | IPv4                                 |
      | id                | 1946be19-54ab-4056-90fb-4ba606f19e66 |
      | name              | None                                 |
      | port_range_max    | None                                 |
      | port_range_min    | None                                 |
      | project_id        | 3f714c72aed7442681cbfa895f4a68d3     |
      | protocol          | icmp                                 |
      | remote_group_id   | None                                 |
      | remote_ip_prefix  | 0.0.0.0/0                            |
      | revision_number   | 1                                    |
      | security_group_id | 89ff5c84-e3d1-46bb-b149-e621689f0696 |
      | updated_at        | 2017-03-30T00:46:43Z                 |
      +-------------------+--------------------------------------+
      
    • 允许安全 shell (SSH) 的访问:

      $ openstack security group rule create --proto tcp --dst-port 22 default
      
      +-------------------+--------------------------------------+
      | Field             | Value                                |
      +-------------------+--------------------------------------+
      | created_at        | 2017-03-30T00:43:35Z                 |
      | description       |                                      |
      | direction         | ingress                              |
      | ether_type        | IPv4                                 |
      | id                | 42bc2388-ae1a-4208-919b-10cf0f92bc1c |
      | name              | None                                 |
      | port_range_max    | 22                                   |
      | port_range_min    | 22                                   |
      | project_id        | 3f714c72aed7442681cbfa895f4a68d3     |
      | protocol          | tcp                                  |
      | remote_group_id   | None                                 |
      | remote_ip_prefix  | 0.0.0.0/0                            |
      | revision_number   | 1                                    |
      | security_group_id | 89ff5c84-e3d1-46bb-b149-e621689f0696 |
      | updated_at        | 2017-03-30T00:43:35Z                 |
      +-------------------+--------------------------------------+
      

启动一个实例

如果选择网络选项1,你只能在公网创建实例。如果选择网络选项2,你可以在公网或私网创建实例。

块设备存储

如果你的环境包含块存储服务,你可以创建一个卷并连接到一个实例上。

编排

如果你的环境包括云编排服务,你可以创建一个栈来自动化创建一个实例。

For more information, see the Orchestration installation guide for Pike, the Orchestration installation guide for Queens, or the Orchestration installation guide for Rocky.

共享文件系统

如果你的环境中包含文件共享系统服务,你可以创建一个共享点,并且将它挂载到一个实例上

For more information, see the Shared File Systems installation guide for Pike, the Shared File Systems installation guide for Queens, or the Shared File Systems installation guide for Rocky.