安装OpenStack(openSUSE) Step by Step - Compute (Nova) (一)
上一篇:安装OpenStack(openSUSE) Step by Step - Image (Glance)
OpenStack Compute Service - Nova
跟随OpenStack Installation Guide for Ubuntu 12.04的节奏,我们遇到了Nova。它是OpenStack的核心,简而言之,它掌控着控制节点或计算节点的行为。
准备条件
安装KVM
- 检查CPU条件
$ grep -E '(vmx|svm)' /proc/cpuinfo
- 使用YAST工具,直接安装KVM,这里不详细介绍。安装后重启。
配置网桥
使用YAST工具添加一个网桥br100。1(前提:使用ifup配置网络)
- YAST - 网络设备 - 网络设置- 概览 - 添加 - 设备类型(网桥) - 配置名称(100)- 下一步 - 静态IP(192.168.100.1) - 下一步 - 完成
配置MySQL
与Keystone相似,我们需要初始化一个数据库用于Nova服务。
$ mysql -u root -p
mysql> CREATE DATABASE nova;
mysql> GRANT ALL ON nova.* TO 'nova'@'%' IDENTIFIED BY '[nova的数据库密码]';
mysql> GRANT ALL ON nova.* TO 'nova'@'localhost' IDENTIFIED BY '[nova的数据库密码]';
mysql> quit
安装配置Block Storage Service - Cinder
- 安装
$ zypper in openstack-cinder-api openstack-cinder-scheduler openstack-cinder-volume python-cinderclient tgt open-iscsi
- 编辑
/etc/cinder/api-paste.ini
[filter:authtoken]
paste.filter_factory = keystoneclient.middleware.auth_token:filter_factory
service_protocol = http
service_host = 127.0.0.1
service_port = 5000
auth_host = 127.0.0.1
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = cinder
admin_password = cinder
- 在Keystone配置中并没有cinder用户,需要根据其它用户的模板添加cinder
$ keystone user-create --tenant-id [xxx] --name cinder --pass cinder
$ keystone user-role-add --tenant-id [xxx] --user-id [xxx] --role-id [xxx]
- 首先建立一个LVM卷组
cinder-volumes
,如果没有空闲分区,可以新建一个文件挂载为loop设备。参考自OpenStack Grizzly Install Guide(A very good guide :) (另外,LVM的管理可以Google)
dd if=/dev/zero of=cinder-volumes bs=1 count=0 seek=2G
losetup /dev/loop2 cinder-volumes
fdisk /dev/loop2
#Type in the followings:
n
p
1
ENTER
ENTER
t
8e
w
pvcreate /dev/loop2
vgcreate cinder-volumes /dev/loop2
- 配置
/etc/cinder/cinder.conf
。
[DEFAULT]
verbose = True
log_dir = /var/log/cinder
auth_strategy = keystone
rootwrap_config = /etc/cinder/rootwrap.conf
state_path = /var/lib/cinder
sql_connection = mysql://cinder:cinder@localhost/cinder
volume_name_template = volume-%s
volume_group = cinder-volumes
api_paste_config=/etc/cinder/api-paste.ini
iscsi_helper = tgtadm
- 在MySQL中添加cinder相关配置
mysql> CREATE DATABASE cinder;
mysql> GRANT ALL ON cinder.* TO 'cinder'@'localhost' IDENTIFIED BY '[cinder的数据库密码]';
mysql> quit
- 配置target framework (tgt)
$ echo "include /etc/tgt/conf.d/*.conf" >> /etc/tgt/targets.conf
$ mkdir /etc/tgt/conf.d
$ echo "include /var/lib/cinder/volumes/*" >> /etc/tgt/conf.d/cinder.conf
$ rctgtd restart
- 初始化数据库,重启相关服务。
cinder-volume
启动错误详见2
$ cinder-manage db sync
$ rcopenstack-cinder-volume restart
$ rcopenstack-cinder-api restart
$ rcopenstack-cinder-scheduler restart
验证cinder安装
$ cinder create --display_name test 1
$ cinder list
返回结果:
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
| a33780a2-52b2-40b1-95eb-529283baa7e6 | available | test | 1 | None | | |
+--------------------------------------+-----------+--------------+------+-------------+----------+-------------+
volume状态错误
此外,volume的状态不是avaliable
和error
时,比如deleting
,是无法用cinder delete
删除的。
+--------------------------------------+----------------+--------------+------+-------------+----------+-------------+
| ID | Status | Display Name | Size | Volume Type | Bootable | Attached to |
+--------------------------------------+----------------+--------------+------+-------------+----------+-------------+
| 992103a2-d40b-4346-8afc-75efdbc643f1 | error_deleting | test | 1 | None | | |
| a33780a2-52b2-40b1-95eb-529283baa7e6 | available | test | 1 | None | | |
+--------------------------------------+----------------+--------------+------+-------------+----------+-------------+
$ cinder delete 992103a2-d40b-4346-8afc-75efdbc643f1
ERROR: Invalid volume: Volume status must be available or error (HTTP 400) (Request-ID: req-35f0b5fe-e435-4595-a31c-ce4e0d571f8e)
只能在数据库中将其状态修改为error
。
mysql>use cinder;
mysql>select status,id from volumes;
+----------------+--------------------------------------+
| status | id |
+----------------+--------------------------------------+
| error_deleting | 992103a2-d40b-4346-8afc-75efdbc643f1 |
| available | a33780a2-52b2-40b1-95eb-529283baa7e6 |
+----------------+--------------------------------------+
mysql>update volumes set status="error" where id="992103a2-d40b-4346-8afc-75efdbc643f1";
mysql>select status,id from volumes;
+-----------+--------------------------------------+
| status | id |
+-----------+--------------------------------------+
| error | 992103a2-d40b-4346-8afc-75efdbc643f1 |
| available | a33780a2-52b2-40b1-95eb-529283baa7e6 |
+-----------+--------------------------------------+
然后,查看target中的节点信息
$ tgtadm --lld iscsi --mode target --op show
Target 1: iqn.2010-10.org.openstack:volume-992103a2-d40b-4346-8afc-75efdbc643f1
System information:
Driver: iscsi
State: ready
I_T nexus information:
LUN information:
LUN: 0
Type: controller
SCSI ID: IET 00010000
SCSI SN: beaf10
Size: 0 MB, Block size: 1
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Thin-provisioning: No
Backing store type: null
Backing store path: None
Backing store flags:
LUN: 1
Type: disk
SCSI ID: IET 00010001
SCSI SN: beaf11
Size: 1074 MB, Block size: 512
Online: Yes
Removable media: No
Prevent removal: No
Readonly: No
Thin-provisioning: No
Backing store type: rdwr
Backing store path: /dev/cinder-volumes/volume-992103a2-d40b-4346-8afc-75efdbc643f1
Backing store flags:
Account information:
ACL information:
ALL
删除这个错误的节点
$ tgtadm --lld iscsi --mode target --op delete --tid 1
最后再使用cinder delete
将其删除
$ cinder delete 992103a2-d40b-4346-8afc-75efdbc643f1
安装Nova
待续… :)
安装OpenStack(openSUSE) Step by Step - Compute (Nova) (二)
参考文档
OpenStack Installation Guide for Ubuntu 12.04
脚注
可能已经存在了一个网桥。 ↩
cinder-volume
服务启动失败,在volume.log
中看到有关sudo
的错误:sudo: no tty present and no askpass program specified
,这是由于openstack-cinder
用户在执行sudo cinder-rootwrap
时,并没有无密码执行的sudo权限。因此需要在/etc/sudoers.d/cinder_sudoers
添加1 2
Defaults: openstack-cinder !requiretty openstack-cinder ALL = (root) NOPASSWD: /usr/bin/cinder-rootwrap
类似的问题也会发生在Nova、Quantum服务,参考自:https://lists.launchpad.net/openstack/msg22121.html
解决方案:
1
$ zypper in openstack-suse-sudo