Mitaka版使用命令启动一个示例

1.创建网络(网络名+子网)

创建网络名 neutron net-create --shared --provider:physical_network provider \ --provider:network_type flat pptfz

net-create 创建网络 --shared 创建共享网络 --provider:physical_network 指定物理网卡名称 provider网络标签 --provider:network_type 指定网络类型 flat桥接网络 pptfz网络名称

创建子网 neutron subnet-create --name bxb \ --allocation-pool start=10.0.0.101,end=10.0.0.250 \ --dns-nameserver 223.5.5.5 --gateway 10.0.0.254 \ pptfz 10.0.0.0/24

subnet-create 创建子网 --name 指定名称 bxb子网名称 --allocation-pool IP地址范围 pptfz 创建的子网关联到哪个网络

以下为操作

#创建网络
neutron net-create --shared --provider:physical_network provider \
 --provider:network_type flat pptfz
Created a new network:
+---------------------------+--------------------------------------+
| Field                     | Value                                |
+---------------------------+--------------------------------------+
| admin_state_up            | True                                 |
| availability_zone_hints   |                                      |
| availability_zones        |                                      |
| created_at                | 2019-02-03T09:37:39                  |
| description               |                                      |
| id                        | 9125ad48-6bbe-4baf-8d78-f91a7c0a8ea2 |
| ipv4_address_scope        |                                      |
| ipv6_address_scope        |                                      |
| mtu                       | 1500                                 |
| name                      | pptfz                                |
| port_security_enabled     | True                                 |
| provider:network_type     | flat                                 |
| provider:physical_network | provider                             |
| provider:segmentation_id  |                                      |
| router:external           | False                                |
| shared                    | True                                 |
| status                    | ACTIVE                               |
| subnets                   |                                      |
| tags                      |                                      |
| tenant_id                 | e33e3feaef784a5bb45bd9c766bc0f46     |
| updated_at                | 2019-02-03T09:37:39                  |
+---------------------------+--------------------------------------+

#创建子网
neutron subnet-create --name bxb \
 --allocation-pool start=10.0.0.101,end=10.0.0.250 \
 --dns-nameserver 223.5.5.5 --gateway 10.0.0.1 \
 pptfz 10.0.0.0/24
Created a new subnet:
+-------------------+----------------------------------------------+
| Field             | Value                                        |
+-------------------+----------------------------------------------+
| allocation_pools  | {"start": "10.0.0.101", "end": "10.0.0.250"} |
| cidr              | 10.0.0.0/24                                  |
| created_at        | 2019-02-03T09:40:37                          |
| description       |                                              |
| dns_nameservers   | 223.5.5.5                                    |
| enable_dhcp       | True                                         |
| gateway_ip        | 10.0.0.254                                   |
| host_routes       |                                              |
| id                | ad21906e-166d-47e2-8634-18c907c6da3b         |
| ip_version        | 4                                            |
| ipv6_address_mode |                                              |
| ipv6_ra_mode      |                                              |
| name              | bxb                                          |
| network_id        | 9125ad48-6bbe-4baf-8d78-f91a7c0a8ea2         |
| subnetpool_id     |                                              |
| tenant_id         | e33e3feaef784a5bb45bd9c766bc0f46             |
| updated_at        | 2019-02-03T09:40:37                          |
+-------------------+----------------------------------------------+

2.创建云主机的硬件配置方案

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    |
| ram                        | 64      |
| rxtx_factor                | 1.0     |
| swap                       |         |
| vcpus                      | 1       |
+----------------------------+---------+

//参数说明
openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 m1.nano
flavor        硬件配置方案
--id        指定编号
--vcpus        cpu个数
--ram        内存(单位:M)
--disk        磁盘(单位:G)
m1.nano        方案名称

3.创建密钥对

ssh-keygen -q -N "" -f ~/.ssh/id_rsa

openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
+-------------+-------------------------------------------------+
| Field       | Value                                           |
+-------------+-------------------------------------------------+
| fingerprint | 0e:af:ab:c3:74:5f:56:1b:e8:46:7d:e5:65:4f:a8:9a |
| name        | mykey                                           |
| user_id     | aaa8bfce5b5d451b956bb76dee235b9e                |
+-------------+-------------------------------------------------+
//参数说明
ssh-keygen -q -N "" -f ~/.ssh/id_rsa  非交互式生成密钥对
-q    安静模式
-N    指定加密密码
-f    密钥对存放位置
openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey  上传密钥对

4.创建安全组规则

openstack security group rule create --proto icmp default
+-----------------------+--------------------------------------+
| Field                 | Value                                |
+-----------------------+--------------------------------------+
| id                    | cb340772-4dd8-4d33-8ae0-2be3f43f26de |
| ip_protocol           | icmp                                 |
| ip_range              | 0.0.0.0/0                            |
| parent_group_id       | b6f5f95a-fd52-43c1-bb4c-0625750e4369 |
| port_range            |                                      |
| remote_security_group |                                      |
+-----------------------+--------------------------------------+

openstack security group rule create --proto tcp --dst-port 22 default
+-----------------------+--------------------------------------+
| Field                 | Value                                |
+-----------------------+--------------------------------------+
| id                    | 01c1cea4-76c0-4181-aca9-4b3148fb0397 |
| ip_protocol           | tcp                                  |
| ip_range              | 0.0.0.0/0                            |
| parent_group_id       | b6f5f95a-fd52-43c1-bb4c-0625750e4369 |
| port_range            | 22:22                                |
| remote_security_group |                                      |
+-----------------------+--------------------------------------+

#默认所有端口全部禁止,上边两个命令为允许ping和ssh
openstack security group rule create --proto icmp default
openstack security group rule create --proto tcp --dst-port 22 default

5.启动一个实例

openstack server create --flavor m1.nano --image cirros \
--nic net-id=`neutron net-list|awk 'NR==4{print $2}'` --security-group default \
--key-name mykey pptfz
+--------------------------------------+-----------------------------------------------+
| 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        | instance-00000001                             |
| OS-EXT-STS:power_state               | 0                                             |
| 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                            | 8KcNG34aXwuK                                  |
| config_drive                         |                                               |
| created                              | 2019-02-03T12:10:10Z                          |
| flavor                               | m1.nano (0)                                   |
| hostId                               |                                               |
| id                                   | d5e07f54-c70e-4657-9ec5-778edc941e99          |
| image                                | cirros (ac21b17b-e910-4ca4-b743-914b8fbd0e55) |
| key_name                             | mykey                                         |
| name                                 | pptfz                                         |
| os-extended-volumes:volumes_attached | []                                            |
| progress                             | 0                                             |
| project_id                           | e33e3feaef784a5bb45bd9c766bc0f46              |
| properties                           |                                               |
| security_groups                      | [{u'name': u'default'}]                       |
| status                               | BUILD                                         |
| updated                              | 2019-02-03T12:10:12Z                          |
| user_id                              | aaa8bfce5b5d451b956bb76dee235b9e              |
+--------------------------------------+-----------------------------------------------+

#创建完成后查看,状态为ACTIVE即为正确
openstack server list
+--------------------------------------+-------+--------+------------------+
| ID                                   | Name  | Status | Networks         |
+--------------------------------------+-------+--------+------------------+
| d5e07f54-c70e-4657-9ec5-778edc941e99 | pptfz | ACTIVE | pptfz=10.0.0.102 |
+--------------------------------------+-------+--------+------------------+

启动实例后会在web界面显示

项目-->计算-->示例

iShot2020-05-2410.45.01

泡泡吐肥皂o © gitbook.pptfz.top 2021 all right reserved,powered by Gitbook文件修订时间: 秃笔南波湾!!!

results matching ""

    No results matching ""