Das Wort „OpenStack“ ist heutzutage sehr beliebt. Vielleicht haben Sie dieses Wort schon einmal gehört, auch wenn Sie nicht im Bereich Cloud Computing tätig sind. Ich habe in den letzten 10 Jahren im Grid-Computing-Bereich gearbeitet und nie die Aufregung hinter OpenStack verstanden. Aber dieses Schlagwort klopfte immer wieder an meine Ohren, wohin ich auch ging – im Ernst, in meinem Büro, Konferenzen und beliebten Websites, die OpenStack immer wieder bewarben. Schließlich wurde ich (ja, mit Nachdruck von meinem Chef) in die Welt von OpenStack gedrängt und diese großen Fragen forderten einen Tribut von mir – Was ist OpenStack, wie wird es implementiert und wie funktioniert es? Nun, der einzige Weg, OpenStack zu verstehen, ist, mit einer Installation zu beginnen.
Auf den ersten Blick sah der Einstieg in OpenStack einfach aus, ist es aber nicht. Ja, die offizielle Website von OpenStack hat eine gute Dokumentation, aber das eigentliche Problem, mit dem ich konfrontiert war, waren die verwendeten Terminologien – Horizon, Glance, Keystone, Nova, Neutron, Swift, Heat, Cinder, Ceilometer….Uff, warum zum Teufel sind sie das? so genannt? Und dann gab es mehrere andere Begriffe, die mit der Installation verknüpft waren – RDO, Packstack, Devstack, verschiedene Architekturen (ein Knoten, zwei Knoten und Multinode), Legacy-Netzwerke usw. Ernsthaft, ich musste zurück zu Google laufen, um all diese zu verstehen (und dieser Typ hat großartige Arbeit geleistet). Nun, wenn Sie mich bitten, über meine Erfahrungen mit OpenStack zu schreiben, dann wird dieser Artikel auf 20 Seiten reduziert. Also werde ich hier aufhören und zum Thema übergehen.
Inhaltsverzeichnis
- Einführung in OpenStack
- Testbed-Architektur
- Installieren und konfigurieren Sie NTP sowohl auf dem Controller als auch auf dem Rechenknoten
- Installieren und konfigurieren Sie MySQL sowohl auf dem Controller als auch auf dem Rechenknoten
- Installieren und konfigurieren Sie Apache Qpid sowohl auf dem Controller als auch auf dem Rechenknoten
- Installieren Sie die Basispakete von OpenStack Icehouse auf dem Controller und dem Rechenknoten
- Installieren Sie KeyStone auf dem Controller-Knoten
- Installieren Sie Glance auf dem Controller-Knoten
- Installieren Sie Nova auf dem Controller-Knoten
- Installieren Sie Nova-Networking auf dem Controller-Knoten
- Dashboard auf dem Controller-Knoten installieren
- Installieren Sie Nova auf dem Rechenknoten
- Installieren Sie Nova-Networking auf dem Rechenknoten
- Instanz erstellen
- Melden Sie sich bei der Instanz an
Was ist OpenStack?
OpenStack ist eine Open-Source-Cloud-Computing-Plattform, die Infrastructure as a Service (IaaS) bereitstellt. Wenn Sie ein Grid-Computing-Experte sind, dann ist OpenStack etwas Ähnliches wie beliebte Grid-Middleware wie Globus Toolkit, Glite, Oracle Grid Engine, Unicore usw. OpenStack ist im Grunde eine Middleware, mit der Sie Cloud-Computing-Ressourcen effizienter und natürlich verwalten können , effektiv.
OpenStack-Dienste
- Horizont :Ein Dashboard-Dienst, der ein Webportal für die Interaktion und Verwaltung der zugrunde liegenden Dienste, virtuellen Instanzen, Nutzer und des Netzwerks bereitstellt.
- Nova :Ein Rechendienst, der bei der Verwaltung von Recheninstanzen hilft – was das Spawnen, Planen, Booten und Beenden einer virtuellen Maschine umfasst.
- Schlüsselstein :Ein Identitätsdienst, der Authentifizierung und Autorisierung bereitstellt.
- Neutron :Ein Netzwerkdienst, mit dem Sie Netzwerke erstellen und verwalten können.
- Blick :Ein Image-Dienst, der beim Speichern und Abrufen von Images virtueller Maschinen hilft.
- Datenbank service :Stellt eine Datenbank als Dienst bereit.
- Swift und Cinder :Bietet Speicher als Dienst.
- Telemetrie :Ein Dienst, der Ihnen hilft, Abrechnung und Benchmarking zu verwalten.
- Es gibt noch viele andere Dienste … lesen Sie mehr auf openstack.org.
Architektur
Wenn Sie ein Anfänger sind, ist es ideal, mit einer Zwei-Knoten-Architektur zu beginnen – ein Knoten heißt „Controller“ und der andere „Compute“. In diesem Tutorial werden wir die OpenStack Icehouse-Version auf dem Betriebssystem CentOS 6.6 installieren. Die auf dem Controller-Knoten zu installierenden Dienste sind Keystone, Glance, Nova, Networking (Legacy-Nova-Networking), Horizon und der Rechenknoten wird Nova und Networking (Legacy-Nova-Networking) haben.
Hinweis: OpenStack-Anfänger? Es wird empfohlen, mit dem alten Netzwerk von Nova zu beginnen. Das Verständnis und die Konfiguration von "Neutron" ist in dieser Phase eine große Herausforderung. Sie sollten jedoch zu einem späteren Zeitpunkt eine Migration von Legacy-Netzwerken zu Neutron in Erwägung ziehen.
Unten sehen Sie das Diagramm, das mein Testbed darstellt. Alle meine Installationsschritte basieren auf der folgenden Architektur.
Hinweis: Da wir das Legacy-Nova-Netzwerk verwenden werden, benötigen wir nur eine Schnittstelle im Controller-Knoten für Verwaltungszwecke und zwei Schnittstellen im Compute-Knoten (eine für die Verwaltung, die in dasselbe Netzwerk des Controller-Knotens fällt, und die andere Schnittstelle ist für externe, was wird für die VM-Kommunikation verwendet).
Nun, wir können mit den Installationsschritten fortfahren.
Wie installiere und konfiguriere ich OpenStack Icehouse auf CentOS?
Ich verwende,
- ‘Controller-Hostname ‘ als Hostname des Controller-Knotens und „compute-hostname ” als Hostname des Compute-Knotens.
- „10.180.10.132“ (Verwaltungs-IP) für den Controller-Knoten und „10.180.10.134“ (Verwaltungs-IP) für den Rechenknoten. Die externe IP des Rechenknotens lautet „10.180.14.151“.
Hinweis: Denken Sie daran, diese durch die entsprechenden FQDN- oder IP-Adressen zu ersetzen.
- Während der Installation, wo immer Sie "setpassword" finden ‘, ersetzen Sie es durch das entsprechende Service-Passwort.
- Ich werde „YUM“ für den größten Teil der Installation verwenden. Stellen Sie also sicher, dass die Maschinen mit dem Internet verbunden sind. Falls Sie Probleme bei der Konfiguration von yum haben, sind die folgenden Anleitungen eine große Hilfe.
- So konfigurieren Sie das Yum-Repository auf CentOS
- Yum-Befehle, die Sie kennen müssen.
- Die Ausgabe der wenigen Befehle wurde abgeschnitten, um Verwirrung zu vermeiden und die Länge dieser Anleitung zu verkürzen.
Die Installation einer beliebigen Komponente (oder eines Dienstes) in OpenStack umfasst die folgenden Schritte:
Installieren und konfigurieren Sie NTP sowohl auf dem Controller als auch auf dem Rechenknoten
Sie können schnell lernen, wie Sie das Network Time Protocol auf Ihrem Controller und Ihren Rechenknoten installieren und konfigurieren.
NTP konfiguriert und ntpd-Dienst gestartet? Dann zurück zu diesem Artikel…
Aktualisieren Sie das Betriebssystem sowohl auf dem Controller als auch auf dem Compute-Knoten
Es wird immer empfohlen, das Betriebssystem zu aktualisieren, bevor Sie eine Komponente installieren. Es wird viele Probleme mit Paketabhängigkeiten lösen.
[root@controller-hostname ]# yum update [root@compute-hostname ]# yum update
Installieren Sie die MySQL-Datenbank sowohl auf dem Controller als auch auf dem Rechenknoten
Hinweis: MySQL heißt jetzt ‚Mariadb‘.
[root@controller-hostname ]# yum install mysql mysql-server MySQL-python [root@compute-hostname ]# yum install mysql mysql-server MySQL-python
Sie müssen sich „/etc/my.cnf ansehen ‘, um sicherzustellen, dass der MySQL-Dienst die Verwaltungs-IP-Adresse sowohl des Controllers als auch der Rechenknoten bindet.
Auf Controller-Knoten :
[root@controller-hostname ]# vi /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql bind-address=10.180.10.132 symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
Auf Rechenknoten :
[root@compute-hostname ]# vi /etc/my.cnf [mysqld] datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql bind-address=10.180.10.134 symbolic-links=0 [mysqld_safe] log-error=/var/log/mysqld.log pid-file=/var/run/mysqld/mysqld.pid
Starten Sie den MySQL-Server:
[root@controller-hostname ~]# service mysqld start [root@compute-hostname ~]# service mysqld start
MySQL einrichten…
[root@controller-hostname ~]# mysql_install_db [root@compute-hostname ~]# mysql_install_db
Es wird immer empfohlen, „mysql_secure_installation“ auszuführen ‘ nach der Installation von MySQL.
[root@controller-hostname ~]# mysql_secure_installation [root@compute-hostname ~]# mysql_secure_installation
Wenn Sie sich nicht sicher sind, was mysql_secure_installation tut, dann finden Sie hier eine Kurzanleitung, die es im Detail erklärt.
Installieren Sie Basis-OpenStack-Icehouse-Pakete sowohl auf dem Controller als auch auf dem Rechenknoten
Richten Sie das Yum-Repository ein und installieren Sie die Icehouse-Basispakete. Dieser Schritt muss sowohl auf dem Controller als auch auf den Rechenknoten durchgeführt werden.
Auf Controller-Knoten:
[root@controller-hostname ~]# yum install yum-plugin-priorities [root@controller-hostname ~]# yum install http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/rdo-release-icehouse-4.noarch.rpm [root@controller-hostname ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-RDO-Icehouse [root@controller-hostname ~]# yum -y install http://fedora.cu.be/epel/7/x86_64/e/epel-release-7-2.noarch.rpm [root@controller-hostname ~]# yum install openstack-utils openstack-selinux
Auf Compute-Knoten:
[root@compute-hostname ~]# yum install yum-plugin-priorities [root@compute-hostname ~]# yum install http://repos.fedorapeople.org/repos/openstack/openstack-icehouse/rdo-release-icehouse-4.noarch.rpm [root@compute-hostname ~]# rpm --import /etc/pki/rpm-gpg/RPM-GPG-KEY-RDO-Icehouse [root@compute-hostname ~]# yum -y install http://fedora.cu.be/epel/7/x86_64/e/epel-release-7-2.noarch.rpm [root@compute-hostname ~]# yum install openstack-utils openstack-selinux
Installieren Sie den Message Broker-Dienst auf dem Controller-Knoten
OpenStack-Dienste benötigen für ihre Kommunikation einen Message Broker. Derzeit unterstützt OpenStack – Rabbit-mq und Apache Qpid. In diesem Tutorial installieren wir Qpid-server.
Apache-Qpid ermöglicht Diensten das Senden und Empfangen von Nachrichten über AMQP (Advanced Message Queuing Protocol).
[root@controller-hostname ~]# yum install qpid-cpp-server
qpid-cpp-server konfigurieren ohne die Notwendigkeit einer Authentifizierung zu arbeiten (Dies wird unseren Installationsprozess vereinfachen. Aus Sicherheitsgründen sollten Sie jedoch die Authentifizierung aktivieren)
[root@controller-hostname ~]# echo "auth=no">/etc/qpid/qpidd.conf
Nachrichtenbroker starten…
[root@controller-hostname ~]# service qpidd start
Installieren und Konfigurieren von Keystone (Identitätsdienst) auf dem Controller-Knoten
Wie ich bereits sagte, spielt der Keystone-Dienst eine wichtige Rolle in OpenStack – er bietet Authentifizierung und Autorisierung. Das bedeutet auch, dass jeder Dienst von OpenStack (einschließlich Identitätsdienst) bei KeyStone registriert werden muss.
Keystone-Pakete installieren…
[root@controller-hostname ~]# yum install openstack-keystone python-keystoneclient
Erstellen Sie eine Datenbank für Keystone , damit der Dienst seinen Zustand und seine Daten speichern kann…
[root@controller-hostname ~]# mysql -u root -p mysql> CREATE DATABASE keystone; mysql> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'controller-hostname' IDENTIFIED BY 'setpassword'; mysql> GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'setpassword';
Hinweis: Denken Sie daran, „setpassword“ durch Ihr eigenes Passwort für Keystone zu ersetzen.
Tabellen für Keystone-Datenbank erstellen…
[root@controller-hostname ~]# su -s /bin/sh -c "keystone-manage db_sync" keystone
Sagen Sie Keystone jetzt, dass Sie dies verwenden sollten, um eine Datenbankverbindung herzustellen
[root@controller-hostname ~]# openstack-config --set /etc/keystone/keystone.conf database connection mysql://keystone:setpassword@controller-hostname/keystone
Hinweis: Denken Sie daran, „setpassword“ durch das passende Passwort „keystone“@mysql
zu ersetzenErstellen Sie ein Authentifizierungstoken, um andere Dienste mit Keystone zu authentifizieren. Dazu verwenden wir openssl, um einen zufälligen HEX-Wert zu generieren und ihn in einer Variablen namens „ADMIN_TOKEN zu speichern ‘
[root@controller-hostname ~]# ADMIN_TOKEN=$(openssl rand -hex 10) [root@controller-hostname ~]# echo $ADMIN_TOKEN e9393f7ac1886f0c1a20
Hinweis: Erstellen Sie eine Kopie des generierten Tokens, da Sie dies später benötigen (nicht erforderlich, wenn Sie Ihre Terminalsitzung nicht auf halbem Weg beenden)
Konfigurieren Sie Keystone für die Verwendung des Authentifizierungstokens im vorherigen Schritt generiert…
[root@controller-hostname ~]# openstack-config --set /etc/keystone/keystone.conf DEFAULT admin_token $ADMIN_TOKEN
Konfigurieren Sie Keystone, um PKI-basierte Authentifizierungstoken bereitzustellen..
[root@controller-hostname ~]# keystone-manage pki_setup --keystone-user keystone --keystone-group keystone
Legen Sie den Besitz und die Berechtigung für den „Keystone“-Benutzer fest…
[root@controller-hostname ~]# chown -R keystone:keystone /etc/keystone/ssl [root@controller-hostname ~]# chmod -R o-rwx /etc/keystone/ssl
Alles fertig für Keystone, starten wir den Dienst…
[root@controller-hostname ~]# service openstack-keystone start
Stellen Sie sicher, dass der Dienst wirklich ausgeführt wird, indem Sie seinen Status überprüfen
[root@controller-hostname ~]# service openstack-keystone status keystone (pid 10245) is running...
Falls der Dienst nach dem Start tot ist, sollten Sie dieses Problem an dieser Stelle selbst beheben.
Stellen Sie den Dienst so ein, dass er während des Systemstarts automatisch gestartet wird…
[root@controller-hostname ~]# chkconfig openstack-keystone on
Abgelaufene Keystone-Token automatisch löschen…
Während des Betriebs können viele abgelaufene Token im Keystone vorhanden sein, wodurch die Größe der Keystone-Datenbank zunimmt. Es ist eine gute Idee, diese in regelmäßigen Abständen zu löschen. Dazu setzen wir Cron-Jobs wie folgt:
[root@controller-hostname ~]# echo '@hourly /usr/bin/keystone-manage token_flush >/var/log/keystone/keystone-tokenflush.log 2&>&1' >> /var/spool/cron/keystone [root@controller-hostname ~]# crontab -l -u keystone @hourly /usr/bin/keystone-manage token_flush > /var/log/keystone/keystone-tokenflush.log 2&>&1
Erstellen Sie Benutzer, Mandanten und Rollen für Keystone
Bevor Sie Keystone-Befehle ausführen, sollten Sie bestimmte Umgebungsvariablen festlegen. Erstellen Sie dazu eine Datei mit dem Namen „admin-openrc.sh ‘ und legen Sie die Umgebungsvariablen wie folgt fest:
[root@controller-hostname ~]# vi admin-openrc.sh export OS_USERNAME=admin export OS_PASSWORD=setpassword export OS_TENANT_NAME=admin export OS_AUTH_URL=http://controller-hostname:35357/v2.0 [root@controller-hostname ~]# source admin-openrc.sh
Lassen Sie uns einen Benutzer erstellen…
[root@controller-hostname ~]# keystone user-create --name=admin --pass=setpassword --email=keystone@controller-hostname
Rolle erstellen…
[root@controller-hostname ~]# keystone role-create --name=admin
Mandanten erstellen…
[root@controller-hostname ~]# keystone tenant-create --name=admin --description="Admin Tenant"
Wir müssen den Benutzer mit der Rolle und dem Mandanten verknüpfen, die in den vorherigen Schritten erstellt wurden …
[root@controller-hostname ~]# keystone user-role-add --user=admin --role=admin --tenant=admin
Registrieren Sie den Keystone (Identitätsdienst) beim KeyStone-Dienst
[root@controller-hostname ~]# keystone tenant-create --name=service --description="Service Tenant" [root@controller-hostname ~]# keystone service-create --name=keystone --type=identity --description="OpenStack Identity" [root@controller-hostname ~]# keystone endpoint-create --service-id=$(keystone service-list | awk '/ compute / {print $2}') --publicurl=http://controller-hostame:8774/v2/%\(tenant_id\)s --internalurl=http://controller-hostame:8774/v2/%\(tenant_id\)s --adminurl=http://controller-hostame:8774/v2/%\(tenant_id\)s
Das war’s, die KeyStone-Konfiguration ist abgeschlossen … Falls Sie während der Keystone-Installation und -Konfiguration auf ein Problem stoßen, finden Sie hier eine Lösung für verschiedene Keystone-Fehler – Häufige Keystone-Dienstfehler und Lösungen .
Installieren Sie Glance (Image Service) auf dem Controller-Knoten
Der Image-Dienst wird auf dem Controller-Knoten installiert, um alle Images zu hosten, die zum Starten von VMs auf dem Compute-Knoten verwendet werden sollen.
[root@controller-hostname ~]# yum install openstack-glance python-glanceclient
Datenbank-„Blick“ einrichten…
[root@controller-hostname ~]# mysql -u root -p mysql> CREATE DATABASE glance; mysql> GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'controller-hostname' IDENTIFIED BY 'setpassword'; mysql > GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' IDENTIFIED BY 'setpassword';
Hinweis: Denken Sie daran, „setpassword“ zu ändern
Tabellen für die Datenbank „Glance“ erstellen…
[root@controller-hostname ~]# su -s /bin/sh -c "glance-manage db_sync" glance
Glick-Dienst konfigurieren, um Datenbankanmeldeinformationen zu lesen…
[root@controller-hostname ~]# openstack-config --set /etc/glance/glance-api.conf database connection mysql://glance:setpassword@controller-hostname/glance [root@controller-hostname ~]# glance-registry.conf database connection mysql://glance:setpassword@controller-hostname/glance
Glance-Benutzer in KeyStone erstellen…
[root@controller-hostname ~]# keystone user-create --name=glance --pass=setpassword --email=glance@controller-hostname
Fügen Sie der Rolle „admin“ einen Blickbenutzer hinzu
[root@controller-hostname ~]# keystone user-role-add --user=glance --tenant=service --role=admin
Authentifizierung für Glance konfigurieren…
[root@controller-hostname ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_uri http://controller-hostname:5000 [root@controller-hostname ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_host controller-hostname [root@controller-hostname ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_port 35357 [root@controller-hostname ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken auth_protocol http [root@controller-hostname ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_tenant_name service [root@controller-hostname ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_user glance [root@controller-hostname ~]# openstack-config --set /etc/glance/glance-api.conf keystone_authtoken admin_password setpassword [root@controller-hostname ~]# openstack-config --set /etc/glance/glance-api.conf paste_deploy flavor keystone [root@controller-hostname ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_uri http://controller-hostname:5000 [root@controller-hostname ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_host controller-hostname [root@controller-hostname ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_port 35357 [root@controller-hostname ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken auth_protocol http [root@controller-hostname ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_tenant_name service [root@controller-hostname ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_user glance [root@controller-hostname ~]# openstack-config --set /etc/glance/glance-registry.conf keystone_authtoken admin_password setpassword [root@controller-hostname ~]# openstack-config --set /etc/glance/glance-registry.conf paste_deploy flavor keystone
Glance-Dienst bei KeyStone registrieren…
[root@controller-hostname ~]# keystone service-create --name=glance --type=image --description="OpenStack Image Service" [root@controller-hostname ~]# keystone --os-token=fd465d38e342ddc68be3 --os-endpoint=http://controller-hostname:35357/v2.0 endpoint-create --service-id=$(keystone service-list | awk '/ image / {print $2}') --publicurl=http://controller-hostname:9292 --internalurl=http://controller-hostname:9292 --adminurl=http://controller-hostname:9292
Übersichtsdienste starten…
[root@controller-hostname ~]# service openstack-glance-api start [root@controller-hostname ~]# service openstack-glance-registry start [root@controller-hostname ~]# chkconfig openstack-glance-api on [root@controller-hostname ~]# chkconfig openstack-glance-registry on
Hinweis: Wenn einer der Dienste nicht gestartet werden kann, überprüfen Sie die Protokolldateien unter /var/log/glance . Lesen Sie auch diese Anleitung – Installationsfehler und Lösungen für den OpenStack Glance Image Service.
Glance-Service testen…
Wir werden jetzt das Cirros-Image herunterladen, um den Blickdienst zu testen. Cirros ist ein winziges Linux-Betriebssystem, das nur wenige MB groß ist, sodass es ganz einfach heruntergeladen und zum Glance-Dienst hinzugefügt werden kann.
[root@controller-hostname ~]# wget http://cdn.download.cirros-cloud.net/0.3.2/cirros-0.3.2-x86_64-disk.img [root@controller-hostname ~]# glance image-create --name=cirros --disk-format=qcow2 --container-format=bare --is-public=true < cirros-0.3.2-x86_64-disk.img
Hinzufügen des CentOS-Images zum Glättungsdienst
[root@controller-hostname ~]# wget http://cloud.centos.org/centos/6/images/CentOS-6-x86_64-GenericCloud-20141129_01.qcow2.xz
Hinweis: xz ist ein Allzweck-Dienstprogramm zur Datenkomprimierung, das eine hohe Komprimierungsrate bietet. Aus diesem Grund ist die Größe der .xz-Datei kleiner und einfach herunterzuladen. Wenn Sie nicht sicher sind, wie Sie .xz-Dateien dekomprimieren, finden Sie hier eine Anleitung, die Ihnen hilft.
Fügen Sie das Bild nach dem Dekomprimieren des .xz-Bildes zum Glance-Dienst hinzu.
[root@controller-hostname ~]# glance image-create --name 'Centos-6' --disk-format qcow2 --container-format bare --is-public=true < CentOS-6-x86_64-GenericCloud-20141129_01.qcow2
Zeigen Sie die Liste der Bilder an, die den Glance-Diensten hinzugefügt wurden…
[root@controller-hostname ~]# glance image-show "cirros" +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 64d7c1cd2b6f60c92c14662941cb7913 | | container_format | bare | | created_at | 2015-02-06T12:47:39 | | deleted | False | | disk_format | qcow2 | | id | a338631b-3bb8-43ba-a700-d4648c040a05 | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | cirros | | owner | e7c679bc36ec4c298cf68ecf6d49c1b3 | | protected | False | | size | 13167616 | | status | active | | updated_at | 2015-02-06T12:47:40 | +------------------+--------------------------------------+
[root@controller-hostname ~]# glance image-show "Centos-6" +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 62ac2565e3527377860361f57639f334 | | container_format | bare | | created_at | 2015-02-13T06:18:52 | | deleted | False | | disk_format | qcow2 | | id | ac7ffb6d-1594-4a4c-94e7-9d8e70a120a8 | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | Centos-6 | | owner | e7c679bc36ec4c298cf68ecf6d49c1b3 | | protected | False | | size | 1151533056 | | status | active | | updated_at | 2015-02-13T06:20:29 | +------------------+--------------------------------------+
Installieren Sie den Nova-Dienst auf dem Controller-Knoten:
Lassen Sie uns nun mit der Installation von Nova auf dem Controller-Knoten fortfahren…
[root@controller-hostname ~]# yum install openstack-nova-api openstack-nova-cert openstack-nova-conductor openstack-nova-console openstack-nova-novncproxy openstack-nova-scheduler python-novaclient
Neue „Nova“-Datenbank erstellen…
[root@controller-hostname ~]# mysql -u root -p mysql> CREATE DATABASE nova; mysql> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'controller-hostname' IDENTIFIED BY 'setpassword'; mysql> GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' IDENTIFIED BY 'setpassword';
Weisen Sie Nova an, die entsprechende Datenbank zu verwenden, und geben Sie die Anmeldeinformationen dafür an…
[root@controller-hostname ~]# openstack-config --set /etc/nova/nova.conf database connection mysql://nova:setpassword@controller-hostname/nova
Nachrichtenbroker (Qpid) mit Nova verbinden…
[root@controller-hostname ~]# openstack-config --set /etc/nova/nova.conf DEFAULT rpc_backend qpid [root@controller-hostname ~]# openstack-config --set /etc/nova/nova.conf DEFAULT qpid_hostname controller-hostname
Tabellen für die Datenbank „nova“ erstellen
[root@controller-hostname ~]# su -s /bin/sh -c "nova-manage db sync" nova
Benutzer für nova in KeyStone erstellen
[root@controller-hostname ~]# keystone user-create --name=nova --pass=setpassword --email=nova@controller-hostname [root@controller-hostname ~]# keystone user-role-add --user=nova --tenant=service --role=admin
Nova-Authentifizierung mit KeyStone konfigurieren
[root@controller-hostname ~]# openstack-config --set /etc/nova/nova.conf DEFAULT auth_strategy keystone [root@controller-hostname ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_uri http://controller-hostname:5000 [root@controller-hostname ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_host controller-hostname [root@controller-hostname ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_protocol http [root@controller-hostname ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_port 35357 [root@controller-hostname ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_user nova [root@controller-hostname ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_tenant_name service [root@controller-hostname ~]# openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_password setpassword
Nova bei KeyStone registrieren
[root@controller-hostname ~]# keystone service-create --name=nova --type=compute --description="OpenStack Compute" [root@controller-hostname ~]# keystone endpoint-create --service-id=$(keystone service-list | awk '/ compute / {print $2}') --publicurl=http://controller-hostname:8774/v2/%\(tenant_id\)s --internalurl=http://controller-hostname:8774/v2/%\(tenant_id\)s --adminurl=http://controller-hostname:8774/v2/%\(tenant_id\)s
Nova-bezogene Dienste starten…
[root@controller-hostname ~]# service openstack-nova-api start [root@controller-hostname ~]# chkconfig openstack-nova-api on [root@controller-hostname ~]# service openstack-nova-cert start [root@controller-hostname ~]# chkconfig openstack-nova-cert on [root@controller-hostname ~]# service openstack-nova-scheduler start [root@controller-hostname ~]# chkconfig openstack-nova-scheduler on [root@controller-hostname ~]# service openstack-nova-novncproxy start [root@controller-hostname ~]# chkconfig openstack-nova-novncproxy on [root@controller-hostname ~]# service openstack-nova-consoleauth start [root@controller-hostname ~]# chkconfig openstack-nova-consoleauth on [root@controller-hostname ~]# service openstack-nova-conductor start [root@controller-hostname ~]# chkconfig openstack-nova-conductor on [root@controller-hostname ~]# service openstack-nova-metadata-api start [root@controller-hostname ~]# chkconfig openstack-nova-metadata-api on
Hinweis: Überprüfen Sie nach dem Start des Dienstes seinen Status und stellen Sie sicher, dass der Dienst wirklich ausgeführt wird. Wenn einer der Dienste nicht gestartet werden konnte, überprüfen Sie die Protokolldateien unter /var/log/nova.
Lesen Sie auch:OpenStack Nova Service Installationsfehler und Lösungen.
Nova-Befehle zum Testen der Konfiguration und Dienste…
Zum Auflisten aller Bilder die im Glance-Dienst gespeichert sind…
[root@controller-hostname ~]# nova image-list +--------------------------------------+---------------+--------+--------------------------------------+ | ID | Name | Status | Server | +--------------------------------------+---------------+--------+--------------------------------------+ | ac7ffb6d-1594-4a4c-94e7-9d8e70a120a8 | Centos-6 | ACTIVE | | | a338631b-3bb8-43ba-a700-d4648c040a05 | cirros | ACTIVE | | | e8c477ae-7c74-497d-9d9b-5fea1035d899 | testvm-snap1 | ACTIVE | aa7c5535-4259-42f0-8d74-5b26f0d731de | +--------------------------------------+---------------+--------+--------------------------------------+
Um alle Dienste aufzulisten…
[root@controller-hostname ~]# nova service-list +------------------+-------------------------+----------+---------+-------+----------------------------+-----------------+ | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason | +------------------+-------------------------+----------+---------+-------+----------------------------+-----------------+ | nova-cert | controller-hostname | internal | enabled | up | 2015-02-16T11:06:09.000000 | - | | nova-scheduler | controller-hostname | internal | enabled | up | 2015-02-16T11:06:07.000000 | - | | nova-consoleauth | controller-hostname | internal | enabled | up | 2015-02-16T11:06:11.000000 | - | | nova-conductor | controller-hostname | internal | enabled | up | 2015-02-16T11:06:12.000000 | - | | nova-console | controller-hostname | internal | enabled | up | 2015-02-16T11:06:12.000000 | - | +------------------+-------------------------+----------+---------+-------+----------------------------+-----------------+
Nova-Networking für Controller-Knoten einrichten
In diesem Zwei-Knoten-Setup werden wir Nova Networking (Legacy) auf Controller- und Compute-Knoten installieren. Das bedeutet, dass Sie sich keine Sorgen um den komplexen Neutron-Service machen müssen.
Konfigurieren Sie Nova für die Verwendung von nova Legacy Networking…
[root@controller-hostname ~]# openstack-config --set /etc/nova/nova.conf DEFAULT network_api_class nova.network.api.API [root@controller-hostname ~]# openstack-config --set /etc/nova/nova.conf DEFAULT security_group_api nova
Nova-Dienste neu starten
[root@controller-hostname ~]# service openstack-nova-api restart [root@controller-hostname ~]# service openstack-nova-scheduler restart [root@controller-hostname ~]# service openstack-nova-conductor restart
Erstellen Sie ein Netzwerk für VMs
Jetzt weiß Nova, dass es Legacy-Netzwerke für die Kommunikation verwenden sollte, aber Sie müssen ein Netzwerk und einen Pool von IP-Adressen erstellen, denen VMs zugewiesen werden sollen. Scrollen Sie einfach nach oben, um das Architekturdiagramm anzuzeigen, in dem Sie die externe IP-Adresse (10.180.14.151) finden, die dem Compute-Knoten zugewiesen ist. Das bedeutet, dass wir ein Subnetz im 10.180.14.0-Netzwerk erstellen müssen, das von VMs verwendet werden kann. Nehmen wir in dieser Anleitung an, dass wir 30 IP-Adressen für die Zuweisung benötigen. So the subnet details goes as below…
------------------------------------------------ TCP/IP NETWORK INFORMATION ------------------------------------------------ IP Entered = ..................: 10.180.14.160 CIDR = ........................: /27 Netmask = .....................: 255.255.255.224 Wildcard Bits = ...............: 0.0.0.31 ------------------------------------------------ Network Address = .............: 10.180.14.160 Broadcast Address = ...........: 10.180.14.191 Usable IP Addresses = .........: 30 First Usable IP Address = .....: 10.180.14.161 Last Usable IP Address = ......: 10.180.14.190
For the subnet ‘10.180.14.160/27’, the first usable IP address is 10.180.14.161 and the last usable IP address is 10.180.14.190.
The below command will create a network called ‘private’
[root@controller-hostname ~]# nova network-create private --bridge br100 --multi-host T --fixed-range-v4 10.180.14.160/27 [root@controller-hostname ~]# nova net-list +--------------------------------------+---------+------------------+ | ID | Label | CIDR | +--------------------------------------+---------+------------------+ | 60dfd46a-4649-4758-8b8d-88cc562b9b39 | private | 10.180.14.160/27 | +--------------------------------------+---------+------------------+
Add a security group to the created network to allow SSH connections
[root@controller-hostname ~]# 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 | | +-------------+-----------+---------+-----------+--------------+
Install Dashboard (Horizon) on Controller node
Now its time to install Horizon service on controller node – provides a portal to manage instances, services, network etc…
[root@controller-hostname ~]# yum install memcached python-memcached mod_wsgi openstack-dashboard
Change the values of CACHES[‘default’][‘LOCATION’] as below
# vi /etc/openstack-dashboard/local_settings CACHES = { 'default': { 'BACKEND' : 'django.core.cache.backends.memcached.MemcachedCache', 'LOCATION' : '127.0.0.1:11211' } }
The above changes should match the address and port specified in /etc/sysconfig/memcached .
Also modify ‘ALLOWED_HOSTS ‘ attribute to accept connection from your desktop – as that will allow you to access the dashboard via browser.
You have to make sure SELINUX allows connection to the web server
[root@controller-hostname ~]# setsebool -P httpd_can_network_connect on
Start web server and memcached
[root@controller-hostname ~]# service memcached start [root@controller-hostname ~]# service httpd start [root@controller-hostname ~]# chkconfig memcached on [root@controller-hostname ~]# chkconfig httpd on
Try accessing the dashboard service – http://controller-hostname/dashboard
Install Nova on Compute node
Finally, we are done with our installation on Controller node and we’ll now move on to install Nova on Compute node.
Install nova compute service on Compute node..
[root@compute-hostname ]# yum install openstack-nova-compute
Connect to nova database on controller node…
[root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf database connection mysql://nova:setpassword@controller-hostname/nova
Setup authentication…
[root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT auth_strategy keystone [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_uri http://controller-hostname:5000 [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_host controller-hostname [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_protocol http [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf keystone_authtoken auth_port 35357 [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_user nova [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_tenant_name service [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf keystone_authtoken admin_password setpassword
Configure Nova to use Qpid message broker for communication
[root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT rpc_backend qpid [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT qpid_hostname controller-hostname
Compute Node should know where the Glance is running, so we need to configure that as well.
[root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT glance_host controller-hostname
Start messagebus, libvirtd and nova-compute services
[root@compute-hostname ]# service libvirtd start [root@compute-hostname ]# chkconfig libvirtd on [root@compute-hostname ]# chkconfig messagebus on [root@compute-hostname ]# service messagebus start [root@compute-hostname ]# service openstack-nova-compute start [root@compute-hostname ]# chkconfig openstack-nova-compute on
Install Nova-Networking for Computer node
[root@compute-hostname ]# yum install openstack-nova-network openstack-nova-api
Configure network api, security group, firewall, network size, dhcp etc..
[root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT network_api_class nova.network.api.API [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT security_group_api nova [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT network_manager nova.network.manager.FlatDHCPManager [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT firewall_driver nova.virt.libvirt.firewall.IptablesFirewallDriver [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT network_size 254 [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT allow_same_net_traffic False [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT multi_host True [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT send_arp_for_ha True [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT share_dhcp_address True [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT force_dhcp_release True
Configure network bridge and interfaces
If you remember we created a network bridge ‘br100 ‘ in controller node. For this tutorial, the external IP address of the compute node is 10.180.14.151 (configured on eth1 network interface) and the subnet is ‘10.180.14.160/27 ‘
[root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT flat_network_bridge br100 [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT flat_interface eth1 [root@compute-hostname ]# openstack-config --set /etc/nova/nova.conf DEFAULT public_interface eth1
Hinweis: Remember to change the network interface (eth1) to the corresponding interface of your compute node.
Start the services…
[root@compute-hostname ]# service openstack-nova-api start [root@compute-hostname ]# service openstack-nova-network start [root@compute-hostname ]# service openstack-nova-metadata-api start [root@compute-hostname ]# chkconfig openstack-nova-api on [root@compute-hostname ]# chkconfig openstack-nova-network on [root@compute-hostname ]# chkconfig openstack-nova-api on
Well, we are done with installations on both the Controller and Compute node. Let us now trying booting VM, but before that you should know the below commands.
List of networks created…
[root@controller-hostname ~]# nova net-list +--------------------------------------+---------+------------------+ | ID | Label | CIDR | +--------------------------------------+---------+------------------+ | 60dfd46a-4649-4758-8b8d-88cc562b9b39 | private | 10.180.14.160/27 | +--------------------------------------+---------+------------------+
List of images stored in Glance…
[root@controller-hostname ~]# nova image-list +--------------------------------------+---------------+--------+--------------------------------------+ | ID | Name | Status | Server | +--------------------------------------+---------------+--------+--------------------------------------+ | ac7ffb6d-1594-4a4c-94e7-9d8e70a120a8 | Centos-6 | ACTIVE | | | a338631b-3bb8-43ba-a700-d4648c040a05 | cirros | ACTIVE | | | e8c477ae-7c74-497d-9d9b-5fea1035d899 | henryvm-snap1 | ACTIVE | aa7c5535-4259-42f0-8d74-5b26f0d731de | +--------------------------------------+---------------+--------+--------------------------------------+
List of flavors available…
[root@controller-hostname ~]# 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 | +----+-----------+-----------+------+-----------+------+-------+-------------+-----------+
List of security groups created…
[root@controller-hostname ~]# nova secgroup-list +----+---------+-------------+ | Id | Name | Description | +----+---------+-------------+ | 1 | default | default | +----+---------+-------------+
You may want to generate SSH keys to allow users to login to the newly created instance.
[root@controller-hostname ~]# ssh-keygen
Add the SSH public key to the nova keypair list..
[root@controller-hostname ~]# nova keypair-add --pub-key ~/.ssh/id_rsa.pub test-key
View the list of key pairs created…
[root@controller-hostname ~]# nova keypair-list +----------+-------------------------------------------------+ | Name | Fingerprint | +----------+-------------------------------------------------+ | test-key | b0:e1:ff:a5:1b:b0:ff:14:d5:46:13:bc:b6:ba:97:9b | +----------+-------------------------------------------------+
Create an Instance
Based on the output from above commands, you can create a new instance as below:
[root@controller-hostname ~]# nova boot --flavor m1.small --image Centos-6 --nic net-id=60dfd46a-4649-4758-8b8d-88cc562b9b39 --security-group default --key-name test-key myfirstvm +--------------------------------------+-------------------------------------------------+ | Property | Value | +--------------------------------------+-------------------------------------------------+ | OS-DCF:diskConfig | MANUAL | | OS-EXT-AZ:availability_zone | nova | | OS-EXT-SRV-ATTR:host | - | | OS-EXT-SRV-ATTR:hypervisor_hostname | - | | OS-EXT-SRV-ATTR:instance_name | instance-00000016 | | OS-EXT-STS:power_state | 0 | | OS-EXT-STS:task_state | - | | OS-EXT-STS:vm_state | building | | OS-SRV-USG:launched_at | - | | OS-SRV-USG:terminated_at | - | | accessIPv4 | | | accessIPv6 | | | adminPass | hEMdKAnLs6XX | | config_drive | | | created | 2015-02-18T08:56:32Z | | flavor | m1.small (2) | | hostId | | | id | a9735dd7-c601-4209-a86a-0575711239d1 | | image | Centos-6 (ac7ffb6d-1594-4a4c-94e7-9d8e70a120a8) | | key_name | test-key | | metadata | {} | | name | myfirstvm | | os-extended-volumes:volumes_attached | [] | | progress | 0 | | security_groups | default | | status | BUILD | | tenant_id | e7c679bc36ec4c298cf68ecf6d49c1b3 | | updated | 2015-02-18T08:56:32Z | | user_id | 8607e0ccc8ee407daf50c1985616b153 | +--------------------------------------+-------------------------------------------------+
Check if the state of the VM is “ACTIVE” using the below command…
[root@controller-hostname ~]# nova list +--------------------------------------+------------------+--------+------------+-------------+-----------------------+ | ID | Name | Status | Task State | Power State | Networks | +--------------------------------------+------------------+--------+------------+-------------+-----------------------+ | 8aaa3873-09c5-48f0-9d1e-cb4401e44583 | Cluster-headnode | ACTIVE | - | Running | private=10.180.14.162 | | a9735dd7-c601-4209-a86a-0575711239d1 | myfirstvm | ACTIVE | - | Running | private=10.180.14.163 | +--------------------------------------+------------------+--------+------------+-------------+-----------------------+
The new VM called “myfirstvm ” is running and the allocated IP address is 10.180.14.163 .
Login to an instance
[root@controller-hostname ~]# cd .ssh/ [root@controller-hostname .ssh]# ssh -i id_rsa [email protected] Last login: Wed Feb 18 09:01:07 2015 from 10.180.10.132 [centos@myfirstvm ~]$ hostname myfirstvm
Hinweis: Since we installed “Horizon” service on controller node, you should be able to create an instance via OpenStack dashboard. That’s super easy!
What is the password for Cirros?
In case, if you have used Cirros image to create an instance, then you must login with username as ‘cirros’ and password as ‘cubswin:)’ (of course, without single quotes).
To know information about the running VM, you can just issue the below command.
[root@controller-hostname ~]# nova show myfirstvm +--------------------------------------+----------------------------------------------------------+ | Property | Value | +--------------------------------------+----------------------------------------------------------+ | OS-DCF:diskConfig | MANUAL | | OS-EXT-AZ:availability_zone | nova | | OS-EXT-SRV-ATTR:host | gcompute.blr.cdac.in | | OS-EXT-SRV-ATTR:hypervisor_hostname | gcompute.blr.cdac.in | | OS-EXT-SRV-ATTR:instance_name | instance-00000016 | | OS-EXT-STS:power_state | 1 | | OS-EXT-STS:task_state | - | | OS-EXT-STS:vm_state | active | | OS-SRV-USG:launched_at | 2015-02-18T08:56:54.000000 | | OS-SRV-USG:terminated_at | - | | accessIPv4 | | | accessIPv6 | | | config_drive | | | created | 2015-02-18T08:56:32Z | | flavor | m1.small (2) | | hostId | bd672087b1933d00d10e9d4f85cbac0326ebf3de73a0ce093c0d1838 | | id | a9735dd7-c601-4209-a86a-0575711239d1 | | image | Centos-6 (ac7ffb6d-1594-4a4c-94e7-9d8e70a120a8) | | key_name | test-key | | metadata | {} | | name | myfirstvm | | os-extended-volumes:volumes_attached | [] | | private network | 10.180.14.163 | | progress | 0 | | security_groups | default | | status | ACTIVE | | tenant_id | e7c679bc36ec4c298cf68ecf6d49c1b3 | | updated | 2015-02-18T08:56:41Z | | user_id | 8607e0ccc8ee407daf50c1985616b153 | +--------------------------------------+----------------------------------------------------------+
Stop an Instance
If you want to stop a running instance, here’s how you can do that.
[root@controller-hostname ~]# nova stop myfirstvm
If you want to delete an instance completely, then here’s the command.
[root@controller-hostname ~]# nova delete myfirstvm
How to add another compute node to the OpenStack environment?
It’s simple! Just follow the same steps that we used for Compute-hostname node.
Do you like this tutorial? Share it with OpenStack community by clicking the share icons at the top.