Ambiente » History » Version 46

« Previous - Version 46/87 (diff) - Next » - Current version
Beraldo Leal, 07 Jun 2012 15:02


Ambiente de Desenvolvimento

Lista de Servidores

  • educloud00 - 200.145.46.166
  • educloud01 - 200.145.46.167
  • educloud02 - 200.145.46.168
  • educloud03 - 200.145.46.169
  • educloud04 - 200.145.46.170
  • educloud05 - 200.145.46.174
  • educloud06 - 200.145.46.175
  • educloud07 - 200.145.46.173

Desabilitados

  • educloud05 - 200.145.46.171
  • educloud06 - 200.145.46.172

Installing OpenStack Identity Service - Keystone

O Keystone é um projeto que provê serviços de "Identidade", "Token", "Catalog" and "Policy" para os componentes do OpenStack. O pacote keystone foi instalado no servidor educloud01.

Este software é feito em python, e por sua vez instala a dependencia keystone-python, uma biblioteca em python para uso do próprio keystone.

Os arquivos de configuração do keystone ficam em /etc/keystone e hoje ele está utilizando como um backend para armazenar os usuários uma base sqlite3, mas ele também permite que seja utilizado uma base LDAP.

Além do daemon (servidor) foi instalado o cliente (também feito em python) python-keystoneclient.

Instalando e configurando o keystone

# apt-get install keystone

Delete the keystone.db file created in the /var/lib/keystone directory.

# rm /var/lib/keystone/keystone.db

Install mysql:

# apt-get install python-mysqldb mysql-server

Use sed to edit /etc/mysql/my.cnf to change bind-address from localhost
(127.0.0.1) to any (0.0.0.0) and restart the mysql service, as root:

# sed -i 's/127.0.0.1/0.0.0.0/g' /etc/mysql/my.cnf
# service mysql restart

To configure the MySQL database, create the keystone database.

# mysql -u root -p
mysql> CREATE DATABASE keystone;
mysql> GRANT ALL ON keystone.* TO 'keystone'@'%' IDENTIFIED BY 'keystonepass';
mysql> FLUSH PRIVILEGES;
mysql> quit;

Edit keystone.conf to use mysql:

[sql]
connection = mysql://keystone:keystonepass@192.168.69.1/keystone

Change in keystone.conf the ADMIN_TOKEN:

admin_token = 012345SECRET99TOKEN012345

Restarte o keystone e inicialize o banco:

# service keystone restart
# keystone-manage db_sync

Configuring Services to work with Keystone

Crie o arquivo /root/openstackrc, com o seguinte conteudo:

export SERVICE_ENDPOINT=http://192.168.69.1:35357/v2.0/
export SERVICE_TOKEN=012345SECRET99TOKEN012345

Estas variaveis de ambiente sao uteis para evitar ficar passando as opcoes --token e --endpoint para os utilitarios de linha de comando.

Carrege o arquivo:

# source /root/openstackrc

Crie os tenants openstackDemo e service:

# keystone tenant-create --name openstackDemo --description "Default Tenant"  --enabled true
# keystone tenant-create --name service --description "Service Tenant"  --enabled true

Crie o user admin, substitua o tenant_id pelo tentant_id do openstackDemo, criado no item anterior:

# keystone user-create --tenant_id 9c401c9d2b9d41bcabda6919d4aec63a --name admin --pass adminpass --enabled true

Crie os roles admin e user:

# keystone role-create --name admin
# keystone role-create --name user

Adicione o user admin ao role admin, fazendo as devidas substituicoes:

# keystone user-role-add --user [admin_user_id] --tenant_id [openstackDemo_tenant_id] --role [admin_role]

Crie um usuario para cada servico, e substitua o tenant_id pelo id do tenant service:

# keystone user-create --tenant_id 92920816c7704a8a95c916d34dc7a05c --name glance --pass glancepass --enabled true
# keystone user-create --tenant_id 92920816c7704a8a95c916d34dc7a05c --name nova --pass novapass --enabled true
# keystone user-create --tenant_id 92920816c7704a8a95c916d34dc7a05c --name swift --pass swiftpass --enabled true

Adicione os users acima ao role admin, fazendo as devidas substituicoes:

# keystone user-role-add --user [glance_user_id] --tenant_id [service_tenant_id] --role [admin_role]
# keystone user-role-add --user [nova_user_id] --tenant_id [service_tenant_id] --role [admin_role]
# keystone user-role-add --user [swift_user_id] --tenant_id [service_tenant_id] --role [admin_role]

Definindo os servicos:

Ate agora, apenas criamos: tenants, users e roles. O Keystone tambem gerencia os servicos e seus endpoins. Desta forma os componentes do openstack consulta o keystone onde determinado servico encontra-se.

Crie os servicos:

# keystone service-create --name keystone --type identity --description "Keystone Identity Service" 
# keystone service-create --name nova --type compute --description "Nova Compute Service" 
# keystone service-create --name volume --type volume --description "Nova Volume Service" 
# keystone service-create --name glance --type image --description "Glance Image Service" 
# keystone service-create --name swift --type object-store --description "Object Storage Service" 

Crie os endpoints para os respectivos servicos:

# keystone endpoint-create --region RegionOne --service_id [keystone_service_id] --publicurl http://192.168.69.1:5000/v2.0 --internalurl http://192.168.69.1:5000/v2.0 --adminurl http://192.168.69.1:35357/v2.0
# keystone endpoint-create --region RegionOne --service_id [compute_service_id] --publicurl 'http://192.168.69.1:8774/v2/%(tenant_id)s' --internalurl 'http://192.168.69.1:8774/v2/%(tenant_id)s' --adminurl 'http://192.168.69.1:8774/v2/%(tenant_id)s'
# keystone endpoint-create --region RegionOne --service_id [volume_service_id] --publicurl 'http://192.168.69.1:8776/v1/%(tenant_id)s' --internalurl 'http://192.168.69.1:8776/v1/%(tenant_id)s' --adminurl 'http://192.168.69.1:8776/v1/%(tenant_id)s'
# keystone endpoint-create --region RegionOne --service_id [glance_service_id] --publicurl http://192.168.69.1:9292/v1 --internalurl http://192.168.69.1:9292/v1 --adminurl http://192.168.69.1:9292/v1
# keystone endpoint-create --region RegionOne --service_id [swift_service_id] --publicurl 'http://192.168.69.1:8888/v1/AUTH_%(tenant_id)s' --adminurl 'http://192.168.69.1:8888/' --internalurl 'http://192.168.69.1:8888/v1/AUTH_%(tenant_id)s'

Verificando a instalacao:

# sudo apt-get install curl openssl

Faca uma requisicao REST para a API do keystone usando o curl:

# curl -d '{"auth": {"tenantName": "openstackDemo", "passwordCredentials": {"username": "admin", "password": "adminpass"}}}' -H "Content-type: application/json" http://192.168.69.1:35357/v2.0/tokens  | python -mjson.tool

O retorno deve conter todos os servicos, endpoins e um token que expira em 24 horas:

{
    "access": {
        "serviceCatalog": [
            {
                "endpoints": [
                    {
                        "adminURL": "http://192.168.69.1:8776/v1/9c401c9d2b9d41bcabda6919d4aec63a", 
                        "internalURL": "http://192.168.69.1:8776/v1/9c401c9d2b9d41bcabda6919d4aec63a", 
                        "publicURL": "http://192.168.69.1:8776/v1/9c401c9d2b9d41bcabda6919d4aec63a", 
                        "region": "RegionOne" 
                    }
                ], 
                "endpoints_links": [], 
                "name": "volume", 
                "type": "volume" 
            }, 
            {
                "endpoints": [
                    {
                        "adminURL": "http://192.168.69.1:9292/v1", 
                        "internalURL": "http://192.168.69.1:9292/v1", 
                        "publicURL": "http://192.168.69.1:9292/v1", 
                        "region": "RegionOne" 
                    }
                ], 
                "endpoints_links": [], 
                "name": "glance", 
                "type": "image" 
            }, 
            {
                "endpoints": [
                    {
                        "adminURL": "http://192.168.69.1:8774/v2/9c401c9d2b9d41bcabda6919d4aec63a", 
                        "internalURL": "http://192.168.69.1:8774/v2/9c401c9d2b9d41bcabda6919d4aec63a", 
                        "publicURL": "http://192.168.69.1:8774/v2/9c401c9d2b9d41bcabda6919d4aec63a", 
                        "region": "RegionOne" 
                    }
                ], 
                "endpoints_links": [], 
                "name": "nova", 
                "type": "compute" 
            }, 
            {
                "endpoints": [
                    {
                        "adminURL": "http://192.168.69.1:35357/v2.0", 
                        "internalURL": "http://192.168.69.1:5000/v2.0", 
                        "publicURL": "http://192.168.69.1:5000/v2.0", 
                        "region": "RegionOne" 
                    }
                ], 
                "endpoints_links": [], 
                "name": "keystone", 
                "type": "identity" 
            }, 
            {
                "endpoints": [
                    {
                        "adminURL": "http://192.168.69.1:8888/", 
                        "internalURL": "http://192.168.69.1:8888/v1/AUTH_9c401c9d2b9d41bcabda6919d4aec63a", 
                        "publicURL": "http://192.168.69.1:8888/v1/AUTH_9c401c9d2b9d41bcabda6919d4aec63a", 
                        "region": "RegionOne" 
                    }
                ], 
                "endpoints_links": [], 
                "name": "swift", 
                "type": "object-store" 
            }
        ], 
        "token": {
            "expires": "2012-06-08T15:31:46Z", 
            "id": "05b818ff23564d5599c97ea5e1df7bbe", 
            "tenant": {
                "description": "Default Tenant", 
                "enabled": true, 
                "id": "9c401c9d2b9d41bcabda6919d4aec63a", 
                "name": "openstackDemo" 
            }
        }, 
        "user": {
            "id": "1fcfbe778fc3428aa30db782056b34d7", 
            "name": "admin", 
            "roles": [
                {
                    "id": "a2d6da77c0a54105aab94484e0d2088b", 
                    "name": "admin" 
                }
            ], 
            "roles_links": [], 
            "username": "admin" 
        }
    }
}

Voce pode tambem listar usuarios, roles, tenants e services:

# keystone user-list
+----------------------------------+---------+-------+--------+
|                id                | enabled | email |  name  |
+----------------------------------+---------+-------+--------+
| 029c5749548946f7b560b2706d31d488 | True    | None  | glance |
| 1fcfbe778fc3428aa30db782056b34d7 | True    | None  | admin  |
| 4b75079aeb1b408ebdb286bfb85e719f | True    | None  | swift  |
| e25f81d50eb84bdb92907adbd0e41f25 | True    | None  | nova   |
+----------------------------------+---------+-------+--------+
# keystone role-list
+----------------------------------+-------+
|                id                |  name |
+----------------------------------+-------+
| 845e83e4d9bf4d8d8188b1e261dfe103 | user  |
| a2d6da77c0a54105aab94484e0d2088b | admin |
+----------------------------------+-------+
# keystone tenant-list
+----------------------------------+---------------+---------+
|                id                |      name     | enabled |
+----------------------------------+---------------+---------+
| 92920816c7704a8a95c916d34dc7a05c | service       | True    |
| 9c401c9d2b9d41bcabda6919d4aec63a | openstackDemo | True    |
+----------------------------------+---------------+---------+
# keystone service-list
+----------------------------------+----------+----------------+---------------------------+
|                id                |   name   |      type      |        description        |
+----------------------------------+----------+----------------+---------------------------+
| 00486163c7c64c6a86f577627071aafc | nova     | compute        | Nova Compute Service      |
| 69d3a6b21c9348acb1042d7d9386ff81 | volume   | volume         | Nova Volume Service       |
| 7b09782f9faf448781f5a460acabe258 | swift    | object-store   | Object Storage Service    |
| d6b32583a6694e9b828b2a50037623ba | keystone | identity       | Keystone Identity Service |
| f7f964a71e2a45119dcaede68fafbd78 | glance   | image          | Glance Image Service      |
+----------------------------------+----------+----------------+---------------------------+

Installing OpenStack Object Storage - Swift

[Descrever o Swift aqui]

Como neste ambiente de desenvolvimento temos apenas um no para storage e este sera o mesmo no que estara instalado o swift-proxy, todos os passos abaixo, sao executados na mesma maquina: educloud01.

Em um ambiente de producao aconselha-se ter pelo menos 05 object storage nodes e 01 object proxy node.

Instalando e configurando o swift

# apt-get install swift python-xattr python-memcache rsync memcached python-netifaces

Infelizmente no momento da escrita deste manual o pacote do swift nao automatiza algumas tarefas, como por exemplo, a criacao dos arquivos de configuracao. Teremos que fazer isso manualmente:

# mkdir /etc/swift

Crie o arquivo de configuracao /etc/swift/swift.conf:

[swift-hash]
# random unique string that can never change (DO NOT LOSE)
swift_hash_path_suffix = fLIbertYgibbitZ

Instalando e configurando os "object nodes"

# apt-get install swift-account swift-container swift-object xfsprogs

Cada "Object node" pode ter muitos dispositivos ligados a eles. 'E necessario que seja utilizado o sistema de arquivos xfs.

# fdisk /dev/sdb (set up a single partition)
# mkfs.xfs -i size=1024 /dev/sdb1

Este dispositivo deve estar montando em /srv/node/

echo "/dev/sdb1 /srv/node/sdb1 xfs noatime,nodiratime,nobarrier,logbufs=8 0 0" >> /etc/fstab
mkdir -p /srv/node/sdb1
mount /srv/node/sdb1
chown -R swift:swift /srv/node

Configure o rsyncd.conf

uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = 192.168.69.1

[account]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/account.lock

[container]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/container.lock

[object]
max connections = 2
path = /srv/node/
read only = false
lock file = /var/lock/object.lock

Edite o /etc/default/rsync:

RSYNC_ENABLE = true

Restarte o rsync:

service rsync restart

Crie o /etc/swift/account-server.conf:

[DEFAULT]
bind_ip = 192.168.69.1
workers = 2

[pipeline:main]
pipeline = account-server

[app:account-server]
use = egg:swift#account

[account-replicator]

[account-auditor]

[account-reaper]

Crie o /etc/swift/container-server.conf:

[DEFAULT]
bind_ip = 192.168.69.1
workers = 2

[pipeline:main]
pipeline = container-server

[app:container-server]
use = egg:swift#container

[container-replicator]

[container-updater]

[container-auditor]

Crie o /etc/swift/object-server.conf:

[DEFAULT]
bind_ip = 192.168.69.1
workers = 2

[pipeline:main]
pipeline = object-server

[app:object-server]
use = egg:swift#object

[object-replicator]

[object-updater]

[object-auditor]

Instale e configure o swift-proxy

# apt-get install swift-proxy memcached

Crie o certificado SSL auto assinado:

cd /etc/swift
openssl req -new -x509 -nodes -out cert.crt -keyout cert.key

Modifique o memcached para ouvir na interface da sua rede interna. Edite a seguinte linha no /etc/memcached.conf, mudando

-l 127.0.0.1
to
-l 192.168.69.1

Restart o memcached:

service memcached restart

Crie o arquivo /etc/swift/proxy-server.conf:

[DEFAULT]
bind_port = 8888
user = swift

[pipeline:main]
pipeline = catch_errors healthcheck cache authtoken keystone proxy-server

[app:proxy-server]
use = egg:swift#proxy
account_autocreate = true

[filter:keystone]
paste.filter_factory = keystone.middleware.swift_auth:filter_factory
operator_roles = admin, swiftoperator

[filter:authtoken]
paste.filter_factory = keystone.middleware.auth_token:filter_factory
# Delaying the auth decision is required to support token-less
# usage for anonymous referrers ('.r:*').
delay_auth_decision = 10
service_port = 5000
service_host = 192.168.69.1
auth_port = 35357
auth_host = 192.168.69.1
auth_token = 012345SECRET99TOKEN012345
admin_token = 012345SECRET99TOKEN012345
auth_protocol = http

[filter:cache]
use = egg:swift#memcache
set log_name = cache

[filter:catch_errors]
use = egg:swift#catch_errors

[filter:healthcheck]
use = egg:swift#healthcheck

Create the account, container and object rings. The builder command is basically creating a builder file with a few parameters. The parameter with the value of 18 represents 2 ^ 18th, the value that the partition will be sized to. Set this "partition power" value based on the total amount of storage you expect your entire ring to use. The value of 1 represents the number of replicas of each object, with the last value being the number of hours to restrict moving a partition more than once.

cd /etc/swift
swift-ring-builder account.builder create 18 1 1
swift-ring-builder container.builder create 18 1 1
swift-ring-builder object.builder create 18 1 1

For every storage device on each node add entries to each ring:

swift-ring-builder account.builder add z<ZONE>-<STORAGE_LOCAL_NET_IP>:6002/<DEVICE> 100
swift-ring-builder container.builder add z<ZONE>-<STORAGE_LOCAL_NET_IP_1>:6001/<DEVICE> 100
swift-ring-builder object.builder add z<ZONE>-<STORAGE_LOCAL_NET_IP_1>:6000/<DEVICE> 100

Como no nosso caso, apenas temos uma zona, em um storage node e com um device (sdb1), o comando acima ficaria:

swift-ring-builder account.builder add z1-192.168.69.1:6002/sdb1 100
swift-ring-builder container.builder add z1-192.168.69.1:6001/sdb1 100
swift-ring-builder object.builder add z1-192.168.69.1:6000/sdb1 100

Verify the ring contents for each ring:

swift-ring-builder account.builder
swift-ring-builder container.builder
swift-ring-builder object.builder

Rebalance the rings:

swift-ring-builder account.builder rebalance
swift-ring-builder container.builder rebalance
swift-ring-builder object.builder rebalance

Altere as permissoes dos arquivos de configuracao:

# chown -R swift:swift /etc/swift/

Inicie o swift-proxy:

swift-init proxy start

Inicie todos os servicos:

swift-init main start
swift-init rest start

Verificando a instalacao

O arquivo /root/openstackrc vai receber novas variaveis de ambiente, ele deve ficar assim:

# Used for Keystone
export SERVICE_ENDPOINT=http://192.168.69.1:35357/v2.0/
export SERVICE_TOKEN=012345SECRET99TOKEN012345

# Used for swift
export ST_AUTH=http://192.168.69.1:5000/v2.0
export ST_USER=openstackDemo:admin
export ST_KEY=adminpass
export OS_REGION_NAME=RegionOne

Carregue o arquivo:

# source /root/openstackrc

Tente obter status do swift:

# swift -V 2.0 stat
  1. Liste os containers:
# swift -V 2.0 list

Suba alguns arquivos para o swift:

# swift -V 2.0 upload myfiles bigfile1.tgz
# swift -V 2.0 upload myfiles bigfile2.tgz

Baixe o container "myfiles":

# cd /tmp/
# swift -V 2.0 download myfiles

Installing OpenStack Image Service - Glance

Also available in: PDF HTML TXT