GNU/Linux >> Linux Esercitazione >  >> Cent OS

Una semplice guida per installare OpenStack Icehouse su CentOS - Architettura a due nodi

La parola "OpenStack" è piuttosto popolare in questi giorni. Potresti aver sentito questa parola, anche se non lavori nell'area del Cloud computing. Ho lavorato nel dominio del Grid computing negli ultimi 10 anni e non ho mai capito il clamore dietro OpenStack. Ma questa parola d'ordine continuava a battere le mie orecchie ovunque io andassi:sul serio, nel mio ufficio, conferenze e siti Web popolari che continuavano a promuovere OpenStack. Alla fine, sono stato spinto (Sì, con forza dal mio capo) nel mondo di OpenStack e queste grandi domande mi hanno messo a dura prova:cos'è Openstack, come viene implementato e come funziona? Bene, l'unico modo per capire OpenStack è iniziare con un'installazione.

A prima vista, iniziare con OpenStack sembrava facile, ma non lo è. Sì, il sito Web ufficiale di OpenStack ha una buona documentazione, ma il vero problema che ho dovuto affrontare è stato la terminologia utilizzata - Horizon, Glance, Keystone, Nova, Neutron, Swift, Heat, Cinder, Ceilometer... Uff, perché diavolo sono chiamato così? E poi, c'erano molti altri termini collegati all'installazione:RDO, Packstack, Devstack, architetture diverse (un nodo, due nodi e multinodo), reti legacy ecc... Seriamente, ho dovuto tornare su Google per capire tutti questi (e questo ragazzo ha fatto un ottimo lavoro). Bene, se mi chiedi di scrivere sulla mia esperienza con OpenStack, questo articolo si ridurrà a 20 pagine. Quindi mi fermo qui e vado all'argomento.

Sommario

  • Introduzione a OpenStack
  • Architettura del banco di prova
  • Installa e configura NTP sia su Controller che su Compute Node
  • Installa e configura MySQL sia su Controller che su Compute Node
  • Installa e configura Apache Qpid sia su Controller che su Compute Node
  • Installa i pacchetti base di OpenStack Icehouse sul nodo Controller e Compute
  • Installa KeyStone sul nodo controller
  • Installa Glance su Controller Node
  • Installa Nova su Controller Node
  • Installa Nova-Networking sul nodo Controller
  • Installa dashboard sul nodo Controller
  • Installa Nova su Compute Node
  • Installa Nova-Networking su Compute Node
  • Crea un'istanza
  • Accedi all'istanza

Cos'è OpenStack?

OpenStack è una piattaforma di cloud computing open source, che fornisce Infrastructure as a Service (IaaS). Se sei un esperto di Grid computing, OpenStack è qualcosa di simile al popolare middleware Grid come Globus Toolkit, Glite, Oracle Grid Engine, Unicore ecc... OpenStack è fondamentalmente un middleware, che ti consente di gestire le risorse di cloud computing in modo più efficiente e ovviamente , in modo efficace.

Servizi OpenStack

  • Orizzonte :un servizio dashboard che fornisce un portale web per interagire e gestire i servizi, le istanze virtuali, gli utenti e la rete sottostanti.
  • Nova :un servizio di elaborazione che aiuta nella gestione delle istanze di elaborazione, che include la generazione, la pianificazione, l'avvio e la chiusura di una macchina virtuale.
  • Pietra di volta :un servizio di identità che fornisce autenticazione e autorizzazione.
  • Neutrone :un servizio di rete che ti consente di creare e gestire la rete.
  • Sguardo :un servizio di immagini che aiuta a archiviare e recuperare immagini di macchine virtuali.
  • Banca dati servizio:fornisce database come servizio.
  • Veloce e Cinder :fornisce l'archiviazione come servizio.
  • Telemetria :un servizio che ti aiuta a gestire la fatturazione e il benchmarking.
  • Ci sono molti altri servizi... leggi di più su openstack.org.

Architettura

Se sei un principiante, il modo ideale è iniziare con un'architettura a due nodi: un nodo chiamato "Controller" e l'altro come "Compute". In questo tutorial, installeremo la versione OpenStack Icehouse sul sistema operativo CentOS 6.6. I servizi da installare sul nodo controller sono Keystone, Glance, Nova, Networking (legacy nova-networking), Horizon e il nodo di calcolo avrà Nova e Networking (legacy nova-networking).

Nota: Principiante di OpenStack? Si consiglia di iniziare con la rete legacy Nova. Comprendere e configurare "Neutron" è una grande richiesta in questa fase. Tuttavia, dovresti considerare di migrare dalla rete legacy a Neutron in una fase successiva.

Di seguito è riportato il diagramma che raffigura il mio banco di prova. Tutti i miei passaggi di installazione si basano sull'architettura seguente.

Nota: Poiché utilizzeremo la rete Legacy Nova, abbiamo bisogno solo di un'interfaccia nel nodo controller per scopi di gestione e due interfacce nel nodo di calcolo (una per la gestione che ricade nella stessa rete del nodo controller e l'altra interfaccia è per l'esterno, che verrà utilizzato per le comunicazioni VM).

Bene, siamo a posto per procedere con i passaggi di installazione.

Come installare e configurare OpenStack Icehouse su CentOS?

Userò,

  • 'nome host controller ' come nome host del nodo Controller e "compute-hostname ” come nome host del nodo Compute.
  • "10.180.10.132" (IP di gestione) per il nodo controller e "10.180.10.134" (IP di gestione) per il nodo di calcolo. L'IP esterno del nodo di calcolo sarà "10.180.14.151"

Nota: Ricordati di sostituirli con gli FQDN o gli indirizzi IP corrispondenti.

  • Durante l'installazione, ovunque trovi "setpassword ', sostituirla con la password di servizio corrispondente.
  • Utilizzerò "YUM" per la maggior parte dell'installazione. Quindi assicurati che le macchine siano connesse a Internet. Nel caso, se hai problemi con la configurazione di yum, le guide seguenti saranno di grande aiuto.
    • Come configurare il repository Yum su CentOS
    • Yum comandi che devi conoscere.
  • L'output dei pochi comandi è stato troncato per evitare confusione e ridurre la lunghezza di questo tutorial.

L'installazione di qualsiasi componente (o servizio) in OpenStack prevede i passaggi seguenti:



Installa e configura NTP sia sul controller che sul nodo di calcolo

Puoi passare rapidamente a scoprire come installare e configurare Network Time Protocol sul controller e sui nodi di calcolo.

NTP configurato e servizio ntpd avviato? Poi torniamo a questo articolo...

Aggiorna il sistema operativo su entrambi i nodi Controller e Compute

Si consiglia sempre di aggiornare il sistema operativo prima di installare qualsiasi componente. Risolverà molti mal di testa dalle dipendenze dei pacchetti.

[root@controller-hostname ]# yum update
[root@compute-hostname ]# yum update


Installa il database MySQL sia sul controller che sul nodo di calcolo

Nota: MySQL è ora chiamato "Mariadb".

[root@controller-hostname ]# yum install mysql mysql-server MySQL-python
[root@compute-hostname ]# yum install mysql mysql-server MySQL-python

Dovrai guardare "/etc/my.cnf ' per garantire che il servizio MySQL si leghi all'indirizzo IP di gestione sia del controller che dei nodi di calcolo.

Nel nodo Controller :

[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

Su nodo di calcolo :

[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

Avvia il server MySQL:

[root@controller-hostname ~]# service mysqld start
[root@compute-hostname ~]# service mysqld start

Imposta MySQL...

[root@controller-hostname ~]# mysql_install_db
[root@compute-hostname ~]# mysql_install_db

Si consiglia sempre di eseguire "mysql_secure_installation ' dopo aver installato MySQL.

[root@controller-hostname ~]# mysql_secure_installation
[root@compute-hostname ~]# mysql_secure_installation

Se non sei sicuro di cosa faccia mysql_secure_installation, ecco una guida rapida che lo spiega in dettaglio.

Installa i pacchetti Base OpenStack Icehouse sia sul controller che sul nodo Compute

Imposta il repository yum e installa i pacchetti Icehouse di base. Questo passaggio deve essere eseguito sia sul controller che sui nodi di calcolo.

Nel nodo controller:

[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

Nel nodo di calcolo:

[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


Installa il servizio Message Broker sul nodo Controller

I servizi OpenStack necessitano di un broker di messaggi per la sua comunicazione. Attualmente OpenStack supporta:Rabbit-mq e Apache Qpid. In questo tutorial installeremo Qpid-server.

Apache Qpid consente ai servizi di inviare e ricevere messaggi tramite AMQP (Advanced Message Queuing Protocol).

[root@controller-hostname ~]# yum install qpid-cpp-server

Configura qpid-cpp-server per funzionare senza la necessità di autenticazione (questo faciliterà il nostro processo di installazione. Ma dovresti abilitare l'autenticazione per motivi di sicurezza)

[root@controller-hostname ~]# echo "auth=no">/etc/qpid/qpidd.conf

Avvia il broker di messaggi...

[root@controller-hostname ~]# service qpidd start

Installazione e configurazione di Keystone (Identity Service) sul nodo Controller

Come ho detto in precedenza, il servizio Keystone svolge un ruolo importante in OpenStack, fornendo autenticazione e autorizzazione. Significa anche che ogni servizio di OpenStack (incluso il servizio di identità) deve essere registrato con KeyStone.

Installa i pacchetti keystone...

[root@controller-hostname ~]# yum install openstack-keystone python-keystoneclient

Crea un database per keystone , in modo che il servizio possa memorizzare il suo stato e i suoi dati...

[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';

Nota: Ricorda di sostituire "setpassword" con la tua password per keystone.

Crea tabelle per il database keystone...

[root@controller-hostname ~]# su -s /bin/sh -c "keystone-manage db_sync" keystone

Ora, di' a Keystone che questo è ciò che dovresti usare per creare una connessione al database

[root@controller-hostname ~]# openstack-config --set /etc/keystone/keystone.conf database connection mysql://keystone:setpassword@controller-hostname/keystone

Nota: Ricorda di sostituire "setpassword" con la password adatta di "keystone"@mysql

Crea token di autenticazione per autenticare altri servizi con keystone. Per farlo, useremo openssl per generare un valore HEX casuale e memorizzarlo in una variabile chiamata 'ADMIN_TOKEN '

[root@controller-hostname ~]# ADMIN_TOKEN=$(openssl rand -hex 10)
[root@controller-hostname ~]# echo $ADMIN_TOKEN
e9393f7ac1886f0c1a20

Nota: Crea una copia del token generato, poiché ne avrai bisogno in un secondo momento (non richiesto, se non intendi terminare la sessione del terminale a metà)

Configura keystone per utilizzare il token di autenticazione generato nel passaggio precedente...

[root@controller-hostname ~]# openstack-config --set /etc/keystone/keystone.conf DEFAULT admin_token $ADMIN_TOKEN

Configura keystone per fornire token di autenticazione basati su PKI..

[root@controller-hostname ~]# keystone-manage pki_setup --keystone-user keystone --keystone-group keystone

Imposta la proprietà e l'autorizzazione per l'utente "keystone"...

[root@controller-hostname ~]# chown -R keystone:keystone /etc/keystone/ssl
[root@controller-hostname ~]# chmod -R o-rwx /etc/keystone/ssl

Tutto fatto per Keystone, avviamo il servizio...

[root@controller-hostname ~]# service openstack-keystone start

Assicurati che il servizio sia realmente in esecuzione controllandone lo stato

[root@controller-hostname ~]# service openstack-keystone status
keystone (pid 10245) is running...

Nel caso, se il servizio è morto dopo l'avvio, dovresti risolvere il problema a questo punto da solo.

Imposta il servizio per l'avvio automatico durante l'avvio del sistema...

[root@controller-hostname ~]# chkconfig openstack-keystone on

Cancella automaticamente i token keystone scaduti...

Potrebbero esserci molti token scaduti nella chiave di volta durante il suo funzionamento, aumentando così le dimensioni del database della chiave di volta. È una buona idea cancellarli a intervalli regolari. Per farlo, imposteremo i lavori cron come di seguito:

[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

Crea utenti, tenant e ruoli per keystone

Prima di eseguire i comandi keystone, è necessario impostare determinate variabili di ambiente. Per farlo, crea un file chiamato 'admin-openrc.sh ' e imposta le variabili di ambiente come di seguito:

[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

Creiamo un utente...

[root@controller-hostname ~]# keystone user-create --name=admin --pass=setpassword --email=keystone@controller-hostname

Crea un ruolo...

[root@controller-hostname ~]# keystone role-create --name=admin

Crea un tenant...

[root@controller-hostname ~]# keystone tenant-create --name=admin --description="Admin Tenant"

Dovremo collegare l'utente con il ruolo e il tenant creati nei passaggi precedenti...

[root@controller-hostname ~]# keystone user-role-add --user=admin --role=admin --tenant=admin

Registra la chiave di volta (servizio di identità) al servizio KeyStone

[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

Ecco fatto, la configurazione di KeyStone è completata... Nel caso, se dovessi riscontrare problemi durante l'installazione e la configurazione di keystone, ecco una soluzione per vari errori di keystone:Errori e soluzioni comuni del servizio keystone .

Installa Glance (Image Service) sul nodo Controller

Il servizio immagine verrà installato sul nodo Controller per ospitare tutte le immagini da utilizzare per avviare le VM sul nodo Compute.

[root@controller-hostname ~]# yum install openstack-glance python-glanceclient

Imposta 'sguardo' del database...

[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';

Nota: Ricordati di cambiare "imposta password"

Crea tabelle per il database "sguardo"...

[root@controller-hostname ~]# su -s /bin/sh -c "glance-manage db_sync" glance

Configura il servizio di colpo d'occhio per leggere le credenziali del database...

[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

Crea utente Glance in KeyStone...

[root@controller-hostname ~]# keystone user-create --name=glance --pass=setpassword --email=glance@controller-hostname

Aggiungi l'utente di colpo d'occhio al ruolo "amministratore"

[root@controller-hostname ~]# keystone user-role-add --user=glance --tenant=service --role=admin

Configura l'autenticazione per Glance...

[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

Registra il servizio Glance su KeyStone...

[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

Avvia i servizi di colpo d'occhio...

[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

Nota: Se uno qualsiasi dei servizi non si avvia, controlla i file di registro in /var/log/glance . Leggi anche questa guida – Errori e soluzioni di installazione del servizio di immagini OpenStack Glance.

Servizio di test Glance...

Ora scaricheremo l'immagine Cirros per testare il servizio di colpo d'occhio. Cirros è un minuscolo sistema operativo Linux che ha una dimensione di pochi MB, quindi è abbastanza facile scaricarlo e aggiungerlo al servizio Glance.

[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

Aggiungi l'immagine CentOS al servizio di colpo d'occhio

[root@controller-hostname ~]# wget http://cloud.centos.org/centos/6/images/CentOS-6-x86_64-GenericCloud-20141129_01.qcow2.xz

Nota: xz è un'utilità di compressione dati generica che fornisce un rapporto di compressione elevato. Questo è il motivo, la dimensione del file .xz è inferiore e facile da scaricare. Se non sei sicuro di come decomprimere i file .xz, ecco un tutorial per aiutarti.

Dopo aver decompresso l'immagine .xz, aggiungi l'immagine al servizio Glance.

[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

Visualizza l'elenco delle immagini aggiunte ai servizi Glance...

[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 |
+------------------+--------------------------------------+

Installa Nova Service sul nodo Controller:

Passiamo ora all'installazione di Nova sul nodo Controller...

[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

Crea database 'nova'...

[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';

Di' a Nova di utilizzare il database corrispondente e di fornire le credenziali per esso...

[root@controller-hostname ~]# openstack-config --set /etc/nova/nova.conf database connection mysql://nova:setpassword@controller-hostname/nova

Collega il broker di messaggi (Qpid) a Nova...

[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

Crea tabelle per il database "nova"

[root@controller-hostname ~]# su -s /bin/sh -c "nova-manage db sync" nova

Crea utente per nova in KeyStone

[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

Configura l'autenticazione nova con KeyStone

[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

Registra nova con KeyStone

[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

Avvia i servizi relativi a Nova...

[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

Nota: Dopo aver avviato il servizio, controlla il suo stato e assicurati che il servizio sia realmente in esecuzione. Se uno qualsiasi dei servizi non si avvia, controlla i file di registro in /var/log/nova.

Leggi anche:Errori e soluzioni di installazione del servizio OpenStack Nova.

Comandi Nova per testare la configurazione e i servizi...

Per elencare tutte le immagini che sono memorizzati nel servizio 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 | testvm-snap1 | ACTIVE | aa7c5535-4259-42f0-8d74-5b26f0d731de |
+--------------------------------------+---------------+--------+--------------------------------------+

Per elencare tutti i servizi...

[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 | - |
+------------------+-------------------------+----------+---------+-------+----------------------------+-----------------+

Imposta Nova-Networking per il nodo Controller

In questa configurazione a due nodi, installeremo la rete Nova (Legacy) sui nodi Controller e Compute. Significa che non devi preoccuparti del complesso servizio Neutron.

Configura Nova per utilizzare la rete legacy nova...

[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

Riavvia i servizi Nova

[root@controller-hostname ~]# service openstack-nova-api restart
[root@controller-hostname ~]# service openstack-nova-scheduler restart
[root@controller-hostname ~]# service  openstack-nova-conductor restart

Crea una rete per le VM

Ora Nova sa che dovrebbe utilizzare la rete legacy per la comunicazione, ma devi creare una rete e un pool di indirizzi IP a cui dovrebbero essere assegnate le VM. Scorri verso l'alto per vedere il diagramma dell'architettura in cui troverai l'IP esterno (10.180.14.151) assegnato al nodo Compute. Significa che dobbiamo creare una sottorete nella rete 10.180.14.0 per l'utilizzo da parte delle macchine virtuali. In this tutorial, let us assume that we need 30 IP addresses for allocation. 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

Nota: 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

Nota: 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.

E il Bonus è qui...

    Scarica l'ebook gratuito sull'installazione di OpenStack Icehouse! Scarica il cheat sheet dell'interfaccia a riga di comando di OpenStack! – Comandi più utilizzati

Cent OS
  1. Guida all'installazione di CentOS 6 Net | Installa CentOS 6 tramite NetInstall

  2. Installa Grafana su CentOS 8 - Guida passo passo?

  3. Installa FreeIPA su CentOS 8 - Guida passo passo?

  4. Installa ClamAV su CentOS 8 - Guida passo passo?

  5. Installare Gparted su CentOS 8 - Una guida passo passo?

Come installare Node.js e npm su CentOS 8

Come installare OpenStack a nodo singolo su CentOS 7

Come installare Node.js su CentOS 8

Come installare Node.js su CentOS 7

Come installare fatture semplici su CentOS 7

Come installare Node.js su CentOS Stream 9