本文共 19908 字,大约阅读时间需要 66 分钟。
注意:本应该直接去数据库拿取配置信息,但因为Nova-Compute的特殊身份,Nova-Compute所在计算节点上全是云主机,万一有一台云主机被******从而控制计算节点,直接***是很危险的。所以不能让Nova-Compute知道数据库在什么地方
[root@linux-node1 ~]# source admin-openrc
[root@linux-node1 ~]# openstack network create --share --external \--provider-physical-network provider \--provider-network-type flat provider+---------------------------+--------------------------------------+| Field | Value |+---------------------------+--------------------------------------+| admin_state_up | UP || availability_zone_hints | || availability_zones | || created_at | 2018-01-22T06:05:17Z || description | || headers | || id | d8acc6f1-8aed-4f7c-a630-83225f592039 || ipv4_address_scope | None || ipv6_address_scope | None || mtu | 1500 || name | provider || port_security_enabled | True || project_id | 14055178975d417987c5a94f030c7acf || project_id | 14055178975d417987c5a94f030c7acf || provider:network_type | flat || provider:physical_network | provider || provider:segmentation_id | None || revision_number | 4 || router:external | External || shared | True || status | ACTIVE || subnets | || tags | [] || updated_at | 2018-01-22T06:05:18Z |+---------------------------+--------------------------------------+[root@linux-node1 ~]# neutron net-list+--------------------------------------+----------+---------+| id | name | subnets |+--------------------------------------+----------+---------+| d8acc6f1-8aed-4f7c-a630-83225f592039 | provider | |+--------------------------------------+----------+---------+
[root@linux-node1 ~]# openstack subnet create --network provider \--allocation-pool start=192.168.56.100,end=192.168.56.200 \--dns-nameserver 192.168.56.2 --gateway 192.168.56.2 \--subnet-range 192.168.56.0/24 provider-subnet+-------------------+--------------------------------------+| Field | Value |+-------------------+--------------------------------------+| allocation_pools | 192.168.56.100-192.168.56.200 || cidr | 192.168.56.0/24 || created_at | 2018-01-22T06:13:27Z || description | || dns_nameservers | 192.168.56.2 || enable_dhcp | True || gateway_ip | 192.168.56.2 || headers | || host_routes | || id | 5ae96c6c-2295-4cef-8ce5-cc19f4596c90 || ip_version | 4 || ipv6_address_mode | None || ipv6_ra_mode | None || name | provider-subnet || network_id | d8acc6f1-8aed-4f7c-a630-83225f592039 || project_id | 14055178975d417987c5a94f030c7acf || project_id | 14055178975d417987c5a94f030c7acf || revision_number | 2 || service_types | [] || subnetpool_id | None || updated_at | 2018-01-22T06:13:27Z |+-------------------+--------------------------------------+[root@linux-node1 ~]# neutron subnet-list+--------------------------------------+-----------------+-----------------+-------------------------------------------+| id | name | cidr | allocation_pools |+--------------------------------------+-----------------+-----------------+-------------------------------------------+| 5ae96c6c-2295-4cef-8ce5-cc19f4596c90 | provider-subnet | 192.168.56.0/24 | {"start": "192.168.56.100", "end": || | | | "192.168.56.200"} |+--------------------------------------+-----------------+-----------------+-------------------------------------------+[root@linux-node1 ~]# neutron net-list+--------------------------------------+----------+------------------------------------------------------+| id | name | subnets |+--------------------------------------+----------+------------------------------------------------------+| d8acc6f1-8aed-4f7c-a630-83225f592039 | provider | 5ae96c6c-2295-4cef-8ce5-cc19f4596c90 192.168.56.0/24 |+--------------------------------------+----------+------------------------------------------------------+
默认的最小规格的主机需要512MB内存,对于环境中计算节点内存不足4 GB的,我们推荐创建只需要64MB的keywa.com
规格的主机。若单纯为了测试的目的,请使用keywa.com
规格的主机来加载CirrOS镜像。
[root@linux-node1 ~]# openstack flavor create --id 0 --vcpus 1 --ram 64 --disk 1 keywa.com+----------------------------+-----------+| Field | Value |+----------------------------+-----------+| OS-FLV-DISABLED:disabled | False || OS-FLV-EXT-DATA:ephemeral | 0 || disk | 1 || id | 0 || name | keywa.com || os-flavor-access:is_public | True || properties | || ram | 64 || rxtx_factor | 1.0 || swap | || vcpus | 1 |+----------------------------+-----------+
[root@linux-node1 ~]# source demo-openrc
[root@linux-node1 ~]# ssh-keygen -q -N ""Enter file in which to save the key (/root/.ssh/id_rsa):[root@linux-node1 ~]# ls -l .ssh/total 8-rw------- 1 root root 1679 Jan 22 14:28 id_rsa-rw-r--r-- 1 root root 398 Jan 22 14:28 id_rsa.pub[root@linux-node1 ~]# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey+-------------+-------------------------------------------------+| Field | Value |+-------------+-------------------------------------------------+| fingerprint | 6d:5f:c6:92:ac:5e:49:40:5c:3e:b4:14:9c:f9:59:8c || name | mykey || user_id | 48cd83bd3ce54b8ebece24680e8c8b0a |+-------------+-------------------------------------------------+
[root@linux-node1 ~]# openstack keypair list+-------+-------------------------------------------------+| Name | Fingerprint |+-------+-------------------------------------------------+| mykey | 6d:5f:c6:92:ac:5e:49:40:5c:3e:b4:14:9c:f9:59:8c |+-------+-------------------------------------------------+
默认情况下,default安全组适用于所有实例并且包括拒绝远程访问实例的防火墙规则。对诸如CirrOS这样的Linux镜像,我们推荐至少允许ICMP (ping))和安全Shell(SSH)规则。
[root@linux-node1 ~]# openstack security group rule create --proto icmp default+-------------------+--------------------------------------+| Field | Value |+-------------------+--------------------------------------+| created_at | 2018-01-22T06:46:59Z || description | || direction | ingress || ethertype | IPv4 || headers | || id | 51ed729f-b268-4a99-b8a6-3a2ba0d31c77 || port_range_max | None || port_range_min | None || project_id | 8a788702c6ea46419bb85b4e4600e3c4 || project_id | 8a788702c6ea46419bb85b4e4600e3c4 || protocol | icmp || remote_group_id | None || remote_ip_prefix | 0.0.0.0/0 || revision_number | 1 || security_group_id | 20346c59-a0c4-4cc3-90be-f94c3581edab || updated_at | 2018-01-22T06:46:59Z |+-------------------+--------------------------------------+
[root@linux-node1 ~]# openstack security group rule create --proto tcp --dst-port 22 default+-------------------+--------------------------------------+| Field | Value |+-------------------+--------------------------------------+| created_at | 2018-01-22T06:49:46Z || description | || direction | ingress || ethertype | IPv4 || headers | || id | 950a1be7-6fd3-4c80-ba60-7f4f0b573771 || port_range_max | 22 || port_range_min | 22 || project_id | 8a788702c6ea46419bb85b4e4600e3c4 || project_id | 8a788702c6ea46419bb85b4e4600e3c4 || protocol | tcp || remote_group_id | None || remote_ip_prefix | 0.0.0.0/0 || revision_number | 1 || security_group_id | 20346c59-a0c4-4cc3-90be-f94c3581edab || updated_at | 2018-01-22T06:49:46Z |+-------------------+--------------------------------------+
启动一台实例,您必须至少指定一个类型、镜像名称、网络、安全组、密钥和实例名称。
[root@linux-node1 ~]# source demo-openrc
列出可用类型
[root@linux-node1 ~]# openstack flavor list+----+-----------+-----+------+-----------+-------+-----------+| ID | Name | RAM | Disk | Ephemeral | VCPUs | Is Public |+----+-----------+-----+------+-----------+-------+-----------+| 0 | keywa.com | 64 | 1 | 0 | 1 | True |+----+-----------+-----+------+-----------+-------+-----------+
列出可用镜像
[root@linux-node1 ~]# openstack image list+--------------------------------------+--------+--------+| ID | Name | Status |+--------------------------------------+--------+--------+| cd96090c-87ca-4eb3-b964-a7457639bc1e | cirros | active |+--------------------------------------+--------+--------+
列出可用网络
[root@linux-node1 ~]# openstack network list+--------------------------------------+----------+--------------------------------------+| ID | Name | Subnets |+--------------------------------------+----------+--------------------------------------+| d8acc6f1-8aed-4f7c-a630-83225f592039 | provider | 5ae96c6c-2295-4cef-8ce5-cc19f4596c90 |+--------------------------------------+----------+--------------------------------------+
列出可用的安全组
[root@linux-node1 ~]# openstack security group list+--------------------------------------+---------+------------------------+----------------------------------+| ID | Name | Description | Project |+--------------------------------------+---------+------------------------+----------------------------------+| 20346c59-a0c4-4cc3-90be-f94c3581edab | default | Default security group | 8a788702c6ea46419bb85b4e4600e3c4 |+--------------------------------------+---------+------------------------+----------------------------------+
[root@linux-node1 ~]# openstack server create --flavor keywa.com --image cirros \--nic net-id=d8acc6f1-8aed-4f7c-a630-83225f592039 --security-group default \--key-name mykey demo-instance+--------------------------------------+-----------------------------------------------+| Field | Value |+--------------------------------------+-----------------------------------------------+| OS-DCF:diskConfig | MANUAL || OS-EXT-AZ:availability_zone | || 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 | MowXppdE5ayJ || config_drive | || created | 2018-01-22T07:13:02Z || flavor | keywa.com (0) || hostId | || id | 3b5f20c8-8b17-48a2-9b72-70cc74f6fc8f || image | cirros (cd96090c-87ca-4eb3-b964-a7457639bc1e) || key_name | mykey || name | demo-instance || os-extended-volumes:volumes_attached | [] || progress | 0 || project_id | 8a788702c6ea46419bb85b4e4600e3c4 || properties | || security_groups | [{u'name': u'default'}] || status | BUILD || updated | 2018-01-22T07:13:02Z || user_id | 48cd83bd3ce54b8ebece24680e8c8b0a |+--------------------------------------+-----------------------------------------------+
[root@linux-node1 ~]# openstack server list+--------------------------------------+---------------+--------+-------------------------+------------+| ID | Name | Status | Networks | Image Name |+--------------------------------------+---------------+--------+-------------------------+------------+| 3b5f20c8-8b17-48a2-9b72-70cc74f6fc8f | demo-instance | ACTIVE | provider=192.168.56.110 | cirros |+--------------------------------------+---------------+--------+-------------------------+------------+
[root@linux-node1 ~]# ssh cirros@192.168.56.110The authenticity of host '192.168.56.110 (192.168.56.110)' can't be established.RSA key fingerprint is 2f:58:9f:5e:da:c5:1f:46:43:e1:c4:64:da:ee:2e:e6.Are you sure you want to continue connecting (yes/no)? yesWarning: Permanently added '192.168.56.110' (RSA) to the list of known hosts.$
$ ping -c 4 114.114.114.114PING 114.114.114.114 (114.114.114.114): 56 data bytes64 bytes from 114.114.114.114: seq=0 ttl=128 time=29.289 ms64 bytes from 114.114.114.114: seq=1 ttl=128 time=29.160 ms64 bytes from 114.114.114.114: seq=2 ttl=128 time=34.413 ms64 bytes from 114.114.114.114: seq=3 ttl=128 time=29.153 ms--- 114.114.114.114 ping statistics ---4 packets transmitted, 4 packets received, 0% packet lossround-trip min/avg/max = 29.153/30.503/34.413 ms
$ ping -c 4 www.baidu.comPING www.baidu.com (14.215.177.39): 56 data bytes64 bytes from 14.215.177.39: seq=0 ttl=128 time=12.611 ms64 bytes from 14.215.177.39: seq=1 ttl=128 time=8.424 ms64 bytes from 14.215.177.39: seq=2 ttl=128 time=10.575 ms64 bytes from 14.215.177.39: seq=3 ttl=128 time=11.595 ms--- www.baidu.com ping statistics ---4 packets transmitted, 4 packets received, 0% packet lossround-trip min/avg/max = 8.424/10.801/12.611 ms
[root@linux-node1 ~]# openstack console url show demo-instance+-------+------------------------------------------------------------------------------------+| Field | Value |+-------+------------------------------------------------------------------------------------+| type | novnc || url | http://192.168.56.11:6080/vnc_auto.html?token=aff15e93-1ebe-49f3-877b-3213e6faa027 |+-------+------------------------------------------------------------------------------------+
转载于:https://blog.51cto.com/11097612/2063687