Cloudcomputing Kochbuch Compute

IMT:HilfeWiki - das Wiki
Wechseln zu: Navigation, Suche
Anleitung
Allgemeine Informationen
Informationen
Betriebssystem Alle
Service Cloudcomputing
Interessant für Angestellte, Studierende und Gäste
HilfeWiki des IMT der Uni Paderborn

Wichtiger Hinweis: Um diese Anleitung nutzen zu können wird ein Kommandozeilen-Client benötigt. Die Bespiele in diesem Kochbuch sind mit den OpenStack Command-line Clients 2.3.0 aus Ubuntu 16.04.1 LTS erzeugt. Neuere Clients können eine etwas andere Aufruf-Syntax haben.

Informationen zum Erzeugen der Kommandozeilen-Clients

Bis auf Ausnahmen lassen sich alle Einstellungen auch im Dashboard vornehmen. Beachten Sie bitte den Artikel Cloudcomputing Aktuelle Informationen.


Rezepte

Abbilder

Auflisten der verfügbaren Abbilder

ubuntu@api-kochbuch-demo:~$ openstack image list
+--------------------------------------+---------------------------------+--------+
| ID                                   | Name                            | Status |
+--------------------------------------+---------------------------------+--------+
| 8965758d-18ae-42a6-bd14-029367d7a27c | Windows Server 2012 R2 Std Eval | active |
| 5d0678d9-56ea-49bc-a0bf-36d96f87810f | openSUSE-13                     | active |
| 3c1c0c93-3a95-4188-9ef7-71866d129750 | Debian-Testing                  | active |
| 7d963cbe-5657-4176-9fec-9640e56f320a | CentOS-7                        | active |
| 0b3be2c2-ef73-4b90-898e-e676671e6849 | Ubuntu-16.04-Xenial-Xerus       | active |
| 5ec22335-1480-417a-b8b3-6eea8791dffe | CirrOS-Image-0.3.2              | active |
+--------------------------------------+---------------------------------+--------+

Einspielen eines Abbildes ins Cloudsystem

usage: openstack image create [-h] [-f {json,shell,table,value,yaml}]
                              [-c COLUMN] [--max-width <integer>] [--noindent]
                              [--prefix PREFIX] [--id <id>]
                              [--container-format <container-format>]
                              [--disk-format <disk-format>]
                              [--min-disk <disk-gb>] [--min-ram <ram-mb>]
                              [--file <file>] [--volume <volume>] [--force]
                              [--protected | --unprotected]
                              [--public | --private] [--property <key=value>]
                              [--tag <tag>] [--project <project>]
                              [--project-domain <project-domain>]
                              <image-name>

Umfangreichere Hilfe mit openstack image create --help

Beispiel: Einspielen eines CentOS 6 Cloud Images, heruntergeladen aus den CentOS Cloud Images.

ubuntu@api-kochbuch-demo:~$ wget http://cloud.centos.org/centos/6/images/CentOS-6-x86_64-GenericCloud-1608.raw.tar.gz
[...]
2016-09-21 06:49:02 (17.1 MB/s) - ‘CentOS-6-x86_64-GenericCloud-1608.raw.tar.gz’ saved [260367618/260367618]
ubuntu@api-kochbuch-demo:~$ tar -xvzf CentOS-6-x86_64-GenericCloud-1608.raw.tar.gz 
CentOS-6-x86_64-GenericCloud-1608.raw

Das Image wird nach dem Herunterladen entpackt und inkl. der Angabe von minimalen Anforderungen an Festplattenspeicher und RAM eingespielt.

ubuntu@api-kochbuch-demo:~$ openstack image create \
	--property hypervisor_type=qemu \
	--container-format bare \
	--disk-format raw \
	--min-disk 1 \
	--min-ram 256 \
	--file CentOS-6-x86_64-GenericCloud-1608.raw \
	--private \
	CentOS-6-x86_64-GenericCloud-1608
 
+------------------+------------------------------------------------------+
| Field            | Value                                                |
+------------------+------------------------------------------------------+
| checksum         | 9a44adfc62adf520e63298dac0bda27f                     |
| container_format | bare                                                 |
| created_at       | 2016-09-21T06:52:35Z                                 |
| disk_format      | raw                                                  |
| file             | /v2/images/1bc15b27-031b-4b96-966b-ec8eb9c15b79/file |
| id               | 1bc15b27-031b-4b96-966b-ec8eb9c15b79                 |
| min_disk         | 1                                                    |
| min_ram          | 256                                                  |
| name             | CentOS-6-x86_64-GenericCloud-1608                    |
| owner            | 3ceb7c480ede4680bb42be90b365375d                     |
| properties       | hypervisor_type='qemu'                               |
| protected        | False                                                |
| schema           | /v2/schemas/image                                    |
| size             | 8589934592                                           |
| status           | active                                               |
| tags             |                                                      |
| updated_at       | 2016-09-21T06:54:53Z                                 |
| virtual_size     | None                                                 |
| visibility       | private                                              |
+------------------+------------------------------------------------------+

Löschen eines Abbildes

ubuntu@api-kochbuch-demo:~$ openstack image delete CentOS-6-x86_64-GenericCloud-1608


Schlüsselpaare

Erzeugen eines Schlüsselpaares

ubuntu@api-kochbuch-demo:~$ ssh-keygen -t rsa -b 4096 -C "ubuntu@api-kochbuch-demo"
Generating public/private rsa key pair.
Enter file in which to save the key (/home/ubuntu/.ssh/id_rsa): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/ubuntu/.ssh/id_rsa.
Your public key has been saved in /home/ubuntu/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:l9G2HrX6YVlQNl9T4Y0otPtuESpZT7TzEbrhvjXWyKw ubuntu@api-kochbuch-demo
The key's randomart image is:
+---[RSA 4096]----+
|          .    +B|
|         . o..o+*|
|          +.+o+oo|
|          .*Bo.o |
|        So+=o*...|
|        o..o==.= |
|         . .+.@ .|
|           .o* o |
|           .E..  |
+----[SHA256]-----+

Der geheime und der öffentliche Schlüssel liegen nun in /home/ubuntu/.ssh/

ubuntu@api-kochbuch-demo:~$ ls -alh /home/ubuntu/.ssh/
total 20K
drwx------ 2 ubuntu ubuntu 4.0K Sep 21 07:52 .
drwxr-xr-x 4 ubuntu ubuntu 4.0K Sep 21 06:49 ..
-rw------- 1 ubuntu ubuntu  414 Sep 19 11:43 authorized_keys
-rw------- 1 ubuntu ubuntu 3.2K Sep 21 07:52 id_rsa
-rw-r--r-- 1 ubuntu ubuntu  750 Sep 21 07:52 id_rsa.pub


Auflisten der verfügbaren Schlüsselpaare

ubuntu@api-kochbuch-demo:~$ openstack keypair list
+-------------------------------+-------------------------------------------------+
| Name                          | Fingerprint                                     |
+-------------------------------+-------------------------------------------------+
| mein-oeffentlicher-schluessel | 32:9d:46:b9:5a:90:3f:e8:6c:c5:2c:d5:56:ca:fc:51 |
+-------------------------------+-------------------------------------------------+

Einspielen eines Schlüsselpaares

ubuntu@api-kochbuch-demo:~$ openstack keypair create --public-key /home/ubuntu/.ssh/id_rsa.pub mein-oeffentlicher-schluessel
+-------------+------------------------------------------------------------------+
| Field       | Value                                                            |
+-------------+------------------------------------------------------------------+
| fingerprint | 32:9d:46:b9:5a:90:3f:e8:6c:c5:2c:d5:56:ca:fc:51                  |
| name        | mein-oeffentlicher-schluessel                                    |
| user_id     | 648800718411377698900aa0a353b3e3dc69d98bc569b455312fdabfa36bb9e8 |
+-------------+------------------------------------------------------------------+

Löschen eines Schlüsselpaares

ubuntu@api-kochbuch-demo:~$ openstack keypair delete mein-oeffentlicher-schluessel


Sicherheitsgruppen

Auflisten der verfügbaren Sicherheitsgruppen

ubuntu@api-kochbuch-demo:~$ openstack security group list
+--------------------------------------+-----------------+--------------------------+----------------------------------+
| ID                                   | Name            | Description              | Project                          |
+--------------------------------------+-----------------+--------------------------+----------------------------------+
| 10ca62ef-8bc1-433d-a9da-1b20f5ae72ff | SSH-Demo        | Zugriff via SSH erlauben | 0cc039b0eab849888c980a23606d3a52 |
+--------------------------------------+-----------------+--------------------------+----------------------------------+

Einspielen einer Sicherheitsgruppe, sowie erstellen von Zugriffsregeln

ubuntu@api-kochbuch-demo:~$ openstack security group create --description "Zugriff via SSH erlauben" SSH-Zugriff
+-------------+--------------------------------------+
| Field       | Value                                |
+-------------+--------------------------------------+
| description | Zugriff via SSH erlauben             |
| id          | 4ffcc76b-1970-4e4a-8a95-8488109f9ddc |
| name        | SSH-Zugriff                          |
| rules       | []                                   |
| tenant_id   | 3ceb7c480ede4680bb42be90b365375d     |
+-------------+--------------------------------------+


ubuntu@api-kochbuch-demo:~$ openstack security group rule create --proto TCP --src-ip 0.0.0.0/0 --dst-port 22 SSH-Zugriff
+-----------------------+--------------------------------------+
| Field                 | Value                                |
+-----------------------+--------------------------------------+
| id                    | 43319261-0567-4889-9bd9-d11468147c5e |
| ip_protocol           | tcp                                  |
| ip_range              | 0.0.0.0/0                            |
| parent_group_id       | 4ffcc76b-1970-4e4a-8a95-8488109f9ddc |
| port_range            | 22:22                                |
| remote_security_group |                                      |
+-----------------------+--------------------------------------+

Sinnvolle alternative zu 0.0.0.0/0 ist auch 131.234.0.0/16.


ubuntu@api-kochbuch-demo:~$ openstack security group rule list SSH-Zugriff
+--------------------------------------+-------------+-----------+------------+-----------------------+
| ID                                   | IP Protocol | IP Range  | Port Range | Remote Security Group |
+--------------------------------------+-------------+-----------+------------+-----------------------+
| 43319261-0567-4889-9bd9-d11468147c5e | tcp         | 0.0.0.0/0 | 22:22      |                       |
+--------------------------------------+-------------+-----------+------------+-----------------------+

Löschen einer Sicherheitsgruppe

ubuntu@api-kochbuch-demo:~$ openstack security group delete SSH-Zugriff


Instanzen

Auflisten der verfügbaren Varianten

ubuntu@api-kochbuch-demo:~$ openstack flavor list
+--------------------------------------+-------------------+-------+------+-----------+-------+-----------+
| ID                                   | Name              |   RAM | Disk | Ephemeral | VCPUs | Is Public |
+--------------------------------------+-------------------+-------+------+-----------+-------+-----------+
| 1                                    | m1.tiny           |   512 |    1 |         0 |     1 | True      |
| 2                                    | m1.small          |  2048 |   20 |         0 |     1 | True      |
| 3                                    | m1.medium         |  4096 |   40 |         0 |     2 | True      |
| 4                                    | m1.large          |  8192 |   80 |         0 |     4 | True      |
| 5                                    | m1.xlarge         | 16384 |  160 |         0 |     8 | True      |
| 678ce37b-aad6-435e-9c9c-519a2caaf67e | teutostack.tiny   |   512 |    1 |         0 |     1 | True      |
| 4529b369-48a9-479e-ba9a-b232c6aeb533 | teutostack.small  |  2048 |   20 |         0 |     1 | True      |
| 7808f8d4-d730-493e-b63d-8a9a2392a637 | teutostack.medium |  4096 |   40 |         0 |     2 | True      |
| 62b309b4-1ef0-4e9b-affd-77033f5c471f | teutostack.large  |  8192 |   80 |         0 |     4 | True      |
| cc55d4dd-71c0-4d03-af13-f35ba820ec8b | teutostack.xlarge | 16384 |  160 |         0 |     8 | True      |
+--------------------------------------+-------------------+-------+------+-----------+-------+-----------+


Auflisten der laufenden Instanzen

ubuntu@api-kochbuch-demo:~$ openstack server list
+--------------------------------------+--------------------+--------+----------------------------------------------------------+
| ID                                   | Name               | Status | Networks                                                 |
+--------------------------------------+--------------------+--------+----------------------------------------------------------+
| 80d6f685-5e23-4624-94f7-954351da8e68 | CentOS6-Instanz    | ACTIVE | Privates-Kochbuch-Test-Netz=192.168.0.101, 192.26.184.42 |
+--------------------------------------+--------------------+--------+----------------------------------------------------------+

Erzeugen einer neuen Instanz

Achtung: Es wird hier davon ausgegangen, dass Netzwerke, Subnetzte und Router nach dem Cloudcomputing Kochbuch Netzwerk angelegt wurden.

Als Vorbereitung muss die ID des Subnetzes gesucht werden, in dem die Instanz gestartet werden soll.

ubuntu@api-kochbuch-demo:~$ openstack network list
+--------------------------------------+-----------------------------+--------------------------------------+
| ID                                   | Name                        | Subnets                              |
+--------------------------------------+-----------------------------+--------------------------------------+
| 0a2cafd5-3a3f-4312-95fe-584240ab1a3b | Privates-Kochbuch-Test-Netz | 71851d4c-9578-4e13-935c-d2ea6eddf5fd |
+--------------------------------------+-----------------------------+--------------------------------------+

Wichtig ist hier die ID 0a2cafd5-3a3f-4312-95fe-584240ab1a3b.


usage: openstack server create [-h] [-f {json,shell,table,value,yaml}]
                               [-c COLUMN] [--max-width <integer>]
                               [--noindent] [--prefix PREFIX]
                               (--image <image> | --volume <volume>) --flavor
                               <flavor>
                               [--security-group <security-group-name>]
                               [--key-name <key-name>]
                               [--property <key=value>]
                               [--file <dest-filename=source-filename>]
                               [--user-data <user-data>]
                               [--availability-zone <zone-name>]
                               [--block-device-mapping <dev-name=mapping>]
                               [--nic <net-id=net-uuid,v4-fixed-ip=ip-addr,v6-fixed-ip=ip-addr,port-id=port-uuid>]
                               [--hint <key=value>]
                               [--config-drive <config-drive-volume>|True]
                               [--min <count>] [--max <count>] [--wait]
                               <server-name>


ubuntu@api-kochbuch-demo:~$ openstack server create \
    --image CentOS-6-x86_64-GenericCloud-1608 \
    --flavor m1.small \
    --security-group SSH-Zugriff \
    --key-name mein-oeffentlicher-schluessel \
    --nic net-id=0a2cafd5-3a3f-4312-95fe-584240ab1a3b \
    --wait \
    CentOS6-Instanz
 
+--------------------------------------+--------------------------------------------------------------------------+
| Field                                | Value                                                                    |
+--------------------------------------+--------------------------------------------------------------------------+
| addresses                            | Privates-Kochbuch-Test-Netz=192.168.0.101                                |
| created                              | 2016-09-21T09:40:30Z                                                     |
| flavor                               | m1.small (2)                                                             |
| hostId                               | 8d18bd9e4d5097279235d7648729143d9eed73853ecfe20c50b9c413                 |
| id                                   | 80d6f685-5e23-4624-94f7-954351da8e68                                     |
| image                                | CentOS-6-x86_64-GenericCloud-1608 (1bc15b27-031b-4b96-966b-ec8eb9c15b79) |
| key_name                             | mein-oeffentlicher-schluessel                                            |
| name                                 | CentOS6-Instanz                                                          |
| project_id                           | 3ceb7c480ede4680bb42be90b365375d                                         |
| security_groups                      | [{u'name': u'SSH-Zugriff'}]                                              |
| status                               | ACTIVE                                                                   |
| updated                              | 2016-09-21T09:41:42Z                                                     |
| user_id                              | 648800718411377698900aa0a353b3e3dc69d98bc569b455312fdabfa36bb9e8         |
+--------------------------------------+--------------------------------------------------------------------------+


ubuntu@api-kochbuch-demo:~$ openstack server list
+--------------------------------------+--------------------+--------+-------------------------------------------+
| ID                                   | Name               | Status | Networks                                  |
+--------------------------------------+--------------------+--------+-------------------------------------------+
| 80d6f685-5e23-4624-94f7-954351da8e68 | CentOS6-Instanz    | ACTIVE | Privates-Kochbuch-Test-Netz=192.168.0.101 |
+--------------------------------------+--------------------+--------+-------------------------------------------+


Die Maschine wurde gestartet mit der IP-Adresse 192.168.0.101 im privaten Subnetz.

In der Netzwerktopologie Ansicht des Dashboards sollte folgendes dargestellt werden.

Cloudcomputing-Kochbuch-Netzwerktopologie-mit-Instanz.png

Das Consolen-Log zum Start der Maschine kann eingesehen werden um Fingerprints vom SSH Dienst o.Ae. zu überprüfen.

ubuntu@api-kochbuch-demo:~$ openstack console log  show CentOS6-Instanz
 
Press any key to continue.
    GNU GRUB  version 0.97  (639K lower / 2096000K upper memory)
 
[...]
 
Starting cloud-init: Cloud-init v. 0.7.5 running 'init' at Wed, 21 Sep 2016 09:42:01 +0000. Up 19.47 seconds.
ci-info: +++++++++++++++++++++++++++Net device info+++++++++++++++++++++++++++
ci-info: +--------+------+---------------+---------------+-------------------+
ci-info: | Device |  Up  |    Address    |      Mask     |     Hw-Address    |
ci-info: +--------+------+---------------+---------------+-------------------+
ci-info: |   lo   | True |   127.0.0.1   |   255.0.0.0   |         .         |
ci-info: |  eth0  | True | 192.168.0.101 | 255.255.255.0 | fa:16:3e:b3:45:09 |
ci-info: +--------+------+---------------+---------------+-------------------+
ci-info: ++++++++++++++++++++++++++++++++++Route info+++++++++++++++++++++++++++++++++++
ci-info: +-------+-----------------+-------------+-----------------+-----------+-------+
ci-info: | Route |   Destination   |   Gateway   |     Genmask     | Interface | Flags |
ci-info: +-------+-----------------+-------------+-----------------+-----------+-------+
ci-info: |   0   | 169.254.169.254 | 192.168.0.1 | 255.255.255.255 |    eth0   |  UGH  |
ci-info: |   1   |   192.168.0.0   |   0.0.0.0   |  255.255.255.0  |    eth0   |   U   |
ci-info: |   2   |     0.0.0.0     | 192.168.0.1 |     0.0.0.0     |    eth0   |   UG  |
ci-info: +-------+-----------------+-------------+-----------------+-----------+-------+
Starting cloud-init: Cloud-init v. 0.7.5 running 'modules:config' at Wed, 21 Sep 2016 09:42:05 +0000. Up 23.33 seconds.
Starting cloud-init: Cloud-init v. 0.7.5 running 'modules:final' at Wed, 21 Sep 2016 09:42:07 +0000. Up 24.82 seconds.
ci-info: ++++++++++++++Authorized keys from /home/centos/.ssh/authorized_keys for user centos++++++++++++++
ci-info: +---------+-------------------------------------------------+---------+--------------------------+
ci-info: | Keytype |                Fingerprint (md5)                | Options |         Comment          |
ci-info: +---------+-------------------------------------------------+---------+--------------------------+
ci-info: | ssh-rsa | 32:9d:46:b9:5a:90:3f:e8:6c:c5:2c:d5:56:ca:fc:51 |    -    | ubuntu@api-kochbuch-demo |
ci-info: +---------+-------------------------------------------------+---------+--------------------------+
ec2: 
ec2: #############################################################
ec2: -----BEGIN SSH HOST KEY FINGERPRINTS-----
ec2: 1024 94:2e:84:a6:91:b3:99:0f:3a:8f:a1:ab:02:64:b2:44 /etc/ssh/ssh_host_dsa_key.pub (DSA)
ec2: 2048 42:f6:e9:a2:8a:d1:69:36:de:46:50:0b:df:3a:ff:0e /etc/ssh/ssh_host_key.pub (RSA1)
ec2: 2048 5d:15:45:8b:17:fc:36:24:4a:fc:7f:38:73:80:75:c2 /etc/ssh/ssh_host_rsa_key.pub (RSA)
ec2: -----END SSH HOST KEY FINGERPRINTS-----
ec2: #############################################################
-----BEGIN SSH HOST KEY KEYS-----
2048 35 24729335969706217270572574187095548970469722209977583944970987336352842868656255121532431941480242942539756030561541945947352763741180035553477761940604337636014595623125408519146312364565194088248950213301746440491257505680148337626835295310581260264512640963689919603371444875301829077011219264762263766126220049453080479312075733802418176798297220049674483748238187029296069254560842930151829137531042469449012610655457512179119906290038268702890222767304514651228106292711590861328050790807511000803047647492237039936698387111541210742381953681362477782395209040886655431597197973703324881097533544486225175204259 
ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAsda1es6Oudmm9POPZb+NjLMDoayDUopCcox3CXqzuLp204Kz7OwTBt4T7S0dnoIjAi4dLYFtMew4DWIGVNd3EiBCV8A8YALyhgMSopbT4+Zu9t+nC3NCMz6EZf4OFiWYd4WkhRnLhZ2GtIvt5byH+N/oNKIpUZA9ZVy2ZdTYSfRutm9cnjm8MUcBWfYAyH9HxfstyGxA3bK14D6Jr1xk5EVARGaaW38F0OTc48jV72m7fUjoiHx0Yt0aKt4voDCMY+VevhOaBCMambFVte0OkIezqTlxhfsJsej4dhUu7dWRj23AzJGpu09UaP42myysF793PociyYBR4ao72EU3hw== 
-----END SSH HOST KEY KEYS-----
Cloud-init v. 0.7.5 finished at Wed, 21 Sep 2016 09:42:07 +0000. Datasource DataSourceOpenStack [net,ver=2].  Up 25.01 seconds
 
[...]
 
CentOS release 6.8 (Final)
Kernel 2.6.32-642.4.2.el6.x86_64 on an x86_64
 
centos6-instanz login:


Um von Außen (ausserhalb des privaten Netzes) auf die Instanz zugreifen zu können, muss eine Floating-IP auf die Maschine konfiguriert werden. Es kann eine neue Floating-IP belegt werden oder eine die bereits belegt war wiederverwendet werden. Die Floating-IP muss dazu aus einem Netz kommen dass auch über einen zugehörigen Router erreicht werden kann.

ubuntu@api-kochbuch-demo:~$ openstack ip floating pool list
+----------------------+
| Name                 |
+----------------------+
| physext_uni_services |
| physext_f5_net       |
| physext_dmz_uni      |
| physext_private_uni  |
| physext_public_uni   |
+----------------------+


ubuntu@api-kochbuch-demo:~$ openstack ip floating create physext_public_uni
+-------------+--------------------------------------+
| Field       | Value                                |
+-------------+--------------------------------------+
| fixed_ip    | None                                 |
| id          | f3a6d4cd-53ef-4f55-a9d2-f644cf3ce25c |
| instance_id | None                                 |
| ip          | 192.26.184.42                        |
| pool        | physext_public_uni                   |
+-------------+--------------------------------------+


ubuntu@api-kochbuch-demo:~$ openstack ip floating add 192.26.184.42 CentOS6-Instanz


ubuntu@api-kochbuch-demo:~$ openstack server list
+--------------------------------------+--------------------+--------+----------------------------------------------------------+
| ID                                   | Name               | Status | Networks                                                 |
+--------------------------------------+--------------------+--------+----------------------------------------------------------+
| 80d6f685-5e23-4624-94f7-954351da8e68 | CentOS6-Instanz    | ACTIVE | Privates-Kochbuch-Test-Netz=192.168.0.101, 192.26.184.42 |
+--------------------------------------+--------------------+--------+----------------------------------------------------------+


Der im Consolen-Log ausgegebene SSH-Host Key Fingerprint (hier im Beispiel ssh-rsa AAAAB3NzaC1 [...] kann ich der lokalen .ssh/known_hosts eingetragen werden. Geschieht dies nicht, wird der Fingerprint beim ersten Login per SSH nach Korrektheit abgefragt.

ubuntu@api-kochbuch-demo:~$ vi .ssh/known_hosts 
192.26.184.42 ssh-rsa AAAAB3NzaC1yc2EAA [gekürzt] o72EU3hw==
ubuntu@api-kochbuch-demo:~$ ssh -i /home/ubuntu/.ssh/id_rsa centos@192.26.184.42
[centos@centos6-instanz ~]$
 
[centos@centos6-instanz ~]$ id
uid=500(centos) gid=500(centos) groups=500(centos),4(adm),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
 
[centos@centos6-instanz ~]$ sudo -s
[root@centos6-instanz centos]# id
uid=0(root) gid=0(root) groups=0(root) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
 
[root@centos6-instanz centos]#

Die Maschine läuft und ist erreichbar.

Löschen einer laufenden Instanz

ubuntu@api-kochbuch-demo:~$ openstack server delete CentOS6-Instanz

Datenträger

Datenträger stellen Speicher dar, die unabhängig von der Instanz verwaltet werden. Datenträger können an eine Instanz gehängt werden. Die Wahl kann später verändert werden. Von Datenträger können Schahttenkopien erzeugt werden. Sollen von mehreren Datenträger gleichzeitig eine Schattenkopie erzeugt werden, geschieht dies über eine Datenträger-Konsistenzgruppe. Datenträger können auch zwischen Projekten transferiert werden.

Erzeugen eines Datenträgers

ubuntu@api-kochbuch-demo:~$ openstack volume create --description "Beschreibung" --type ceph --size 1 Datentraeger
+---------------------+------------------------------------------------------------------+
| Field               | Value                                                            |
+---------------------+------------------------------------------------------------------+
| attachments         | []                                                               |
| availability_zone   | nova                                                             |
| bootable            | false                                                            |
| consistencygroup_id | None                                                             |
| created_at          | 2016-09-29T05:12:13.729776                                       |
| description         | Beschreibung                                                     |
| encrypted           | False                                                            |
| id                  | d610eea4-bd71-4f57-b24d-7eda28871de3                             |
| migration_status    | None                                                             |
| multiattach         | False                                                            |
| name                | Datentraeger                                                     |
| properties          |                                                                  |
| replication_status  | disabled                                                         |
| size                | 1                                                                |
| snapshot_id         | None                                                             |
| source_volid        | None                                                             |
| status              | creating                                                         |
| type                | ceph                                                             |
| updated_at          | None                                                             |
| user_id             | 648800718411377698900aa0a353b3e3dc69d98bc569b455312fdabfa36bb9e8 |
+---------------------+------------------------------------------------------------------+
 
ubuntu@api-kochbuch-demo:~$ openstack volume list 
+--------------------------------------+--------------+-----------+------+-------------+
| ID                                   | Display Name | Status    | Size | Attached to |
+--------------------------------------+--------------+-----------+------+-------------+
| d610eea4-bd71-4f57-b24d-7eda28871de3 | Datentraeger | available |    1 |             |
+--------------------------------------+--------------+-----------+------+-------------+

Auflisten der vorhandenen Datenträger

ubuntu@api-kochbuch-demo:~$ openstack volume list 
+--------------------------------------+--------------+-----------+------+-------------+
| ID                                   | Display Name | Status    | Size | Attached to |
+--------------------------------------+--------------+-----------+------+-------------+
| d610eea4-bd71-4f57-b24d-7eda28871de3 | Datentraeger | available |    1 |             |
| 4b9e27cf-f9d0-49a9-901e-2ce7261da4fe | test         | available |    1 |             |
+--------------------------------------+--------------+-----------+------+-------------+
 
ubuntu@api-kochbuch-demo:~$ openstack volume show Datentraeger
+--------------------------------+------------------------------------------------------------------+
| Field                          | Value                                                            |
+--------------------------------+------------------------------------------------------------------+
| attachments                    | []                                                               |
| availability_zone              | nova                                                             |
| bootable                       | false                                                            |
| consistencygroup_id            | None                                                             |
| created_at                     | 2016-09-29T05:12:14.000000                                       |
| description                    | Beschreibung                                                     |
| encrypted                      | False                                                            |
| id                             | d610eea4-bd71-4f57-b24d-7eda28871de3                             |
| migration_status               | None                                                             |
| multiattach                    | False                                                            |
| name                           | Datentraeger                                                     |
| os-vol-host-attr:host          | cinder.cloud.uni-paderborn.de@ceph#ceph                          |
| os-vol-mig-status-attr:migstat | None                                                             |
| os-vol-mig-status-attr:name_id | None                                                             |
| os-vol-tenant-attr:tenant_id   | 3ceb7c480ede4680bb42be90b365375d                                 |
| properties                     |                                                                  |
| replication_status             | disabled                                                         |
| size                           | 1                                                                |
| snapshot_id                    | None                                                             |
| source_volid                   | None                                                             |
| status                         | available                                                        |
| type                           | ceph                                                             |
| updated_at                     | 2016-09-29T05:12:14.000000                                       |
| user_id                        | 648800718411377698900aa0a353b3e3dc69d98bc569b455312fdabfa36bb9e8 |
+--------------------------------+------------------------------------------------------------------+

Erzeugen eines Schattenkopie von einem Datenträgers

ubuntu@api-kochbuch-demo:~$ openstack snapshot create --description "Schattenkopie 1 vom Datentraeger" --name "Schattenkopie 1" Datentraeger
+-------------+--------------------------------------+
| Field       | Value                                |
+-------------+--------------------------------------+
| created_at  | 2016-09-29T07:31:07.788996           |
| description | Schattenkopie 1 vom Datentraeger     |
| id          | 41a1e859-ec4f-4e4b-b2aa-fc115286198e |
| name        | Schattenkopie 1                      |
| properties  |                                      |
| size        | 1                                    |
| status      | creating                             |
| updated_at  | None                                 |
| volume_id   | d610eea4-bd71-4f57-b24d-7eda28871de3 |
+-------------+--------------------------------------+
 
ubuntu@api-kochbuch-demo:~$ openstack snapshot list
+--------------------------------------+-----------------+----------------------------------+-----------+------+
| ID                                   | Name            | Description                      | Status    | Size |
+--------------------------------------+-----------------+----------------------------------+-----------+------+
| 41a1e859-ec4f-4e4b-b2aa-fc115286198e | Schattenkopie 1 | Schattenkopie 1 vom Datentraeger | available |    1 |
+--------------------------------------+-----------------+----------------------------------+-----------+------+

Aus Schattenkopien können wieder Datenträger erzeugt werden.


Anhängen eines Datenträgers an eine Instanz

ubuntu@api-kochbuch-demo:~$ openstack server list
+--------------------------------------+-------------------+--------+---------------------------------------+
| ID                                   | Name              | Status | Networks                              |
+--------------------------------------+-------------------+--------+---------------------------------------+
| fa33d34a-0826-4024-a896-fba3929affae | ServerA           | ACTIVE | PrivatesNetzA=10.1.0.3, 192.26.184.45 |
+--------------------------------------+-------------------+--------+---------------------------------------+
 
ubuntu@api-kochbuch-demo:~$ nova volume-attach fa33d34a-0826-4024-a896-fba3929affae d610eea4-bd71-4f57-b24d-7eda28871de3
+----------+--------------------------------------+
| Property | Value                                |
+----------+--------------------------------------+
| device   | /dev/vdb                             |
| id       | d610eea4-bd71-4f57-b24d-7eda28871de3 |
| serverId | fa33d34a-0826-4024-a896-fba3929affae |
| volumeId | d610eea4-bd71-4f57-b24d-7eda28871de3 |
+----------+--------------------------------------+
 
ubuntu@api-kochbuch-demo:~$ openstack volume list
+--------------------------------------+--------------+-----------+------+----------------------------------+
| ID                                   | Display Name | Status    | Size | Attached to                      |
+--------------------------------------+--------------+-----------+------+----------------------------------+
| d610eea4-bd71-4f57-b24d-7eda28871de3 | Datentraeger | in-use    |    1 | Attached to ServerA on /dev/vdb  |
+--------------------------------------+--------------+-----------+------+----------------------------------+
 
ubuntu@api-kochbuch-demo:~$ openstack volume show Datentraeger
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| Field                          | Value                                                                                                                                                                                                                                                                                                                  |
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
| attachments                    | [{u'server_id': u'fa33d34a-0826-4024-a896-fba3929affae', u'attachment_id': u'7744c818-9f6f-48d2-b093-afd82323d050', u'attached_at': u'2016-09-29T08:12:19.000000', u'host_name': None, u'volume_id': u'd610eea4-bd71-4f57-b24d-7eda28871de3', u'device': u'/dev/vdb', u'id': u'd610eea4-bd71-4f57-b24d-7eda28871de3'}] |
| availability_zone              | nova                                                                                                                                                                                                                                                                                                                   |
| bootable                       | false                                                                                                                                                                                                                                                                                                                  |
| consistencygroup_id            | None                                                                                                                                                                                                                                                                                                                   |
| created_at                     | 2016-09-29T05:12:14.000000                                                                                                                                                                                                                                                                                             |
| description                    | Beschreibung                                                                                                                                                                                                                                                                                                           |
| encrypted                      | False                                                                                                                                                                                                                                                                                                                  |
| id                             | d610eea4-bd71-4f57-b24d-7eda28871de3                                                                                                                                                                                                                                                                                   |
| migration_status               | None                                                                                                                                                                                                                                                                                                                   |
| multiattach                    | False                                                                                                                                                                                                                                                                                                                  |
| name                           | Datentraeger                                                                                                                                                                                                                                                                                                           |
| os-vol-host-attr:host          | cinder.cloud.uni-paderborn.de@ceph#ceph                                                                                                                                                                                                                                                                                |
| os-vol-mig-status-attr:migstat | None                                                                                                                                                                                                                                                                                                                   |
| os-vol-mig-status-attr:name_id | None                                                                                                                                                                                                                                                                                                                   |
| os-vol-tenant-attr:tenant_id   | 3ceb7c480ede4680bb42be90b365375d                                                                                                                                                                                                                                                                                       |
| properties                     | attached_mode='rw', readonly='False'                                                                                                                                                                                                                                                                                   |
| replication_status             | disabled                                                                                                                                                                                                                                                                                                               |
| size                           | 1                                                                                                                                                                                                                                                                                                                      |
| snapshot_id                    | None                                                                                                                                                                                                                                                                                                                   |
| source_volid                   | None                                                                                                                                                                                                                                                                                                                   |
| status                         | in-use                                                                                                                                                                                                                                                                                                                 |
| type                           | ceph                                                                                                                                                                                                                                                                                                                   |
| updated_at                     | 2016-09-29T08:12:19.000000                                                                                                                                                                                                                                                                                             |
| user_id                        | 648800718411377698900aa0a353b3e3dc69d98bc569b455312fdabfa36bb9e8                                                                                                                                                                                                                                                       |
+--------------------------------+------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
 
ubuntu@api-kochbuch-demo:~$ openstack server show ServerA
+--------------------------------------+------------------------------------------------------------------+
| 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-0000019f                                                |
| 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-26T06:19:02.000000                                       |
| OS-SRV-USG:terminated_at             | None                                                             |
| accessIPv4                           |                                                                  |
| accessIPv6                           |                                                                  |
| addresses                            | PrivatesNetzA=10.1.0.3, 192.26.184.45                            |
| config_drive                         |                                                                  |
| created                              | 2016-09-26T06:18:51Z                                             |
| flavor                               | m1.small (2)                                                     |
| hostId                               | a70656c29b3b898217f4e2db350807f468bd150e035a36787fa49e3d         |
| id                                   | fa33d34a-0826-4024-a896-fba3929affae                             |
| image                                | CirrOS-Image-0.3.2 (5ec22335-1480-417a-b8b3-6eea8791dffe)        |
| key_name                             | mein-oeffentlicher-schluessel                                    |
| name                                 | ServerA                                                          |
| os-extended-volumes:volumes_attached | [{u'id': u'd610eea4-bd71-4f57-b24d-7eda28871de3'}]               |
| progress                             | 0                                                                |
| project_id                           | 3ceb7c480ede4680bb42be90b365375d                                 |
| properties                           |                                                                  |
| security_groups                      | [{u'name': u'SSH+ICMP'}]                                         |
| status                               | ACTIVE                                                           |
| updated                              | 2016-09-26T06:19:02Z                                             |
| user_id                              | 648800718411377698900aa0a353b3e3dc69d98bc569b455312fdabfa36bb9e8 |
+--------------------------------------+------------------------------------------------------------------+

Löschen eines Datenträgers

ubuntu@api-kochbuch-demo:~$ openstack volume delete Datentraeger

Siehe auch


Bei Fragen oder Problemen wenden Sie sich bitte an die IMT:Benutzerberatung

Notebook-Café BI1.111 IMT:ServicePoint N5.345 Tel.: +49 (5251) 60-5544 E-Mail: imt@uni-paderborn.de