To create a network:
[[email protected] ~]# source admin-openrc.sh
[[email protected] ~]# neutron net-create flat--shared--provider:physical_network physnet1--provider:network_ Type flatcreated a new network:+---------------------------+--------------------------------------+| Field | Value |+---------------------------+--------------------------------------+| admin_state_up | True | | ID | 9252CB78-D155-40D4-8EA5-5E45852A6B40 | | MTU | 0 | | name | Flat | | port_security_enabled | True | | Provider:network_type | Flat | | Provider:physical_network | Physnet1 | | provider:segmentation_id | || router:external | False | | Shared | True || Status | ACTIVE | | Subnets | || tenant_id | D7064a9e91934300b28cccc787161fdb |+---------------------------+--------------------------------------+
[[email protected] ~]# neutron subnet-create flat 192.168.56.0/24--name flat-subnet--allocation-pool start= 192.168.56.100,end=192.168.56.200--dns-nameserver 192.168.56.2--gateway 192.168.56.2Created a new subnet:+--------- ----------+------------------------------------------------------+| Field | Value |+-------------------+----------------------------------------------- -------+| Allocation_pools | {"Start": "192.168.56.100", "End": "192.168.56.200"} | | CIDR | 192.168.56.0/24 | | Dns_nameservers | 192.168.56.2 | | Enable_dhcp | True | | Gateway_ip | 192.168.56.2 | | Host_routes | || ID | 5ff3d70a-c336-421d-880e-d1a13791afd0 | | Ip_version | 4 | | Ipv6_address_mode | || Ipv6_ra_mode | || name | flat-subnet | | network_id | 9252CB78-D155-40D4-8EA5-5E45852A6B40 | | subnetpool_id | || tenant_id | D7064a9e91934300b28cccc787161fdb |+-------------------+----------------------------------------------- -------+
[[email protected] ~]# neutron subnet-list+--------------------------------------+-------------+- ----------------+------------------------------------------------------+| ID | name | CIDR | Allocation_pools |+--------------------------------------+-------------+-------------- ---+------------------------------------------------------+| 5ff3d70a-c336-421d-880e-d1a13791afd0 | flat-subnet | 192.168.56.0/24 | {"Start": "192.168.56.100", "End": "192.168.56.200"} |+--------------------------------------+-------------+------ -----------+------------------------------------------------------+
[[email protected] ~]# neutron net-list+--------------------------------------+------+------------------------------------------------------+| id | name | subnets |+--------------------------------------+------+------------------------------------------------------+| 9252cb78-d155-40d4-8ea5-5e45852a6b40 | flat | 5ff3d70a-c336-421d-880e-d1a13791afd0 192.168.56.0/24 |+--------------------------------------+------+------------------------------------------------------+
Create key:
[[email protected] ~]# source demo-openrc.sh
[[email protected] ~]# ssh-keygen -q -N ""Enter file in which to save the key (/root/.ssh/id_rsa):
[[email protected] ~]# ls .ssh/id_rsa id_rsa.pub
[[email protected] ~]# nova keypair-add --pub-key ~/.ssh/id_rsa.pub mykey
[[email protected] ~]# nova keypair-list +-------+-------------------------------------------------+| Name | Fingerprint |+-------+-------------------------------------------------+| mykey | 9c:a0:94:9c:f0:25:2d:f0:8b:1b:32:02:e6:9e:1c:54 |+-------+-------------------------------------------------+
To add a security group:
[[email protected] ~]# nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0 +-------------+-----------+---------+-----------+--------------+| IP Protocol | From Port | To Port | IP Range | Source Group |+-------------+-----------+---------+-----------+--------------+| icmp | -1 | -1 | 0.0.0.0/0 | |+-------------+-----------+---------+-----------+--------------+
[[email protected] ~]# nova secgroup-add-rule default tcp 22 22 0.0.0.0/0+-------------+-----------+---------+-----------+--------------+| IP Protocol | From Port | To Port | IP Range | Source Group |+-------------+-----------+---------+-----------+--------------+| tcp | 22 | 22 | 0.0.0.0/0 | |+-------------+-----------+---------+-----------+--------------+
To start a virtual machine:
[[email protected] ~]# Nova flavor-list +----+-----------+-----------+------+-----------+------+-- -----+-------------+-----------+| ID | Name | MEMORY_MB | Disk | Ephemeral | Swap | Vcpus | Rxtx_factor | Is_public |+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+| 1 | M1.tiny | 512 | 1 | 0 | | 1 | 1.0 | True | | 2 | M1.small | 2048 | 20 | 0 | | 1 | 1.0 | True | | 3 | M1.medium | 4096 | 40 | 0 | | 2 | 1.0 | True | | 4 | M1.large | 8192 | 80 | 0 | | 4 | 1.0 | True | | 5 | M1.xlarge | 16384 | 160 | 0 | | 8 | 1.0 | True |+----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
[[email protected] ~]# nova image-list +--------------------------------------+--------+--------+--------+| ID | Name | Status | Server |+--------------------------------------+--------+--------+--------+| 0297b83c-f9d7-4c19-ab05-762fd4616c49 | cirros | ACTIVE | |+--------------------------------------+--------+--------+--------+
[[email protected] ~]# nova net-list +--------------------------------------+-------+------+| ID | Label | CIDR |+--------------------------------------+-------+------+| 9252cb78-d155-40d4-8ea5-5e45852a6b40 | flat | None |+--------------------------------------+-------+------+
[[email protected] ~]# nova boot--flavor m1.tiny--image cirros--nic NET-ID=9252CB78-D155-40D4-8EA5-5E45852A6B40 --security-group default--key-name mykey hello-instance+--------------------------------------+------------------ -----------------------------+| Property | Value |+--------------------------------------+----------------------------------- ------------+| Os-dcf:diskconfig | MANUAL | | Os-ext-az:availability_zone | || Os-ext-sts:power_state | 0 | | Os-ext-sts:task_state | scheduling | | Os-ext-sts:vm_state | Building | | Os-srv-usg:launched_at | - || Os-srv-usg:terminated_at | - || accessIPv4 | || AccessIPv6 | || AdminPass | UBU5NC8PV3KD | | config_drive | || Created | 2018-10-08t23:55:54z | | Flavor | M1.tiny (1) | | HostId | || ID | 5b6b6e93-2aed-4c73-ba6d-220b43c9d48a | | Image | Cirros (0297b83c-f9d7-4c19-ab05-762fd4616c49) | | Key_name | MyKey | | metadata | {} || name | hello-instance | | os-extended-volumes:volumes_attached | [] || Progress | 0 | | security_groups | Default | | Status | BUILD | | tenant_id | 29b7833bc24e41d7b4c1d8c77de81e88 | | Updated | 2018-10-08t23:56:04z | | user_id | 8ce3700aed4e428d9ce51b05685ae0a6 |+--------------------------------------+----------------------------------- ------------+
To connect a virtual machine:
[[email protected] ~]# nova list+--------------------------------------+----------------+--------+------------+-------------+---------------------+| ID | Name | Status | Task State | Power State | Networks |+--------------------------------------+----------------+--------+------------+-------------+---------------------+| e7585ece-c8e9-4ad8-8796-8a58bca459bf | hello-instance | ACTIVE | - | Running | flat=192.168.56.103 |+--------------------------------------+----------------+--------+------------+-------------+---------------------+
[[email protected] ~]# ping 192.168.56.103 ping 192.168.56.103 (192.168.56.103) (+) bytes of data.64 b Ytes from 192.168.56.103:icmp_seq=1 ttl=64 time=22.1 ms64 bytes from 192.168.56.103:icmp_seq=2 ttl=64 time=17.7 ms64 byt Es from 192.168.56.103:icmp_seq=3 ttl=64 time=4.11 ms64 bytes from 192.168.56.103:icmp_seq=4 ttl=64 time=44.4 Ms^C---19 2.168.56.103 Ping Statistics---4 packets transmitted, 4 received, 0% packet loss, time 3006msrtt Min/avg/max/mdev = 4.119 /22.102/44.434/14.503 Ms
[[email protected] ~]# ssh [email protected]the authenticity of host ' 192.168.56.103 (192.168.56.103) ' can ' t be established. RSA key fingerprint is Sha256:34k1lhbvi28tn4ylfxqtafnuv2a3lcsggoxscynraey.rsa key fingerprint is MD5:fa:29:2a:6f : 56:67:2a:45:bb:74:3c:9d:9b:84:83:5d. Is you sure want to continue connecting (yes/no)? yeswarning:permanently added ' 192.168.56.103 ' (RSA) to the list of known hosts.$ whoamicirros$ IP addr show1:lo: <loo Pback,up,lower_up> MTU 16436 qdisc noqueue link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00 inet 127.0.0.1/ 8 Scope host lo inet6:: 1/128 scope host Valid_lft forever Preferred_lft Forever2:eth0: <broadcast,multicast ,up,lower_up> MTU Qdisc pfifo_fast qlen-link/ether fa:16:3e:f4:6f:fe brd ff:ff:ff:ff:ff:ff inet 192.168 .56.103/24 BRD 192.168.56.255 Scope global eth0 inet6 fe80::f816:3eff:fef4:6ffe/64 scope link Valid_lft forever Preferred_lft forever$ exitconnection to 192.168.56.103 closed.
Connect via VNC:
Get hello-instance virtual machine strength connection URL;
[[email protected] ~]# nova get-vnc-console hello-instance novnc +-------+------------------------------------------------------------------------------------+| Type | Url |+-------+------------------------------------------------------------------------------------+| novnc | http://192.168.56.11:6080/vnc_auto.html?token=b895d0e1-cfed-4736-99e0-e91986b7b82c |+-------+------------------------------------------------------------------------------------+
Open the URL via the browser;
Node1 network card changes;
[[email protected] ~]# ifconfig brq9252cb78-d1:flags=4163<up,broadcast,running,multicast> MTU ine T 192.168.56.11 netmask 255.255.255.0 broadcast 192.168.56.255 ether 00:0c:29:81:30:8f Txqueuelen (Etherne T) Rx packets 19654 Bytes 3675080 (3.5 MiB) Rx Errors 0 dropped 0 overruns 0 frame 0 TX packets 1 7122 bytes 21751953 (20.7 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ens33:flags=4163<up,b Roadcast,running,multicast> MTU Inet6 fe80::c52b:9095:bd1d:f94e prefixlen ScopeID 0x20<link> Ether 00:0c:29:81:30:8f Txqueuelen (Ethernet) Rx packets 30222 Bytes 5286547 (5.0 MiB) Rx Error S 0 dropped 0 overruns 0 frame 0 TX packets 32628 bytes 34571258 (32.9 MiB) TX errors 0 dropped 0 overr UNS 0 Carrier 0 collisions 0ens37:flags=4163<up,broadcast,running,multicast> MTU inet 192.168.47.142 Netmask 255.255.255.0 Broadcast 192.168.47.255 INET6 FE80::d 51e:5fe4:2294:35f0 prefixlen 00:0 scopeid 0x20<link> ether c:29:81:30:99 Txqueuelen (Ethernet) Rx packets 3203 Bytes 230403 (225.0 KiB) Rx errors 0 dropped 0 Overruns 0 Frame 0 TX packets 732 bytes 63739 (62.2 KiB) TX errors 0 dropped 0 overruns 0 carrier 0 Co Llisions 0lo:flags=73<up,loopback,running> MTU 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6:: 1 PR Efixlen ScopeID 0x10
[[email protected] ~]# brctl showbridge name bridge id STP enabled interfacesbrq9252cb78-d1 8000.000c2981308f no ens33 tap3bbe2f60-5a
Node2 network card changes;
[[email protected] Linux-node2 ~]# ifconfig brq9252cb78-d1:flags=4163<up,broadcast,running,multicast> MTU inet 192.168.56.12 netmask 255.255.255.0 broadcast 192.168.56.255 Inet6 fe80::2cf6:8ff:fed1:e558 Prefixlen ScopeID 0x20<link> ether 00:0c:29:b2:dc:b3 txqueuelen (Ethernet) RX packets 3911 Bytes 834854 (815.2 KiB) RX errors 0 dropped 0 overruns 0 frame 0 TX packets 4240 bytes 1069545 (1.0 M IB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0ENS33:FLAGS=4163<UP,BROADCAST,RUNNING,MULTICAST&G T MTU Inet6 fe80::9752:504d:ee43:64f5 prefixlen scopeid 0x20<link> ether 00:0c:29:b2:dc:b3 TX Queuelen (Ethernet) Rx packets 2044792 bytes 230569291 (219.8 MiB) Rx Errors 0 dropped 0 overruns 0 Frame 0 TX Packets 2033577 bytes 214521423 (204.5 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 Coll Isions 0ENS37:FLAGS=4163< Up,broadcast,running,multicast> MTU inet 192.168.47.143 netmask 255.255.255.0 broadcast 192.168.47.255 Inet6 fe80::c33f:7c14:d42c:bc06 prefixlen scopeid 0x20<link> ether 00:0c:29:b2:dc:bd Txqueuelen 1 (Ethernet) Rx packets 133097 bytes 145683102 (138.9 MiB) Rx Errors 0 dropped 0 overruns 0 frame 0 TX Packets 27306 Bytes 1767757 (1.6 MiB) TX errors 0 dropped 0 overruns 0 carrier 0 collisions 0lo:flags =73<up,loopback,running> MTU 65536 inet 127.0.0.1 netmask 255.0.0.0 inet6:: 1 Prefixlen Scopei D 0x10
[[email protected] linux-node2 ~]# brctl showbridge name bridge id STP enabled interfacesbrq9252cb78-d1 8000.000c29b2dcb3 no ens33 tapf761b1bc-25
Version Openstack-liberty create the first virtual machine (vi)