磕磕碰碰一周,终于看到了dashboard…谨以此文,记录下各种坑~
环境配置:VirtualBox5.1.12 + ubuntu16.04 + devstack(stable/newton)
https://www.virtualbox.org/
镜像 -> 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的配置如上图,记住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)。
配置完成后,ping应该能成功
官方指导手册 -> http://docs.openstack.org/developer/devstack/
最大的坑是天朝的网络。devstack在安装的时候,需要从git或是pypi上下载大量组件,但这些外网,是很难从我朝访问的。基本晚上7~11点,git和pypi下载的丢包率在20%,传输速率<10KB
$ sudo apt-get install python
$ sudo apt-get install git
$ adduser stack
... type password ...
$ echo "stack ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
$ su stack
git clone https://git.openstack.org/openstack-dev/devstack -b stable/newton
或
git clone https://github.com/openstack-dev/devstack -b stable/newton
推荐从github上下载代码,稍微快那么一丢丢
git clone成功后,看到devstack的目录,在devstack目录下创建local.conf文件,如下配置
ADMIN_PASSWORD=secret
DATABASE_PASSWORD=$ADMIN_PASSWORD
RABBIT_PASSWORD=$ADMIN_PASSWORD
SERVICE_PASSWORD=$ADMIN_PASSWORD
GIT_BASE=http://git.trystack.cn
or
GIT_BASE=https://github.com
NOVA_BRANCH=stable/newton
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
[global]
index-url = https://pypi.doubanio.com/simple
$ ./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$
$ 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