• openstack部署之创建第一个实例


    简介

      当完成keystone、glance、nova、neutron组件的部署(部署方法参考之前的博文)之后,我们就可以创建第一个虚拟机实例了,下边具体操作下创建第一个虚拟机实例。

    创建第一个实例

    创建provider network

    • 设置环境变量,这个在所有服务部署中都会用到,所以如果有报错,首先考虑是否设置环境变量
    [root@localhost ~]# source admin-openstack.sh
    • 创建网络
    $ openstack network create  --share --external 
      --provider-physical-network provider 
      --provider-network-type flat provider
    
    Created a new network:
    
    +---------------------------+--------------------------------------+
    | Field                     | Value                                |
    +---------------------------+--------------------------------------+
    | admin_state_up            | UP                                   |
    | availability_zone_hints   |                                      |
    | availability_zones        |                                      |
    | created_at                | 2017-03-14T14:37:39Z                 |
    | description               |                                      |
    | dns_domain                | None                                 |
    | id                        | 54adb94a-4dce-437f-a33b-e7e2e7648173 |
    | ipv4_address_scope        | None                                 |
    | ipv6_address_scope        | None                                 |
    | is_default                | None                                 |
    | mtu                       | 1500                                 |
    | name                      | provider                             |
    | port_security_enabled     | True                                 |
    | project_id                | 4c7f48f1da5b494faaa66713686a7707     |
    | provider:network_type     | flat                                 |
    | provider:physical_network | provider                             |
    | provider:segmentation_id  | None                                 |
    | qos_policy_id             | None                                 |
    | revision_number           | 3                                    |
    | router:external           | External                             |
    | segments                  | None                                 |
    | shared                    | True                                 |
    | status                    | ACTIVE                               |
    | subnets                   |                                      |
    | updated_at                | 2017-03-14T14:37:39Z                 |
    +---------------------------+--------------------------------------+
    • 创建子网
    openstack subnet create --network provider 
      --allocation-pool start=192.168.46.100,end=192.168.46.200    #设置创建的实例的地址范围
      --dns-nameserver 223.5.5.5 --gateway 192.168.46.1     #设置dns,在此使用的是阿里的DNS,设置网关
      --subnet-range 192.168.46.0/24 provider              #设置子网掩码,网络名称为provider
    • 检查创建的网络和子网
    [root@localhost ~]# openstack network list
    +--------------------------------------+----------+--------------------------------------+
    | ID                                   | Name     | Subnets                              |
    +--------------------------------------+----------+--------------------------------------+
    | 20583a37-6c4b-4f26-a5d6-fc7e643200d9 | provider | 4b8c0017-6ea7-4d7e-920c-4ea143d0b3ac |
    +--------------------------------------+----------+--------------------------------------+
    [root@localhost ~]# openstack subnet list
    +--------------------------------------+----------+--------------------------------------+-----------------+
    | ID                                   | Name     | Network                              | Subnet          |
    +--------------------------------------+----------+--------------------------------------+-----------------+
    | 4b8c0017-6ea7-4d7e-920c-4ea143d0b3ac | provider | 20583a37-6c4b-4f26-a5d6-fc7e643200d9 | 192.168.46.0/24 |
    +--------------------------------------+----------+--------------------------------------+-----------------+

    创建云主机规格

    $ 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       |
    +----------------------------+---------+

    创建key pair

    • 设置demo环境变量
    [root@localhost ~]# source demo-openstack.sh
    • 生成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                |
    +-------------+-------------------------------------------------+
    

      可以直接使用key登录虚拟机

    • 查看key
    [root@localhost ~]# openstack keypair list
    +-------+-------------------------------------------------+
    | Name  | Fingerprint                                     |
    +-------+-------------------------------------------------+
    | mykey | 5b:ab:e1:3d:2f:0a:5c:a9:17:b5:d1:0d:85:05:fa:89 |
    +-------+-------------------------------------------------+
    • 在安全组中增加两个规则,设置ping和22端口(为了可以ssh连接虚拟机)
    $ 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                 |
    +-------------------+--------------------------------------+
    
    $ 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                 |
    +-------------------+--------------------------------------+
    • 查看安全组

    [root@localhost ~]# openstack security group list
    +--------------------------------------+---------+-------------+----------------------------------+
    | ID                                   | Name    | Description | Project                          |
    +--------------------------------------+---------+-------------+----------------------------------+
    | f9ccf579-326e-41a2-8125-67290fcb5888 | default | 缺省安全组  | 9ce357d324a84c84a940e3db27a3bbde |
    +--------------------------------------+---------+-------------+----------------------------------+

    启动实例

    • 创建实例需要使用到network id,先通过如下命令查看
    [root@localhost ~]# openstack network list
    +--------------------------------------+----------+--------------------------------------+
    | ID                                   | Name     | Subnets                              |
    +--------------------------------------+----------+--------------------------------------+
    | 20583a37-6c4b-4f26-a5d6-fc7e643200d9 | provider | 4b8c0017-6ea7-4d7e-920c-4ea143d0b3ac |
    +--------------------------------------+----------+--------------------------------------+
    • 启动实例
    $ 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                 |
    +-------------------+--------------------------------------+
  • 相关阅读:
    《DSP using MATLAB》Problem 6.4
    《DSP using MATLAB》Problem 6.3
    《DSP using MATLAB》Problem 6.1
    《DSP using MATLAB》Problem 5.38
    整除分块+取模
    尺取法(滑窗,双指针)
    uva247电话圈(floyd)
    uva1151并查集+最小生成树
    uva1395 苗条的生成树
    uva10562看图写树
  • 原文地址:https://www.cnblogs.com/baihl/p/10853329.html
Copyright © 2020-2023  润新知