VirtualBox + DevStack 2016-12-31

磕磕碰碰一周,终于看到了dashboard…谨以此文,记录下各种坑~
环境配置:VirtualBox5.1.12 + ubuntu16.04 + devstack(stable/newton)

  • VirtualBox
    • 下载安装
    • 安装ubuntu1604
    • 虚拟机配置
  • devstack
    • 准备
    • 下载devstack代码
    • 配置localconf
    • 运行devstack


VirtualBox

下载,安装

https://www.virtualbox.org/

安装ubuntu16.04。

镜像 -> https://www.ubuntu.com/download/desktop/contribute?version=16.04.1&architecture=amd64
当然,你也可以装个麒麟操作系统 -> http://www.ubuntukylin.com/downloads/

虚拟机配置

最关键的是网络配置。创建虚拟机的时候,virtualbox会创建一个网卡1,使用NAT方式与外部通信。在部署devstack的时候,个人比较推荐添加另一个网卡,用于host(windows)和guest(ubuntu)的通信。

  • 网络

VirtualBox + DevStack 2016-12-31_第1张图片
virtualbox的配置如上图,记住mac地址,后面需要根据这个mac地址去ubuntu下配置网卡ip。在host(windows)上,给Host-Only Network#2, 配上ip地址192.168.152.1。在guest(ubuntu)上,找到mac是08:00:27:39:D5:CB的网卡,配上ip地址192.168.152.101(之后dashboard也会使用这个ip)。
VirtualBox + DevStack 2016-12-31_第2张图片
VirtualBox + DevStack 2016-12-31_第3张图片
配置完成后,ping应该能成功
VirtualBox + DevStack 2016-12-31_第4张图片

  • 系统
    下面配置勉强够跑devstack,ε=ε=ε=(~ ̄▽ ̄)~
    处理器数量:2
    内存 :4096MB
    运行峰值 :100%
    硬件加速 :VT-x/AMD-V 嵌套分页

devstack

官方指导手册 -> http://docs.openstack.org/developer/devstack/
最大的坑是天朝的网络。devstack在安装的时候,需要从git或是pypi上下载大量组件,但这些外网,是很难从我朝访问的。基本晚上7~11点,git和pypi下载的丢包率在20%,传输速率<10KB

准备

  • ubuntu 源,如果觉得慢,可以使用163或者aliyun的源
  • python 2.7,ubuntu 16.04默认安装,若手动安装
$ sudo apt-get install python
  • git
$ sudo apt-get install git
  • 创建stack用户
$ adduser stack
... type password ...

$ echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
$ su stack

下载devstack代码

git clone https://git.openstack.org/openstack-dev/devstack -b stable/newton

git clone https://github.com/openstack-dev/devstack -b stable/newton

推荐从github上下载代码,稍微快那么一丢丢

配置local.conf

git clone成功后,看到devstack的目录,在devstack目录下创建local.conf文件,如下配置

  • 密码配置
    随便配,看心情
ADMIN_PASSWORD=secret
DATABASE_PASSWORD=$ADMIN_PASSWORD
RABBIT_PASSWORD=$ADMIN_PASSWORD
SERVICE_PASSWORD=$ADMIN_PASSWORD
  • git仓库
    devstack默认会从https://git.openstack.org上下载openstack组件,那是相当的慢。故在local.conf必须要把仓库替换成其他源,国内推荐git.trystack.cn。注意,trystack用的是http,不是https
GIT_BASE=http://git.trystack.cn
or
GIT_BASE=https://github.com
  • branch
    保证与devstack的branch一直,避免不可预知的问题
NOVA_BRANCH=stable/newton
  • Service/Dashboard IP
HOST_IP=192.168.152.101

完整配置如下(还配了heat组件)

[[local|localrc]]
ADMIN_PASSWORD=secret
DATABASE_PASSWORD=$ADMIN_PASSWORD
RABBIT_PASSWORD=$ADMIN_PASSWORD
SERVICE_PASSWORD=$ADMIN_PASSWORD

# Branches
KEYSTONE_BRANCH=stable/newton
NOVA_BRANCH=stable/newton
NEUTRON_BRANCH=stable/newton
SWIFT_BRANCH=stable/newton
GLANCE_BRANCH=stable/newton
CINDER_BRANCH=stable/newton

# Use mirror
GIT_BASE=http://git.trystack.cn
NOVNC_REPO=http://git.trystack.cn/kanaka/noVNC.git
SPICE_REPO=http://git.trystack.cn/git/spice/spice-html5.git

# Enable heat services
enable_service h-eng h-api h-api-cfn h-api-cw

# Enable heat plugin
enable_plugin heat http://git.trystack.cn/openstack/heat.git stable/newton

IMAGE_URL_SITE="http://download.fedoraproject.org"
IMAGE_URL_PATH="/pub/fedora/linux/releases/25/CloudImages/x86_64/images/"
IMAGE_URL_FILE="Fedora-Cloud-Base-25-1.3.x86_64.qcow2"
IMAGE_URLS+=","$IMAGE_URL_SITE$IMAGE_URL_PATH$IMAGE_URL_FILE

# Service/Dashboard IP
FLOATING_RANGE=192.168.1.224/27
HOST_IP=192.168.152.101
FLAT_INTERFACE=enp0s8
  • pypi源
    devstack默认python源为https://pypi.python.org,天朝访问非常慢。可以从https://www.pypi-mirrors.org/选一个国内的镜像,把镜像地址写到pip.conf文件,并放到/root/.pip/pip.conf以及/home/stack/.pip/pip.conf
[global]
index-url = https://pypi.doubanio.com/simple

运行devstack

  • 运行
$ ./stack.sh

... wait for some time ...

=========================
DevStack Component Timing
=========================
Total runtime         1555

run_process            78
test_with_retry         5
apt-get-update          9
pip_install           219
restart_apache_server  28
wait_for_service       23
git_timed              26
apt-get                12
=========================



This is your host IP address: 192.168.152.101
This is your host IPv6 address: ::1
Horizon is now available at http://192.168.152.101/dashboard
Keystone is serving at http://192.168.152.101/identity/
The default users are: admin and demo
The password: secret
2016-12-31 00:53:31.222 | WARNING:
2016-12-31 00:53:31.223 | Using lib/neutron-legacy is deprecated, and it will be removed in the future
2016-12-31 00:53:31.225 | stack.sh completed in 1555 seconds.
stack@exxucao-VirtualBox:~/devstack$
  • dashboard
    运行结束后,会看到屏幕提示dashboard在http://192.168.152.101/dashboard,但此时用浏览器去访问dashboard会提示Internal Server Error
    VirtualBox + DevStack 2016-12-31_第5张图片
    这是因为此时dashboard并不允许通过192.168.152.101访问,需要手动把ip地址加到local_settings.py里的ALLOWED_HOSTS字段
$ vim /opt/stack/horizon/openstack_dashboard/local/local_settings.py
# If horizon is running in production (DEBUG is False), set this
# with the list of host/domain names that the application can serve.
# For more information see:
# https://docs.djangoproject.com/en/dev/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ['*']

重启apache2服务

$ sudo service apache2 restart

VirtualBox + DevStack 2016-12-31_第6张图片
使用admin/secret登陆,就能看到
VirtualBox + DevStack 2016-12-31_第7张图片

你可能感兴趣的:(devstack)