Welcome to openstack-on-centos’s documentation!

准备工作

在主节点和计算节点进行如下配置。

设置软件源

更改 centos 源

备份系统配置

cd /etc/yum.repos.d
mv CentOS-Base.repo.backup

中科大镜像 下载相应版本 CentOS-Base.repo 文件,放入 /etc/yum.repos.d

运行 yum makecache 生成缓存。

添加 epel 仓库

下载安装 epel 配置文件

wget -c http://mirror.neu.edu.cn/fedora/epel/6/i386/epel-release-6-8.noarch.rpm
rpm -i epel-release-6-8.noarch.rpm
cd /etc/yum.repos.d

打开 epel.repo, 修改配置

[epel]
enabled = 1
baseurl = http://mirrors.ustc.edu.cn/fedora/epel/6/$basearch
# mirrorlist = ...  # 注释此项

运行 yum makecache 生成缓存。

安装 MySQL 和 rabbitmq

安装 MySQL

yum install mysql mysql-server MySQL-python # 安装 MySQL 数据库及其 Python 绑定
service mysqld start      # 启动 MySQL 服务
chkconfig mysqld on       # 设置开机启动服务
mysql_secure_installation # 设置root密码,删除空用户和测试表

安装 rabbitmq

yum install rabbitmq-server # 安装 rabbitmq-server 服务器
service rabbitmq-server start  # 启动 rabbitmq-server
chkconfig rabbitmq-server on   # 设置开机启动服务

安装和配置 Keystone

安装

安装 openstack-keystone

yum install openstack-utils openstack-keystone python-keystoneclient

初始化数据库

修改 /etc/keystone/keystone.confsql->connection 项为

mysql://keystone:keystone@127.0.0.1:3306/keystone

Note

因为mysql版本的问题,127.0.0.1 不可写为 localhost,且端口号不可忽略,否则连接不上数据库。所有mysql连接的配置都需注意。

原因:

  • 当主机名为 localhost 时,mysql驱动会使用 unix_socks 进行连接, 此时需要在 uri 后添加 socks 文件的路径参数才能使用
  • 在mysql旧版本中,若不指定版本号,则默认为 0

在mysql中建立keystone数据库和用户,并赋予权限。

openstack-db --init --service keystone

如上命令会根据配置文件中的 connection 项,创建 keystone 数据库和 keystone 用户,密码为 keystone

设置 admin_token

openstack-config --set /etc/keystone/keystone.conf DEFAULT admin_token <admin_token>

admin_token 为一密钥,用于操作keystone时的认证。

同步数据库

keystone-manage db_sync

此命令在keystone数据库中创建相应数据表。

启动 keystone 服务

service openstack-keystone start # 启动 keystone 服务
chkconfig openstack-keystone on  # 设置开机启动服务

配置服务

创建用户、租户和角色

创建租户

keystone --token <admin_token> --endpoint http://127.0.0.1:35357/v2.0 \
    tenant-create --name demo

创建用户并与租户绑定

keystone --token <admin_token> --endpoint http://127.0.0.1:35357/v2.0 \
    user-create --tenant-id <上一步中返回的tenant-id> --name admin --pass admin

创建管理员角色(根据keystone默认的 policy.json)

keystone --token <admin_token> --endpoint http://127.0.0.1:35357/v2.0 \
    role-create --name admin

赋予demo中的admin用户管理员权限

keystone --token <admin_token> --endpoint http://127.0.0.1:35357/v2.0 \
    user-role-add --tenant-id <tenant-id> --user-id <user-id> --role-id <role-id>

创建服务

修改 /etc/keystone/keystone.conf 中,catalog->driver 项为 keystone.catalog.backends.sql.Catalog,即设置服务目录采用数据库存储。

定义 Identity 服务

keystone --token <admin-token> --endpoint http://127.0.0.1:35357/v2.0 \
    service-create --name=keystone --type=identity

keystone --token <admin-token> --endpoint http://127.0.0.1:35357/v2.0 \
    endpoint-create \
    --region scut \
    --service-id=<上一步返回的service-id> \
    --publicurl=http://192.168.1.1:5000/v2.0 \
    --internalurl=http://192.168.1.1:5000/v2.0 \
    --adminurl=http://192.168.1.1:35357/v2.0

定义 Compute 服务

keystone --token <admin-token> --endpoint http://127.0.0.1:35357/v2.0 \
    service-create --name=nova --type=compute

keystone --token <admin-token> --endpoint http://127.0.0.1:35357/v2.0 \
    endpoint-create \
    --region scut \
    --service-id=<上一步返回的service-id> \
    --publicurl='http://192.168.1.1:8774/v2/%(tenant_id)s' \
    --internalurl='http://192.168.1.1:8774/v2/%(tenant_id)s' \
    --adminurl='http://192.168.1.1:8774/v2/%(tenant_id)s'

定义 Volume 服务

keystone --token <admin-token> --endpoint http://127.0.0.1:35357/v2.0 \
    service-create --name=volume --type=volume

keystone --token <admin-token> --endpoint http://127.0.0.1:35357/v2.0 \
    endpoint-create \
    --region scut \
    --service-id=<上一步返回的service-id> \
    --publicurl='http://192.168.1.1:8776/v1/%(tenant_id)s' \
    --internalurl='http://192.168.1.1:8776/v1/%(tenant_id)s' \
    --adminurl='http://192.168.1.1:8776/v1/%(tenant_id)s'

定义 Image 服务

keystone --token <admin-token> --endpoint http://127.0.0.1:35357/v2.0 \
    service-create --name=glance --type=image

keystone --token <admin-token> --endpoint http://127.0.0.1:35357/v2.0 \
    endpoint-create \
    --region scut \
    --service-id=<上一步返回的service-id> \
    --publicurl='http://192.168.1.1:9292' \
    --internalurl='http://192.168.1.1:9292' \
    --adminurl='http://192.168.1.1:9292'

定义 EC2 兼容服务

keystone --token <admin-token> --endpoint http://127.0.0.1:35357/v2.0 \
    service-create --name=ec2 --type=ec2

keystone --token <admin-token> --endpoint http://127.0.0.1:35357/v2.0 \
    endpoint-create \
    --region scut \
    --service-id=<上一步返回的service-id> \
    --publicurl='http://192.168.1.1:8773/services/Cloud' \
    --internalurl='http://192.168.1.1:8773/services/Cloud' \
    --adminurl='http://192.168.1.1:8773/services/Admin'

定义 Object Storage 服务

keystone --token <admin-token> --endpoint http://127.0.0.1:35357/v2.0 \
    service-create --name=swift --type=object-store

keystone --token <admin-token> --endpoint http://127.0.0.1:35357/v2.0 \
    endpoint-create \
    --region scut \
    --service-id=<上一步返回的service-id> \
    --publicurl='http://192.168.1.1:8888/v1/AUTH_%(tenant_id)s' \
    --internalurl='http://192.168.1.1:8888/v1/AUTH_%(tenant_id)s' \
    --adminurl='http://192.168.1.1:8888/v1'

验证 Identify 服务安装

验证 keystone 是否正确运行以及用户是否正确建立。

keystone --os-username=admin --os-password=admin \
    --os-auth-url=http://127.0.0.1:35357/v2.0 token-get

验证用户在指定的 tenant 上是否有明确定义的角色。

keystone --os-username=admin --os-password=admin \
    --os-tenant-name=demo --os-auth-url=http://127.0.0.1:35357/v2.0 token-get

此命令根据 username, password, tenant-name 换取访问 token

可以将以上参数设置为环境变量,不用每次输入

export OS_USERNAME=admin
export OS_PASSWORD=admin
export OS_TENANT_NAME=demo
export OS_AUTH_URL=http://127.0.0.1:35357/v2.0 # 管理员命令必须通过 35357 端口执行

此时可直接运行

keystone token-get

最后,验证admin账户有权限执行管理命令

keystone user-list   # 列举所有用户

安装和配置 Glance

安装

安装 openstack-glance

yum install openstack-nova openstack-glance

配置 glance 数据库

在mysql中建立 glance 数据库和用户,并赋予权限。

mysql -u root -p
create database glance;
grant all on glance.* to 'glance'@'%' identified by 'glance';
grant all on glance.* to 'glance'@'localhost' identified by 'glance';

修改配置文件

/etc/glance/glance-api.conf

enable_v1_api=True
enable_v2_api=True

[keystone_authtoken]
auth_host = 127.0.0.1
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = glance
admin_password = glance

flavor=keystone

sql_connection = mysql://glance:glance@127.0.0.1:3306/glance

/etc/glance/glance-api-paste.ini

[filter:authtoken]
admin_tenant_name = service
admin_user = glance
admin_password = glance

glance-registry.conf

[keystone_authtoken]
auth_host = 127.0.0.1
auth_port = 35357
auth_protocol = http
admin_tenant_name = service
admin_user = glance
admin_password = glance

flavor = keystone

sql_connection = mysql://glance:glance@127.0.0.1:3306/glance

glance-registry-paste.ini

[pipeline:glance-registry-keystone]
pipeline = authtoken context registryapp

同步数据库,启动服务

glance-manage db_sync
service glance-registry start  # 启动服务
service glance-api start
chkconfig glance-registry on   # 设置开机启动服务
chkconfig glance-api on

验证 Glance 安装

获取测试镜像

mkdir /tmp/images
cd /tmp/images
wget -c http://smoser.brickies.net/ubuntu/ttylinux-uec/ttylinux-uec-amd64-12.1_2.6.35-22_1.tar.gz
tar -zxvf ttylinux-uec-amd64-12.1_2.6.35-22_1.tar.gz

设置环境变量

export OS_USERNAME=admin
export OS_TENANT_NAME=demo
export PASSWORD=admin
export OS_AUTH_URL=http://127.0.0.1:5000/v2.0/
export OS_REGION_NAME=scut

(通过以上环境变量调用 glance,上传的镜像属于admin用户的demo tenant)

上传内核

glance image-create --name="tty-linux-kernel" \
--disk-format=aki \
--container-format=aki < ttylinux-uec-amd64-12.1_2.6.35-22_1-vmlinuz

上传 initrd

glance image-create --name="tty-linux-ramdisk" \
--disk-format=ari \
--container-format=ari < ttylinux-uec-amd64-12.1_2.6.35-22_1-loader

上传镜像

glance image-create --name="tty-linux" \
--disk-format=ami \
--container-format=ami \
--property kernel_id=<上面返回的kernel_id> \
ramdisk_id=<上面返回的ramdisk_id> < ttylinux-uec-amd64-12.1_2.6.35-22_1.img

Note

磁盘格式为 aki, ari, ami 时,容器格式需与磁盘格式相同

运行 image-list 命令列举镜像

glance image-list

命令应返回三个镜像

配置 Hypervisor —— KVM为例

检查硬件虚拟化支持

egrep '(vmx|svm)' --color=always /proc/cpuinfo

若无结果返回,说明硬件不支持虚拟化,不能使用 KVM,需使用其它虚拟化技术。

检查 KVM 模块加载

lsmod |grep kvm

若模块未加载

modprobe kvm
modprobe kvm-intel # for intel cpu
modprobe kvm-amd   # for amd cpu

修改 nova 配置文件

/etc/nova/nova.conf

compute-driver=libvirt.LibvirtDriver
libvirt_type=kvm

安装和配置 nova – 主节点

网络设置

网卡接口设置

安装桥接管理软件

yum install bridge-utils

删除原有网卡上的桥接

brctl show
brctl delbr <要删除的桥接网卡>

Note

注意不要改动外网网卡的桥接,以免远程访问断开

重新设置 ip

ifconfig peth0 192.168.1.1 # 假设 peth0 为内部连接端口

将网卡设置为混杂模式

ifconfig peth0 promisc

设置 selinux 为 permissive

setenforce permissive

安装 dnsmasq

yum install dnsmasq-utils # 用作虚拟机 DHCP 自动获取 IP

配置数据库

在mysql中建立 nova 数据库和用户,并赋予权限

mysql -u root -p
create database nova;
grant all on nova.* to 'nova'@'%' identified by nova;
grant all on nova.* to 'nova'@'%' identified by nova;

修改配置文件

/etc/nova/nova.conf

[DEFAULT]
# debug=True
# verbose=True
compute_scheduler_driver=nova.scheduler.filter_scheduler.FilterScheduler
logdir = /var/log/nova
state_path = /var/lib/nova
lock_path = /var/lib/nova/tmp
volumes_dir = /etc/nova/volumes
iscsi_helper = tgtadm
sql_connection = mysql://nova:nova@127.0.0.1:3306/nova
compute_driver = libvirt.LibvirtDriver
firewall_driver = nova.virt.libvirt.firewall.IptablesFirewallDriver
#rpc_backend = nova.openstack.common.rpc.impl_qpid  # 默认使用 rabbitmq
rootwrap_config = /etc/nova/rootwrap.conf
libvirt_type = kvm
my_ip=192.168.1.1
# 注意此处路径需存在,且对nova用户具有读写权限
instances_path=/state/partition1/openstack/instance

#AUTH
auth_strategy = keystone
# 消息队列主机,因为 rabbitmq 部署在主节点上,与 nova 处于同一主机,故 ip 可设置为127.0.0.1
rabbit_host = 127.0.0.1

api_paste_config = /etc/nova/api-paste.ini

#NETWORK
dhcpbridge = /usr/bin/nova-dhcpbridge
dhcpbridge_flagfile = /etc/nova/nova.conf
force_dhcp_release = False
libvirt_inject_partition = -1
injected_network_template = /usr/share/nova/interfaces.template
libvirt_nonblocking = True

network_manager = nova.network.manager.FlatDHCPManager
fixed_range=192.168.100.0/24  # VM IP 范围
flat_network_bridge = br100   # 虚拟网桥名称
# 因为几台服务器间只有一个端口相互连接,所以public和flat接口设置为同一个
public_interface=peth0
flat_interface=peth0

#VNC
# 外网可访问的地址
novncproxy_base_url=http://202.38.192.97:6080/vnc_auto.html

[keystone_authtoken]
admin_tenant_name = service
admin_user = nova
admin_password = nova
auth_host = 127.0.0.1
auth_port = 35357
auth_protocol = http
signing_dir = /tmp/keystone-signing-nova

同步数据库

nova-manage db sync

启动服务

for svc in api objectstore compute network volume scheduler cert;
do
    service openstack-nova-$svc start; # 启动服务
    chkconfig openstack-nova-$svc on;  # 设置开机启动服务
done

创建网络

nova-manage network create private --fixed_range_v4=192.168.100.0/24 \
    --bridge_interface=br100 --num_networks=1 --network_size=256

验证 nova 安装

nova-manage service list

此命令获取 nova 各服务的运行状况,在返回中笑脸为正常运行,X 为错误。

设置账户认证信息

建立一个 openrc 文件

export OS_USERNAME=admin
export OS_TENANT_NAME=demo
export PASSWORD=admin
export OS_AUTH_URL=http://127.0.0.1:5000/v2.0/
export OS_REGION_NAME=scut

读入 openrc

source openrc

验证效果

nova image-list

通过 nova 命令访问 glance 服务,获取 admin 用户在 demo tenant 所有的镜像。

其它计算节点配置

安装 openstack-nova

yum install openstack-nova

网卡接口设置

安装桥接管理软件

yum install bridge-utils

将网卡设置为混杂模式

ifconfig eth0 promisc

设置 selinux 为 permissive

setenforce permissive

修改配置文件

[DEFAULT]
# debug=True
# verbose=True
compute_scheduler_driver=nova.scheduler.filter_scheduler.FilterScheduler
logdir = /var/log/nova
state_path = /var/lib/nova
lock_path = /var/lib/nova/tmp
volumes_dir = /etc/nova/volumes
iscsi_helper = tgtadm
# 此处为管理节点主机 IP
sql_connection = mysql://nova:nova@192.168.1.1:3306/nova
compute_driver = libvirt.LibvirtDriver
firewall_driver = nova.virt.libvirt.firewall.IptablesFirewallDriver
#rpc_backend = nova.openstack.common.rpc.impl_qpid
rootwrap_config = /etc/nova/rootwrap.conf
libvirt_type = kvm
# 本机 IP
my_ip=192.168.1.253
# 注意此处路径需存在,且对nova用户具有权限
instances_path=/state/partition1/openstack/instance

#AUTH
auth_strategy = keystone
# 管理节点
rabbit_host=192.168.1.1  # 远程访问主节点上的 rabbitmq 服务
glance_host=192.168.1.1  # 主节点上的 glance 服务
api_paste_config=/etc/nova/api-paste.ini

#NETWORK
dhcpbridge = /usr/bin/nova-dhcpbridge
dhcpbridge_flagfile = /etc/nova/nova.conf
force_dhcp_release = False
injected_network_template = /usr/share/nova/interfaces.template
libvirt_nonblocking = True
libvirt_inject_partition = -1
network_manager = nova.network.manager.FlatDHCPManager
#fixed_range=192.168.100.0/24
#floating_range=192.168.1.0/24
flat_network_bridge = br100
public_interface=eth0
flat_interface=eth0

# 外网 IP
novncproxy_base_url=http://202.38.192.97:6080/vnc_auto.html
# 本机内部 IP
# 设置为本机 IP,不可设置为 127.0.0.1,否则主节点上的 VNC_PROXY 无法访问
vncserver_proxyclient_address=192.168.1.253
vncserver_listen=192.168.1.253

[keystone_authtoken]
admin_tenant_name = service
admin_user = nova
admin_password = nova
auth_host = 192.168.1.1
auth_port = 35357
auth_protocol = http
signing_dir = /tmp/keystone-signing-nova

启动服务

service openstack-nova-compute start # 启动 compute 服务
chkconfig openstack-nova-compute on  # 设置开机自动启动

配置 nova_volume

根据文件创建虚拟设备

dd if=/dev/zero of=nova-volumes.img bs=10M count=1024
vgcreate nova-volumes $(losetup --show -f nova-volumes.img)

启动服务

service tgt start        # 主节点
service nova-volume start
service open-iscsi start # 计算节点

运行虚拟机

注册虚拟机镜像

wget -c https://launchpad.net/cirros/trunk/0.3.0/+download/cirros-0.3.0-x86_64-disk.img \
    -O cirros.img
glance image-create \
    --name=cirros-0.3.0-x86_64 \
    --disk-format=qcow2 \
    --container-format=bare < cirros.img

设置安全组

nova secgroup-add-rule default tcp 22 22 0.0.0.0/0  # 开放 22 端口
nova secgroup-add-rule default icmp -1 -1 0.0.0.0/0 # 开放 ping

添加密钥

nova keypair-add --pub_key ~/.ssh/id_rsa.pub key # 上传 ssh 访问公钥

创建虚拟机

nova boot --flavor 2 --image <cirros的image-id> \
    --key_name=key --security_group default cirros

查看虚拟运行日志

nova console-log

安装和配置 Dashboard

安装 Dashboard

yum install memcached mod-wsgi openstack-dashboard

修改配置文件

/etc/openstack-dashboard/local_settings

CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
SWIFT_ENABLED = False
QUANTUM_ENABLED = False

重启 Apache 服务器

service httpd restart

安装和配置 Swift

主节点

安装

yum install openstack-swift openstack-swift-proxy \
    openstack-swift-account openstack-swift-container \
    openstack-swift-object memcached

修改配置文件

/etc/swift/swift.conf

[swift-hash]
swift_hash_path_suffix = <random string>

创建 SSL 自签名证书

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

配置 proxy-server

/etc/swift/proxy-server.conf

[DEFAULT]
bind_port = 8888
user = demo
[pipeline:main]
pipeline = healthcheck cache swift3 authtoken keystone proxy-server
[app:proxy-server]
use = egg:swift#proxy
allow_account_management = true
account_autocreate = true
[filter:keystone]
paste.filter_factory = keystone.middleware.swift_auth:filter_factory
operator_roles = Member,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 = 127.0.0.1
auth_port = 35357
auth_host = 127.0.0.1
auth_protocol = http
auth_uri = http://127.0.0.1:5000/
auth_token = <keystone 中的 admin_token>
admin_token = <keystone 中的 admin_token>
admin_tenant_name = service
admin_user = swift
admin_password = swift
signing_dir = /etc/swift # notice
[filter:cache]
use = egg:swift#memcache
set log_name = cache
[filter:catch_errors]
use = egg:swift#catch_errors
[filter:healthcheck]
use = egg:swift#healthcheck

创建 account, container, object rings

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

(第二个参数为每个对象复制的个数)

添加每个节点上的存储设备

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

检查每个 ring 中的内容

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

重新平衡 ring

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

复制 account.ring.gz, container.ring.gz 和 object.ring.gz 到存储节点。

确认所以配置文件为swift用户所有

chown -R swift:swift /etc/swift

启动 proxy 服务

swift-init proxy start

存储节点

安装

yum install openstack-swift-account openstack-swift-container \
    openstack-swift-object xfsprogs

配置虚拟磁盘

dd if=/dev/zero of=swift.img bs=10M count=1024
iosetup --show -f swift.img
mkfs.xfs -i size=1024 /dev/loop0
mkdir -p /srv/node/loop0
mount /dev/loop0 /srv/node/loop0
chown -R swift:swift /srv/node

配置 rsync

/etc/rsyncd.conf

uid = swift
gid = swift
log file = /var/log/rsyncd.log
pid file = /var/run/rsyncd.pid
address = <STORAGE_LOCAL_NET_IP>
[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

启动 rsync

rsync --daemon --config=/etc/rsyncd.conf

配置 swift

**/etc/swift/account-server.conf** ::
[DEFAULT] bind_ip = <STORAGE_LOCAL_NET_IP> workers = 2 [pipeline:main] pipeline = account-server [app:account-server] use = egg:swift#account [account-replicator] [account-auditor] [account-reaper]

/etc/swift/account-container.conf

[DEFAULT]
bind_ip = <STORAGE_LOCAL_NET_IP>
workers = 2
[pipeline:main]
pipeline = container-server
[app:container-server]
use = egg:swift#container
[container-replicator]
[container-auditor]
[container-reaper]

/etc/swift/object-server.conf

[DEFAULT]
bind_ip = <STORAGE_LOCAL_NET_IP>
workers = 2
[pipeline:main]
pipeline = object-server
[app:object-server]
use = egg:swift#object
[object-replicator]
[object-updater]
[object-auditor]
[object-expirer]

启动服务

swift-init object-server start
swift-init object-replicator start
swift-init object-updater start
swift-init object-auditor start
swift-init container-server start
swift-init container-replicator start
swift-init container-updater start
swift-init container-auditor start
swift-init account-server start
swift-init account-replicator start
swift-init account-auditor start

验证安装

swift -V 2.0 -A http://127.0.0.1:35357/v2.0 \
    -U demo:admin -K admin stat
swift -V 2.0 -A http://127.0.0.1:35357/v2.0 \
    -U demo:admin -K admin upload myfile <file> # 上传文件
swift -V 2.0 -A http://127.0.0.1:35357/v2.0 \
    -U demo:admin -K admin download myfile # 下载文件

问题分析

  1. 查看日志

    /var/log/ 下的日志信息通常会给出各组件出错的原因,如 数据库的连接和权限问题、消息队列无法连接、网络连接问题、依赖的服务未运行、配置文件错误等。一般启动相应的组件,或修改配置文件中IP和端口可解决问题。

  2. 开启 Debug 模式

    一种方式是修改配置文件,设置 Debug 为 True;另一种是运行命令的时候加入命令行参数 –debug。后者可以显示出在调用哪个API时出错或卡死,根据访问的端口号和API可以判断出是哪个服务,查看相应的日志获取错误信息。

  3. 磁盘空间不足导致的配额不足

    OpenStack各组件需要的空间默认是在 /var/lib 下,也就是和根目录使用同一分区的空间。这会导致空间不足的问题。方法是修改各个组件配置文件中的路径相关参数。或者将其它分区的文件夹挂载到 /var/lib 文件夹下。修改路径后,需要确保新的路径具有合适的访问权限。

  4. Dashboard 的编码问题导致出错

    Dashboard 某些地方对中文的支持有问题,所以运行 Apache 的 httpd 前,可以先将环境设置为英文环境 export LANG=en_US.utf8

  5. 网络的问题

    配置 nova 或启动虚拟机时,nova 可能会更改系统中的网络配置,从而导致服务器之间、服务器与外网间或 VM 与外网间的连接问题。此时应该检查网络设置,通过设置IP、添加NAT或者端口映射的方式解决网络的问题。

  6. 虚拟机无法自动获得 IP

    查看主节点上的 dnsmasq 的运行和设置是否正常。可以尝试关闭 dnsmasq 或重新启动 nova-network。

附A:安装镜像制作

Windows 7

创建虚拟机磁盘

qemu-kvm create -f qcow2 win7.img 10g

下载虚拟机驱动

wget -c \
    http://alt.fedoraproject.org/pub/alt/virtio-win/latest/images/bin/virtio-win-0.1-52.iso

启动虚拟机

qemu-kvm -m 1024 -cdrom windows7.iso \
    -drive file=win7.img,if=virtio \
    -drive file=virtio-win-0.1-52.iso,index=3,media=cdrom \
    -net nic,model=virtio \
    -net user
    -nographic -vnc :0

其中 windows7.iso 为 Win7 安装镜像地址,需从别处下载。然后使用 vncviewer 访问相应 -vnc 选项端口进行系统安装。 安装时,需先加载相应的虚拟驱动,否则无法看到磁盘。 安装后将 win7.img 上传即可。

glance image-create --name="Win7" \
    --is-public=true \
    --container-format=bare \
    --disk-format=qcow2 < win7.img

Ubuntu

创建虚拟磁盘命令同上,无需下载和加载虚拟机驱动镜像,加载安装镜像运行即可

qemu-kvm -m 1024 -cdrom ubuntu.iso \
    -drive file=ubuntu.img,if=virtio \
    -net nic,model=virtio \
    -net user \
    -nographic -vnc :0