Cloudcomputing Kochbuch Load Balancer as a Service (LBaaS)

IMT HilfeWiki - das Wiki

Allgemeine Informationen
Anleitung
Informationen
BetriebssystemAlle
ServiceCloudcomputing
Interessant fürAngestellte, Studierende und Gäste
HilfeWiki des IMT der Uni Paderborn

no displaytitle found: Cloudcomputing Kochbuch Load Balancer as a Service (LBaaS)

... Hinweis auf den CLI Artikel hier ...

Informationen zum Erzeugen des Kommandozeilen-Clients

Rezepte[Bearbeiten | Quelltext bearbeiten]

Schritt 1: Drei Webserver instanziieren[Bearbeiten | Quelltext bearbeiten]

ubuntu@api-kochbuch-demo:~$ wget https://rgw.cloud.uni-paderborn.de:8443/swift/v1/hilfe-uni-paderborn-de-snippets/cloudcomputing/hilfewiki-apache2-lb.sh
2016-09-23 10:16:47 (5.22 MB/s) - ‘hilfewiki-apache2-lb.sh’ saved [283/283]

ubuntu@api-kochbuch-demo:~$ cat hilfewiki-apache2-lb.sh 
#!/bin/bash

PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/snap/bin"

sudo apt-get update -y
sudo apt-get install -y apache2
sudo sh -c 'hostname > /var/www/html/ip.txt'
sudo sh -c 'ip a | grep "scope global" >> /var/www/html/ip.txt'


ubuntu@api-kochbuch-demo:~$ openstack server create \
    --image Ubuntu-16.04-Xenial-Xerus \
    --flavor m1.small \
    --security-group SSH-Zugriff \
    --security-group HTTP \
    --key-name mein-oeffentlicher-schluessel \
    --nic net-id=0a2cafd5-3a3f-4312-95fe-584240ab1a3b \
    --user-data hilfewiki-apache2-lb.sh \
    --min 3 --max 3 \
    --wait \
    Loadbalancer-Webserver

+--------------------------------------+------------------------------------------------------------------+
| Field                                | Value                                                            |
+--------------------------------------+------------------------------------------------------------------+
| OS-DCF:diskConfig                    | MANUAL                                                           |
| OS-EXT-AZ:availability_zone          | nova                                                             |
| OS-EXT-SRV-ATTR:host                 | cpu3                                                             |
| OS-EXT-SRV-ATTR:hypervisor_hostname  | cpu3.cloud.uni-paderborn.de                                      |
| OS-EXT-SRV-ATTR:instance_name        | instance-0000018d                                                |
| OS-EXT-STS:power_state               | 1                                                                |
| OS-EXT-STS:task_state                | None                                                             |
| OS-EXT-STS:vm_state                  | active                                                           |
| OS-SRV-USG:launched_at               | 2016-09-23T10:25:11.000000                                       |
| OS-SRV-USG:terminated_at             | None                                                             |
| accessIPv4                           |                                                                  |
| accessIPv6                           |                                                                  |
| addresses                            | Privates-Kochbuch-Test-Netz=192.168.0.111                        |
| adminPass                            | 6sVWYrqAZWGR                                                     |
| config_drive                         |                                                                  |
| created                              | 2016-09-23T10:24:59Z                                             |
| flavor                               | m1.small (2)                                                     |
| hostId                               | a70656c29b3b898217f4e2db350807f468bd150e035a36787fa49e3d         |
| id                                   | 11b5d731-451c-4173-a422-4bca08c9bd2e                             |
| image                                | Ubuntu-16.04-Xenial-Xerus (0b3be2c2-ef73-4b90-898e-e676671e6849) |
| key_name                             | mein-oeffentlicher-schluessel                                    |
| name                                 | Loadbalancer-Webserver-1                                         |
| os-extended-volumes:volumes_attached | []                                                               |
| progress                             | 0                                                                |
| project_id                           | 3ceb7c480ede4680bb42be90b365375d                                 |
| properties                           |                                                                  |
| security_groups                      | [{u'name': u'SSH-Zugriff'}, {u'name': u'HTTP'}]                  |
| status                               | ACTIVE                                                           |
| updated                              | 2016-09-23T10:25:12Z                                             |
| user_id                              | 648800718411377698900aa0a353b3e3dc69d98bc569b455312fdabfa36bb9e8 |
+--------------------------------------+------------------------------------------------------------------+

ubuntu@api-kochbuch-demo:~$ openstack server list
+--------------------------------------+--------------------------+--------+-------------------------------------------+
| ID                                   | Name                     | Status | Networks                                  |
+--------------------------------------+--------------------------+--------+-------------------------------------------+
| 635397a6-cb75-45eb-8ce0-63e7db4b5882 | Loadbalancer-Webserver-3 | ACTIVE | Privates-Kochbuch-Test-Netz=192.168.0.112 |
| 5307dd9b-29df-4779-8b2a-0a06798ec077 | Loadbalancer-Webserver-2 | ACTIVE | Privates-Kochbuch-Test-Netz=192.168.0.110 |
| 11b5d731-451c-4173-a422-4bca08c9bd2e | Loadbalancer-Webserver-1 | ACTIVE | Privates-Kochbuch-Test-Netz=192.168.0.111 |
+--------------------------------------+--------------------------+--------+-------------------------------------------+

Schritt 2: Loadbalancer erzeugen, VIP, Pools und Mitglieder konfigurieren[Bearbeiten | Quelltext bearbeiten]

ubuntu@api-kochbuch-demo:~$ neutron lbaas-loadbalancer-create --name Kochbuch-Loadbalancer Privates-Kochbuch-Test-Subnetz
Created a new loadbalancer:
+---------------------+--------------------------------------+
| Field               | Value                                |
+---------------------+--------------------------------------+
| admin_state_up      | True                                 |
| description         |                                      |
| id                  | d1ff1dbd-d7ae-4665-ad24-6a9967d066f6 |
| listeners           |                                      |
| name                | Kochbuch-Loadbalancer                |
| operating_status    | OFFLINE                              |
| pools               |                                      |
| provider            | haproxy                              |
| provisioning_status | ACTIVE                               |
| tenant_id           | 3ceb7c480ede4680bb42be90b365375d     |
| vip_address         | 192.168.0.113                        |
| vip_port_id         | 88021fc7-c30e-40a6-b0bc-c65f0b17e357 |
| vip_subnet_id       | 71851d4c-9578-4e13-935c-d2ea6eddf5fd |
+---------------------+--------------------------------------+


ubuntu@api-kochbuch-demo:~$  neutron port-update \
  --security-group HTTP \
  88021fc7-c30e-40a6-b0bc-c65f0b17e357



ubuntu@api-kochbuch-demo:~$  neutron lbaas-listener-create \
  --name Kochbuch-Loadbalancer-HTTP \
  --loadbalancer Kochbuch-Loadbalancer \
  --protocol HTTP \
  --protocol-port 80

Created a new listener:
+---------------------------+------------------------------------------------+
| Field                     | Value                                          |
+---------------------------+------------------------------------------------+
| admin_state_up            | True                                           |
| connection_limit          | -1                                             |
| default_pool_id           |                                                |
| default_tls_container_ref |                                                |
| description               |                                                |
| id                        | a5d52b12-6318-44ca-9c52-69a561f143fe           |
| loadbalancers             | {"id": "d1ff1dbd-d7ae-4665-ad24-6a9967d066f6"} |
| name                      | Kochbuch-Loadbalancer-HTTP                     |
| protocol                  | HTTP                                           |
| protocol_port             | 80                                             |
| sni_container_refs        |                                                |
| tenant_id                 | 3ceb7c480ede4680bb42be90b365375d               |
+---------------------------+------------------------------------------------+


ubuntu@api-kochbuch-demo:~$ neutron lbaas-pool-create \
  --name Kochbuch-Loadbalancer-HTTP-Pool \
  --lb-algorithm ROUND_ROBIN \
  --listener Kochbuch-Loadbalancer-HTTP \
  --protocol HTTP

Created a new pool:
+---------------------+------------------------------------------------+
| Field               | Value                                          |
+---------------------+------------------------------------------------+
| admin_state_up      | True                                           |
| description         |                                                |
| healthmonitor_id    |                                                |
| id                  | de737c6c-ccad-432d-b365-89fa23148ca2           |
| lb_algorithm        | ROUND_ROBIN                                    |
| listeners           | {"id": "a5d52b12-6318-44ca-9c52-69a561f143fe"} |
| loadbalancers       | {"id": "d1ff1dbd-d7ae-4665-ad24-6a9967d066f6"} |
| members             |                                                |
| name                | Kochbuch-Loadbalancer-HTTP-Pool                |
| protocol            | HTTP                                           |
| session_persistence |                                                |
| tenant_id           | 3ceb7c480ede4680bb42be90b365375d               |
+---------------------+------------------------------------------------+



ubuntu@api-kochbuch-demo:~$  neutron lbaas-member-create \
  --subnet Privates-Kochbuch-Test-Subnetz \
  --address 192.168.0.110 \
  --protocol-port 80 \
  Kochbuch-Loadbalancer-HTTP-Pool

Created a new member:
+----------------+--------------------------------------+
| Field          | Value                                |
+----------------+--------------------------------------+
| address        | 192.168.0.110                        |
| admin_state_up | True                                 |
| id             | e35b7005-ad08-40b5-b360-c8117a07f760 |
| name           |                                      |
| protocol_port  | 80                                   |
| subnet_id      | 71851d4c-9578-4e13-935c-d2ea6eddf5fd |
| tenant_id      | 3ceb7c480ede4680bb42be90b365375d     |
| weight         | 1                                    |
+----------------+--------------------------------------+

ubuntu@api-kochbuch-demo:~$ neutron lbaas-member-create \
  --subnet Privates-Kochbuch-Test-Subnetz \
  --address 192.168.0.111 \
  --protocol-port 80 \
  Kochbuch-Loadbalancer-HTTP-Pool

Created a new member:
+----------------+--------------------------------------+
| Field          | Value                                |
+----------------+--------------------------------------+
| address        | 192.168.0.111                        |
| admin_state_up | True                                 |
| id             | 1165034f-01ae-4b6f-bd57-d7c4cffbed50 |
| name           |                                      |
| protocol_port  | 80                                   |
| subnet_id      | 71851d4c-9578-4e13-935c-d2ea6eddf5fd |
| tenant_id      | 3ceb7c480ede4680bb42be90b365375d     |
| weight         | 1                                    |
+----------------+--------------------------------------+

ubuntu@api-kochbuch-demo:~$ neutron lbaas-member-create \
  --subnet Privates-Kochbuch-Test-Subnetz \
  --address 192.168.0.112 \
  --protocol-port 80 \
  Kochbuch-Loadbalancer-HTTP-Pool

Created a new member:
+----------------+--------------------------------------+
| Field          | Value                                |
+----------------+--------------------------------------+
| address        | 192.168.0.112                        |
| admin_state_up | True                                 |
| id             | 3a34eedc-ef18-4f10-8261-071fb82f70ac |
| name           |                                      |
| protocol_port  | 80                                   |
| subnet_id      | 71851d4c-9578-4e13-935c-d2ea6eddf5fd |
| tenant_id      | 3ceb7c480ede4680bb42be90b365375d     |
| weight         | 1                                    |
+----------------+--------------------------------------+


ubuntu@api-kochbuch-demo:~$ neutron lbaas-loadbalancer-list
+--------------------------------------+-----------------------+---------------+---------------------+----------+
| id                                   | name                  | vip_address   | provisioning_status | provider |
+--------------------------------------+-----------------------+---------------+---------------------+----------+
| d1ff1dbd-d7ae-4665-ad24-6a9967d066f6 | Kochbuch-Loadbalancer | 192.168.0.113 | ACTIVE              | haproxy  |
+--------------------------------------+-----------------------+---------------+---------------------+----------+

ubuntu@api-kochbuch-demo:~$ neutron lbaas-listener-list
+--------------------------------------+--------------------------------------+----------------------------+----------+---------------+----------------+
| id                                   | default_pool_id                      | name                       | protocol | protocol_port | admin_state_up |
+--------------------------------------+--------------------------------------+----------------------------+----------+---------------+----------------+
| a5d52b12-6318-44ca-9c52-69a561f143fe | de737c6c-ccad-432d-b365-89fa23148ca2 | Kochbuch-Loadbalancer-HTTP | HTTP     |            80 | True           |
+--------------------------------------+--------------------------------------+----------------------------+----------+---------------+----------------+

ubuntu@api-kochbuch-demo:~$ neutron lbaas-pool-list 
+--------------------------------------+---------------------------------+----------+----------------+
| id                                   | name                            | protocol | admin_state_up |
+--------------------------------------+---------------------------------+----------+----------------+
| de737c6c-ccad-432d-b365-89fa23148ca2 | Kochbuch-Loadbalancer-HTTP-Pool | HTTP     | True           |
+--------------------------------------+---------------------------------+----------+----------------+

ubuntu@api-kochbuch-demo:~$ neutron lbaas-member-list Kochbuch-Loadbalancer-HTTP-Pool
+--------------------------------------+------+---------------+---------------+--------+--------------------------------------+----------------+
| id                                   | name | address       | protocol_port | weight | subnet_id                            | admin_state_up |
+--------------------------------------+------+---------------+---------------+--------+--------------------------------------+----------------+
| 1165034f-01ae-4b6f-bd57-d7c4cffbed50 |      | 192.168.0.111 |            80 |      1 | 71851d4c-9578-4e13-935c-d2ea6eddf5fd | True           |
| 3a34eedc-ef18-4f10-8261-071fb82f70ac |      | 192.168.0.112 |            80 |      1 | 71851d4c-9578-4e13-935c-d2ea6eddf5fd | True           |
| e35b7005-ad08-40b5-b360-c8117a07f760 |      | 192.168.0.110 |            80 |      1 | 71851d4c-9578-4e13-935c-d2ea6eddf5fd | True           |
+--------------------------------------+------+---------------+---------------+--------+--------------------------------------+----------------+

Schritt 3: Funktionstest[Bearbeiten | Quelltext bearbeiten]

ubuntu@api-kochbuch-demo:~$ curl http://192.168.0.113/ip.txt
loadbalancer-webserver-1
    inet 192.168.0.111/24 brd 192.168.0.255 scope global ens3

ubuntu@api-kochbuch-demo:~$ curl http://192.168.0.113/ip.txt
loadbalancer-webserver-2
    inet 192.168.0.110/24 brd 192.168.0.255 scope global ens3

ubuntu@api-kochbuch-demo:~$ curl http://192.168.0.113/ip.txt
loadbalancer-webserver-3
    inet 192.168.0.112/24 brd 192.168.0.255 scope global ens3

ubuntu@api-kochbuch-demo:~$ curl http://192.168.0.113/ip.txt
loadbalancer-webserver-1
    inet 192.168.0.111/24 brd 192.168.0.255 scope global ens3

Schritt 4: Funktionsmonitore[Bearbeiten | Quelltext bearbeiten]

ubuntu@api-kochbuch-demo:~$ neutron lbaas-healthmonitor-create \
  --delay 5 \
  --max-retries 2 \
  --timeout 10 \
  --type HTTP \
  --pool Kochbuch-Loadbalancer-HTTP-Pool

Created a new healthmonitor:
+----------------+------------------------------------------------+
| Field          | Value                                          |
+----------------+------------------------------------------------+
| admin_state_up | True                                           |
| delay          | 5                                              |
| expected_codes | 200                                            |
| http_method    | GET                                            |
| id             | 2e4e1849-e794-4cda-9d05-773cfc50fc3d           |
| max_retries    | 2                                              |
| name           |                                                |
| pools          | {"id": "de737c6c-ccad-432d-b365-89fa23148ca2"} |
| tenant_id      | 3ceb7c480ede4680bb42be90b365375d               |
| timeout        | 10                                             |
| type           | HTTP                                           |
| url_path       | /                                              |
+----------------+------------------------------------------------+


Schritt 5: Statistiken[Bearbeiten | Quelltext bearbeiten]

ubuntu@api-kochbuch-demo:~$ neutron lbaas-loadbalancer-stats Kochbuch-Loadbalancer
+--------------------+-------+
| Field              | Value |
+--------------------+-------+
| active_connections | 0     |
| bytes_in           | 1577  |
| bytes_out          | 6422  |
| total_connections  | 19    |
+--------------------+-------+


Schritt 6: Floating IP zuweisen[Bearbeiten | Quelltext bearbeiten]

ubuntu@api-kochbuch-demo:~$ neutron floatingip-list 
+--------------------------------------+------------------+---------------------+--------------------------------------+
| id                                   | fixed_ip_address | floating_ip_address | port_id                              |
+--------------------------------------+------------------+---------------------+--------------------------------------+
| f3a6d4cd-53ef-4f55-a9d2-f644cf3ce25c |                  | 192.26.184.42       |                                      |
+--------------------------------------+------------------+---------------------+--------------------------------------+


$ neutron floatingip-associate FLOATINGIP_ID LOAD_BALANCER_PORT_ID

<syntaxhighlight lang="bash">
ubuntu@api-kochbuch-demo:~$ neutron floatingip-associate f3a6d4cd-53ef-4f55-a9d2-f644cf3ce25c  88021fc7-c30e-40a6-b0bc-c65f0b17e357
Associated floating IP f3a6d4cd-53ef-4f55-a9d2-f644cf3ce25c




Siehe auch[Bearbeiten | Quelltext bearbeiten]


Bei Fragen oder Problemen wenden Sie sich bitte telefonisch oder per E-Mail an uns:

Tel. IT: +49 (5251) 60-5544 Tel. Medien: +49 (5251) 60-2821 E-Mail: imt@uni-paderborn.de

Das Notebook-Café ist die Benutzerberatung des IMT

Das IMT:Notebook-Café (Raum I0.401) bietet in der vorlesungsfreien Zeit nur eingeschränkten Support

Mo Di-Do Fr
Vor-Ort-Support - 09-13 Uhr -
Telefonsupport 08:30-13 Uhr & 13:30-15 Uhr 08:30-13 Uhr

Das IMT:Servicecenter Medien auf H1 hat aktuell von Montag bis Freitag von 08:00-13:00 Uhr geöffnet.


Cookies helfen uns bei der Bereitstellung des IMT HilfeWikis. Bei der Nutzung vom IMT HilfeWiki werden die in der Datenschutzerklärung beschriebenen Cookies gespeichert.