在Ubuntu 14.04上部署OpenStack Juno

192.168.234.202 Openstack controller node
192.168.234.205 Openstack network node
192.168.234.204 Openstack compute node

networ node必须有三个NIC(network interface card),也就是网卡.

管理网段:10.0.0.0/24

2 基础环境 2.1 控制节点 controller node

要给它分配一个OpenStack管理网段的IP,因为它已经有了一个192段的IP了,所以建一个虚拟网卡绑定OpenStack管理网段的IP。

/etc/network/interfaces

# This file describes the network interfaces available on your system # and how to activate them. For more information, see interfaces(5). # The loopback network interface auto lo iface lo inet loopback # The primary network interface auto eth0 #iface eth0 inet dhcp iface eth0 inet static address 192.168.234.202 netmask 255.255.255.0 gateway 192.168.234.1 # OpenStack management interface. iface eth0:1 inet static address 10.0.0.11 netmask 255.255.255.0 gateway 10.0.0.1

/etc/hosts

# Controller 10.0.0.11 controller # network 10.0.0.21 network # compute1 10.0.0.31 compute1

2.2 网络节点 network node

/etc/network/interfaces

#The primary network interface auto eth0 iface eth0 inet static address 192.168.234.205 netmask 255.255.255.0 gateway 192.168.234.1 #management interface auto eth1:1 iface eth0:1 inet static address 10.0.0.21 netmask 255.255.255.0 gateway 10.0.0.1 #Instance tunnels interface. auto eth1:2 iface eth0:2 inet static address 10.0.1.21 netmask 255.255.255.0

/etc/hosts

#Controller 10.0.0.11 controller #network 10.0.0.21 network #compute1 10.0.0.31 compute1

2.3 计算节点 compute node

/etc/network/interfaces

# The primary network interface auto eth0 #iface eth0 inet dhcp iface eth0 inet static address 192.168.234.204 netmask 255.255.255.0 gateway 192.168.234.1 #management interface auto eth0:1 iface eth0:1 inet static address 10.0.0.31 netmask 255.255.255.0 gateway 10.0.0.1 #Instance tunnels interface. auto eth0:2 iface eth0:2 inet static address 10.0.1.31 netmask 255.255.255.0

/etc/hosts

#Controller 10.0.0.11 controller #network 10.0.0.21 network #compute1 10.0.0.31 compute1

3 配置时间同步

所有节点的时间必须同步

3.1 控制节点ntp配置

安装ntp

$ sudo aptitude install ntp -y

在/etc/ntp.conf配置上中国区的server.

server 1.cn.pool.ntp.org server 0.asia.pool.ntp.org server 3.asia.pool.ntp.org

server NTP_SERVER iburst restrict -4 default kod notrap nomodify restrict -6 default kod notrap nomodify

注意:默认的配置里的restrict有两个选项nopeer 和 noquery必须去掉。

重启服务

# service ntp restart

3.2 其它节点ntp配置

网络节点和计算节点也要安装配置ntp,要注意的是它们的ntp配置文件指定的server是controller,也就是从控制节点同步时间。

server controller iburst

3.3 验证ntp是否正确安装

1 在控制节点上运行此命令

#ntpq -c peers remote refid st t when poll reach delay offset jitter ============================================================================== dns2.synet.edu. 202.118.1.46 2 u 67 64 11 114.585 6.251 52.688 *ts0.itsc.cuhk.e .GPS. 1 u 64 64 37 79.028 -37.503 17.905 web10.hnshostin 193.67.79.202 2 u 4 64 77 474.192 -58.614 12.22

你的输出可能跟我的不一样,没关系有内容就OK。

2 在控制节点上运行此命令

# ntpq -c assoc ind assid status conf reach auth condition last_event cnt =========================================================== 1 61846 9424 yes yes none candidate reachable 2 2 61847 963a yes yes none sys.peer sys_peer 3 3 61848 9324 yes yes none outlyer reachable 2 4 61849 9424 yes yes none candidate reachable 2

你的输出可能跟我的不一样,没关系有内容就OK。

3 在其它节点上运行此命令

ntpq -c peers remote refid st t when poll reach delay offset jitter ============================================================================== *controller 137.189.4.10 2 u 29 64 1 0.154 18.278 0.610

输出结果中的remote列,应该是控制节点的hostname.

4 在其它节点上运行下面的命令

# ntpq -c assoc ind assid status conf reach auth condition last_event cnt =========================================================== 1 45051 963a yes yes none sys.peer sys_peer 3

condition列的值应该是sys.peer

4 安装MySQL RabbitMQ 4.1 安装Ubuntu Cloud的keyring和仓库

# apt-get install ubuntu-cloud-keyring # echo "deb " \ "trusty-updates/juno main" > /etc/apt/sources.list.d/cloudarchive-juno.list

4.2 安装配置数据库

1 安装MySQL

在数据库只需要安装在controller节点上。

# apt-get install mysql-server Python-mysqldb

在安装时要求输入root用户的密码,在本文里统一用openstack这个密码了。

2 编辑/etc/mysql/my.cnf,完成下面所提的操作。

在[mysqld]这一节里,把mysql绑定的IP改为controller节点的管理网段IP,同时加上下面的选项。

[mysqld] ... bind-address = 10.0.0.11 ... default-storage-engine = innodb innodb_file_per_table collation-server = utf8_general_ci init-connect = 'SET NAMES utf8' character-set-server = utf8

重启mysql服务。

4.3 安装消息服务

OpenStack使用消息中间件来传递服务之间的操作和状态,消息中间件通常安装在控制节点。OpenStack支持几种消息中间件,这里我们安装最常用的RabbitMQ。

# apt-get install rabbitmq-server

配置RabbitMQ

RabbitMQ在安装时创建了一个用户guest,我们就用这个用户了,只是把他的密码修改为openstack

# rabbitmqctl change_password guest openstack

For RabbitMQ version 3.3.0 or newer, you must enable remote access for the guest account.

Check the RabbitMQ version:

# rabbitmqctl status | grep rabbit

Restart the message broker service:

# service rabbitmq-server restart

5 安装OpenStack的认证服务 OpenStack Identity service

OpenStack Identity service提供如下功能

记录用户和他们的权限

提供OpenStack可用服务的API列表 所有的服务在安装后都要向Identity service注册自己。Identity service知道当前安装了哪些服务和他们在网络中的位置。

5.1 安装配置Identity service 5.1.1 准备工作

1 首先创建数据库

登录到控制节点的mysql

$ mysql -u root -p

创建数据库

CREATE DATABASE keystone;

加上本地和远程访问这个keystone数据库的权限。

GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'localhost' \ IDENTIFIED BY 'openstack'; GRANT ALL PRIVILEGES ON keystone.* TO 'keystone'@'%' \ IDENTIFIED BY 'openstack'; flush PRIVILEGES;

生成管理员的token,在初始配置时用。

# openssl rand -hex 10 7212bf54588f88818b52

5.1.1 安装配置keystone

# apt-get install keystone python-keystoneclient

编辑 /etc/keystone/keystone.conf完成下面的操作:

[DEFAULT] admin_token = 7212bf54588f88818b52 verbose = True ... [database] connection = mysql://keystone:openstack@controller/keystone ... [token] #这个provider可以不用改,默认的就是uuid provider = keystone.token.providers.uuid.Provider #这个默认是注释掉的,我们去掉注释就好 driver = keystone.token.persistence.backends.sql.Token ... [revoke] driver = keystone.contrib.revoke.backends.sql.Revoke ...

然后重启一下keystone服务就行了。

# service keystone restart

5.2 创建tenants, users, and roles 5.2.1 准备工作

在安装完Identity service后,你要创建tenants租户(也就是projects)、用户和角色。 你要用我们上一节创建的临时的管理员token,在你运行keystone命令前,手动配置Identity service endpoint。

你可以把管理员token用–os-token这个参数传给keystone命令,也可以设置环境变量OSSERVICETOKEN。一样的,你可以把管理员token用 Identity service的endpoint用命令行参数–os-endpoint传给keystone,也可以设置环境变量–os-endpoint。
我们采用环境变量的方式

$ export OS_SERVICE_TOKEN=7212bf54588f88818b52 $ export OS_SERVICE_ENDPOINT=:35357/v2.0

5.2.2 开始创建

创建一个用于管理的tenant,用户和角色

创建管理员租户

# keystone tenant-create --name admin --description "Admin Tenant" +-------------+----------------------------------+ | Property | Value | +-------------+----------------------------------+ | description | Admin Tenant | | enabled | True | | id | 357abecb4def441eb7a36e7cf5d173c4 | | name | admin | +-------------+----------------------------------+

创建管理员,我们用openstack做密码。

# keystone user-create --name admin --pass openstack --email admin@example.com +----------+----------------------------------+ | Property | Value | +----------+----------------------------------+ | email | admin@example.com | | enabled | True | | id | c2ba205513e448098f0e0daf80f2f649 | | name | admin | | username | admin | +----------+----------------------------------+

创建管理员角色

$ keystone role-create --name admin +----------+----------------------------------+ | Property | Value | +----------+----------------------------------+ | id | bff3a6083b714fa29c9344bf8930d199 | | name | admin | +----------+----------------------------------+

把管理员角色加到管理员用户上

$ keystone user-role-add --user admin --tenant admin --role admin

Note:Any roles that you create must map to roles specified in the policy.json file included with each OpenStack service. The default policy for most services grants administrative access to the admin role. For more information, see the Operations Guide - Managing Projects and Users.

创建一个用于一般操作的普通租户和用户

$ keystone tenant-create --name demo --description "Demo Tenant" +-------------+----------------------------------+ | Property | Value | +-------------+----------------------------------+ | description | Demo Tenant | | enabled | True | | id | 6245a74d882e451c8d7663a46103b8b2 | | name | demo | +-------------+----------------------------------+ $ keystone user-create --name demo --tenant demo --pass openstack --email demo@example.com +----------+----------------------------------+ | Property | Value | +----------+----------------------------------+ | email | demo@example.com | | enabled | True | | id | 54a55d3f3c1f4797bb82d196e6c02ccd | | name | demo | | tenantId | 6245a74d882e451c8d7663a46103b8b2 | | username | demo | +----------+----------------------------------+

OpenStack 服务需要租户、用户和角色来和其它的服务进行交互。每个服务都需要一个或多个service tenant下的特定的管理员,我们先来创建这个service tenant,下节将把这些服务注册到Identity service里。

$ keystone tenant-create --name service --description "Service Tenant" +-------------+----------------------------------+ | Property | Value | +-------------+----------------------------------+ | description | Service Tenant | | enabled | True | | id | ef36de18149b4c809c4b26b63b6dda37 | | name | service | +-------------+----------------------------------+

5.3 创建服务和API端点

你仍然需要设置OS_SERVICE_TOKEN和OS_SERVICE_ENDPOINT 这个两个环境变量。

5.3.1 创建Identity service服务实体

Openstack维护着一个当前部署环境下可用服务的列表,一个服务想要调用另外一个服务时会先查询一下Identity service,看看想调用的服务是否可用,部署在哪儿等。

首先当然是为Identity service创建一个服务实体了。

$ keystone service-create --name keystone --type identity \ --description "OpenStack Identity" +-------------+----------------------------------+ | Property | Value | +-------------+----------------------------------+ | description | OpenStack Identity | | enabled | True | | id | 4d17778357b84921aa632a5f02a4903b | | name | keystone | | type | identity | +-------------+----------------------------------+

5.3.2 创建Identity service的API端点

OpenStack的服务都提供API以方便其它与之沟通,Identity service维护着这些服务的列表。一个服务用查询这个列表以确定如何与其它服务进行沟通。

OpenStack提供三种API端点的变体:admin, internal, and public。在生产环境里,出于安全的考虑,它们应该会部署在单独的网络里,向不同的用户提供服务。

OpenStack支持多个regions,在本文里进行了简化,我们把所有的API端点都部署在管理网里,并都归属在regionOne这个region下。

$ keystone endpoint-create \ --service-id $(keystone service-list | awk '/ identity / {print $2}') \ --publicurl :5000/v2.0 \ --internalurl :5000/v2.0 \ --adminurl :35357/v2.0 \ --region regionOne +-------------+----------------------------------+ | Property | Value | +-------------+----------------------------------+ | adminurl | :35357/v2.0 | | id | f6a1c6efb040455c8e5aa0b05d01266d | | internalurl | :5000/v2.0 | | publicurl | :5000/v2.0 | | region | regionOne | | service_id | 4d17778357b84921aa632a5f02a4903b | +-------------+----------------------------------+

上面的命令keystone service-list | awk '/ identity / {print $2}'返回的其实就是我创建的Identity service实体的id.

Note Each service that you add to your OpenStack environment requires adding information such as API endpoints to the Identity service. The sections of this guide that cover service installation include steps to add the appropriate information to the Identity service

5.4 验证安装

本节我们来验证Identity service是否正确安装。

5.4.1 删除环境变量

删除OS_SERVICE_TOKEN and OS_SERVICE_ENDPOINT 这两个环境变量。

$ unset OS_SERVICE_TOKEN OS_SERVICE_ENDPOINT

5.4.2 以管理员的身份来请求鉴权的标识

$ keystone --os-tenant-name admin --os-username admin --os-password openstack \ --os-auth-url :35357/v2.0 token-get +-----------+----------------------------------+ | Property | Value | +-----------+----------------------------------+ | expires | 2015-03-12T05:12:19Z | | id | c9fbcb91847749f89848d968f411f571 | | tenant_id | 357abecb4def441eb7a36e7cf5d173c4 | | user_id | c2ba205513e448098f0e0daf80f2f649 | +-----------+----------------------------------+

5.4.3 查询所有的租户

以管理员的身份查询所有的租户,看看我们在前面创建的tenant是否创建成功了。

$ keystone --os-tenant-name admin --os-username admin --os-password openstack \ --os-auth-url :35357/v2.0 tenant-list +----------------------------------+---------+---------+ | id | name | enabled | +----------------------------------+---------+---------+ | 357abecb4def441eb7a36e7cf5d173c4 | admin | True | | 6245a74d882e451c8d7663a46103b8b2 | demo | True | | ef36de18149b4c809c4b26b63b6dda37 | service | True | +----------------------------------+---------+---------+

5.4.4 查询所有的用户

以管理员的身份查询所有的租户,看看我们在前面创建的用户是否都在。

$ keystone --os-tenant-name admin --os-username admin --os-password openstack \ --os-auth-url :35357/v2.0 user-list +----------------------------------+-------+---------+-------------------+ | id | name | enabled | email | +----------------------------------+-------+---------+-------------------+ | c2ba205513e448098f0e0daf80f2f649 | admin | True | admin@example.com | | 54a55d3f3c1f4797bb82d196e6c02ccd | demo | True | demo@example.com | +----------------------------------+-------+---------+-------------------+

admin和demo这个用户必须都在才对。

5.4.5 查询所有的角色

以管理员的身份查询所有的租户,看看我们在前面创建的角色是否都在。

$ keystone --os-tenant-name admin --os-username admin --os-password openstack \ --os-auth-url :35357/v2.0 role-list +----------------------------------+----------+ | id | name | +----------------------------------+----------+ | 9fe2ff9ee4384b1894a90878d3e92bab | _member_ | | 92b557ad2c944613a15065d267480802 | admin | +----------------------------------+----------+

5.4.6 获得demo用户鉴权的标识

$ keystone --os-tenant-name demo --os-username demo --os-password openstack \ --os-auth-url :35357/v2.0 token-get +-----------+----------------------------------+ | Property | Value | +-----------+----------------------------------+ | expires | 2015-03-12T05:57:19Z | | id | 03732cde3a5941bfa7db76515b5422a2 | | tenant_id | 6245a74d882e451c8d7663a46103b8b2 | | user_id | 54a55d3f3c1f4797bb82d196e6c02ccd | +-----------+----------------------------------+

5.4.7 demo用户尝试查询所有用户

demo用户没有管理权限,所以应该报403错误。

$ keystone --os-tenant-name demo --os-username demo --os-password openstack \ --os-auth-url :35357/v2.0 user-list You are not authorized to perform the requested action: admin_required (HTTP 403)

5.5 创建OpenStack客户端环境脚本

上一节我们用环境变量加命令行参数的方式用keystone这个命令来与Identity service来交互。为了提高客户端的操作效率,OpenStack支持简单客户端环境脚本- OpenRC文件。这些脚本包含所有客户端共用的一些选项,当然也可以包含特定选项。 更多信息请参考OpenStack用户指南

编辑admin-openrc.sh,键入以下内容:

export OS_TENANT_NAME=admin export OS_USERNAME=admin export OS_PASSWORD=openstack export OS_AUTH_URL=:35357/v2.0

编辑demo-openrc.sh,键入以下内容:

export OS_TENANT_NAME=demo export OS_USERNAME=demo export OS_PASSWORD=openstack export OS_AUTH_URL=:5000/v2.0

加载这些脚本,比如你想以管理员的身份来操作,请运行:

$ source admin-openrc.sh

6 安装image服务

OpenStack Image Service(glance)允许用户发现、注册和检索虚拟机的映像。它提供了一个REST API,你可以用它来查询映像的元信息和检索映像。 你可以把映像放在安装image service本地文件系统里,也可以选择放在对象存储系统里,如 OpenStack Object Storage。

重要 本文将把Image Service(glance)安装在控制节点上,并使用本地文件保存映像,默认目录为/var/lib/glance/images/,请确保控制节点有足够的存储空间。 如果想了解Image Service(glance)所使用的后端存储的信息更多信息,请参考Configuration Reference

6.1 OpenStack映像服务

OpenStack映像服务是它的IasS的重要核心组件,它接受磁盘或服务器映像的API请求,向用户或OpenStack的计算组件提供映像的元数据。

一些运行在OpenStack Image Service上的周期性的进程支持缓存功能。复制服务通过集群来确保一致性和可用性。其它的服务还包含审核服务,更新服务和收割服务。

OpenStack Image Service包含以下组件:

glance-api 接受映像发现、检索和存储的API调用。

glance-registry Stores, processes, and retrieves metadata about images. Metadata includes items such as size and type. 存储、处理和检索映像的元数据,元数据包含它的大小和类型。

Note 安全备注
glance-registry是内部私有服务,只向OpenStack映像服务提供服务,不要把它暴露给用户。

数据库 用来保存映像的元数据。

映像存储仓库 支持各种存储仓库,包括一般文件系统,对象存储系统,RADOS块设备,HTTP和Amazon S3。

6.2 安装和配置OpenStack映像服务 6.2.1 安装准备

在安装前,你必须创建数据库,服务凭证和API端点。 1. 配置数据库 数据库安装在控制节点上。

$ mysql -u root -p

创建 glance 数据库

CREATE DATABASE glance; GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'localhost' \ IDENTIFIED BY 'openstack'; GRANT ALL PRIVILEGES ON glance.* TO 'glance'@'%' \ IDENTIFIED BY 'openstack';

用切换到管理员身份

$ source admin-openrc.sh

创建服务凭证

创建glance用户

$ keystone user-create --name glance --pass openstack +----------+----------------------------------+ | Property | Value | +----------+----------------------------------+ | email | | | enabled | True | | id | 924b65933a294f0bb5e26945689c2c38 | | name | glance | | username | glance | +----------+----------------------------------+

为glance用户添加admin角色:

$ keystone user-role-add --user glance --tenant service --role admin

创建 glance 服务实体:

$ keystone service-create --name glance --type image \ --description "OpenStack Image Service" +-------------+----------------------------------+ | Property | Value | +-------------+----------------------------------+ | description | OpenStack Image Service | | enabled | True | | id | 1c95672e6b354cddaf6ce0115b6042ab | | name | glance | | type | image | +-------------+----------------------------------+

创建Image Service API 端点:

$ keystone endpoint-create \ --service-id $(keystone service-list | awk '/ image / {print $2}') \ --publicurl :9292 \ --internalurl :9292 \ --adminurl :9292 \ --region regionOne +-------------+----------------------------------+ | Property | Value | +-------------+----------------------------------+ | adminurl | :9292 | | id | ef72bb245bca419399cf4ff304148c31 | | internalurl | :9292 | | publicurl | :9292 | | region | regionOne | | service_id | 1c95672e6b354cddaf6ce0115b6042ab | +-------------+----------------------------------+

6.2.2 创建配置Image服务组件

1 安装包

# apt-get install glance python-glanceclient

2 编辑/etc/glance/glance-api.conf 加入下面的内容

[database] connection = mysql://glance:GLANCE_DBPASS@controller/glance ... [keystone_authtoken] #Note:Comment out any auth_host, auth_port, and auth_protocol options because the identity_uri option replaces them. auth_uri = :5000/v2.0 identity_uri = :35357 admin_tenant_name = service admin_user = glance admin_password = GLANCE_PASS ... [paste_deploy] flavor = keystone ... [glance_store] ... default_store = file filesystem_store_datadir = /var/lib/glance/images/ [DEFAULT] ... notification_driver = noop [DEFAULT] ... verbose = True

在本文中GLANCEDBPASS和GLANCEPASS都为openstack.

3 编辑 /etc/glance/glance-registry.conf 加入下面的内容:

[database] ... connection = mysql://glance:GLANCE_DBPASS@controller/glance [keystone_authtoken] ... auth_uri = :5000/v2.0 identity_uri = :35357 admin_tenant_name = service admin_user = glance admin_password = GLANCE_PASS [paste_deploy] ... flavor = keystone [DEFAULT] ... notification_driver = noop verbose = True

Note: 请注释掉任何authhost、authport和authprotocol 选项 因为identityuri替换了它们.

4 装载Image Service数据库:

# su -s /bin/sh -c "glance-manage db_sync" glance

6.2.3 完成安装

重启Image服务:

# service glance-registry restart # service glance-api restart

默认Ubuntu安装创建了一个SQLite,你可以删除它。

# rm -f /var/lib/glance/glance.sqlite

6.3 验证安装

[1] 创建一个临时目录

$ mkdir /tmp/images

2 下载映像到这个临时目录

$ wget -P /tmp/images

3 转成管理员身份

$ source admin-openrc.sh

4 上传映像到Image服务

$ glance image-create --name "cirros-0.3.3-x86_64" --file /tmp/images/cirros-0.3.3-x86_64-disk.img \ --disk-format qcow2 --container-format bare --is-public True --progress [=============================>] 100% +------------------+--------------------------------------+ | Property | Value | +------------------+--------------------------------------+ | checksum | 133eae9fb1c98f45894a4e60d8736619 | | container_format | bare | | created_at | 2015-03-12T08:45:49 | | deleted | False | | deleted_at | None | | disk_format | qcow2 | | id | b460412b-4566-4d8b-8b9a-27f638f8ca58 | | is_public | True | | min_disk | 0 | | min_ram | 0 | | name | cirros-0.3.3-x86_64 | | owner | 357abecb4def441eb7a36e7cf5d173c4 | | protected | False | | size | 13200896 | | status | active | | updated_at | 2015-03-12T08:45:49 | | virtual_size | None | +------------------+--------------------------------------+

glance image-create命令的更多信息请参见:.

关于disk和container格式的更多信息请参考OpenStack Virtual Machine Image Guide

5 查询映像以确认数据是否正确

$ glance image-list +--------------------------------------+---------------------+-------------+------------------+----------+--------+ | ID | Name | Disk Format | Container Format | Size | Status | +--------------------------------------+---------------------+-------------+------------------+----------+--------+ | b460412b-4566-4d8b-8b9a-27f638f8ca58 | cirros-0.3.3-x86_64 | qcow2 | bare | 13200896 | active | +--------------------------------------+---------------------+-------------+------------------+----------+--------+

6 删除临时目录

$ rm -r /tmp/images

7 安装OpenStack计算服务

概念和组件的作用,请参考安装手册

7.1 安装配置控制节点 7.1.1 准备工作

1 配置数据库 数据库安装在控制节点上。

$ mysql -u root -p

创建 glance 数据库

CREATE DATABASE nova; GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'localhost' \ IDENTIFIED BY 'NOVA_DBPASS'; GRANT ALL PRIVILEGES ON nova.* TO 'nova'@'%' \ IDENTIFIED BY 'NOVA_DBPASS';

NOVA_DBPASS我们使用openstack.

2 切换到管理员身份

$ source admin-openrc.sh

3 To create the service credentials, complete these steps:

创建 nova 用户:

$ keystone user-create --name nova --pass openstack +----------+----------------------------------+ | Property | Value | +----------+----------------------------------+ | email | | | enabled | True | | id | 952eae64d8124b06812a5bb595f3690f | | name | nova | | username | nova | +----------+----------------------------------+

为nova用户添加admin角色:

$ keystone user-role-add --user nova --tenant service --role admin

创建 nova 服务实体:

$ keystone service-create --name nova --type compute \ --description "OpenStack Compute" +-------------+----------------------------------+ | Property | Value | +-------------+----------------------------------+ | description | OpenStack Compute | | enabled | True | | id | 45a5a2e53de246f89dedf20a9d23c8f8 | | name | nova | | type | compute | +-------------+----------------------------------+

创建计算服务API端点:

$ keystone endpoint-create \ --service-id $(keystone service-list | awk '/ compute / {print $2}') \ --publicurl :8774/v2/%\(tenant_id\)s \ --internalurl :8774/v2/%\(tenant_id\)s \ --adminurl :8774/v2/%\(tenant_id\)s \ --region regionOne +-------------+-----------------------------------------+ | Property | Value | +-------------+-----------------------------------------+ | adminurl | :8774/v2/%(tenant_id)s | | id | 7839d34cdfb641a9884eee7b67680391 | | internalurl | :8774/v2/%(tenant_id)s | | publicurl | :8774/v2/%(tenant_id)s | | region | regionOne | | service_id | 45a5a2e53de246f89dedf20a9d23c8f8 | +-------------+-----------------------------------------+

7.1.2 安装配置计算控制组件

1 安装相关包

# apt-get install nova-api nova-cert nova-conductor nova-consoleauth \ nova-novncproxy nova-scheduler python-novaclient

2 编辑 /etc/nova/nova.conf 加入下面的内容
默认安装nova.conf内容好少,你要手动添加下面的内容。

[database] ... connection = mysql://nova:openstack@controller/nova [DEFAULT] ... rpc_backend = rabbit rabbit_host = controller rabbit_password = openstack auth_strategy = keystone #这个IP应该是管理网段的IP my_ip = 10.0.0.11 vncserver_listen = 10.0.0.11 vncserver_proxyclient_address = 10.0.0.11 verbose = True [keystone_authtoken] ... auth_uri = :5000/v2.0 identity_uri = :35357 admin_tenant_name = service admin_user = nova admin_password = openstack [glance] ... host = controller

3 装载计算服务数据库:

# su -s /bin/sh -c "nova-manage db sync" nova

7.1.3 完成安装

重启计算服务

# service nova-api restart # service nova-cert restart # service nova-consoleauth restart # service nova-scheduler restart # service nova-conductor restart # service nova-novncproxy restart

7.2 安装配置计算节点

终于到了计算节点了

7.2.1 安装hypervisor

1 安装包

# apt-get install nova-compute sysfsutils

2 编辑 /etc/nova/nova.conf 加入下面的内容
默认安装nova.conf内容好少,你要手动添加下面的内容。

[DEFAULT] ... rpc_backend = rabbit rabbit_host = controller rabbit_password = openstack auth_strategy = keystone my_ip = 10.0.0.31 vnc_enabled = True vncserver_listen = 0.0.0.0 vncserver_proxyclient_address = 10.0.0.31 novncproxy_base_url = :6080/vnc_auto.html verbose = True [keystone_authtoken] ... auth_uri = :5000/v2.0 identity_uri = :35357 admin_tenant_name = service admin_user = nova admin_password = openstack [glance] ... host = controller

7.2.2 完成安装

先看看这个节点支不支持硬件虚拟化

# egrep -c '(vmx|svm)' /proc/cpuinfo

如果返回的结果是0,那你就需要编辑/etc/nova/nova-compute.conf这个文件,把virt_type改成qemu:

[libvirt] ... virt_type = qemu

重启计算服务

# service nova-compute restart

7.3 验证安装

请在控制节点上运行下面的命令

1 切换为管理员

$ source admin-openrc.sh

2 列出所有的服务组件

$ nova service-list +----+------------------+-----------+----------+---------+-------+----------------------------+-----------------+ | Id | Binary | Host | Zone | Status | State | Updated_at | Disabled Reason | +----+------------------+-----------+----------+---------+-------+----------------------------+-----------------+ | 1 | nova-cert | localhost | internal | enabled | up | 2015-03-12T10:04:04.000000 | - | | 2 | nova-scheduler | localhost | internal | enabled | up | 2015-03-12T10:04:12.000000 | - | | 3 | nova-consoleauth | localhost | internal | enabled | up | 2015-03-12T10:04:12.000000 | - | | 4 | nova-conductor | localhost | internal | enabled | up | 2015-03-12T10:04:11.000000 | - | | 5 | nova-compute | localhost | nova | enabled | up | 2015-03-12T10:04:06.000000 | - | +----+------------------+-----------+----------+---------+-------+----------------------------+-----------------+

Host那一列都是localhost有问题,我设置了hostname但是没有重启机器。重启以后应该会好。

3 列出所有映像

$ nova image-list +--------------------------------------+---------------------+--------+--------+ | ID | Name | Status | Server | +--------------------------------------+---------------------+--------+--------+ | b460412b-4566-4d8b-8b9a-27f638f8ca58 | cirros-0.3.3-x86_64 | ACTIVE | | +--------------------------------------+---------------------+--------+--------+

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/15676.html