首页 公告 项目 RSS

使用devstack安装openstack

October 12, 2017 本文有 1675 个字 需要花费 4 分钟阅读

概述

早就想用devstack去安装openstack了,但是自己的电脑内存才4g真的太小了,最近上了8g内存,果断开虚拟机装devstack。
devstack的基本概念大家可以去百度这里就不说了
要准备的东西

  • ubuntu16.04
  • Google
  • 网络(最好是移动网,电信的出口带宽真的很快,和断网一样的快)
  • 一部电影(推荐美国派,如果不知道美国派是什么,去百度。因为安装时间很长,所以最好来一部电影消磨时间)
  • virtualbox
  • 一颗坚信可以安装成功的心

devstack不可能会一次性安装完成openstack,所以出错了要学会解决,比如一个软件包不能下载,那么就自己在实体机挂代理下载好然后scp到虚拟机对应的文件夹中,还有要相信我的配置文件,运行一次./stack.sh不行那就再次运行一次,如果还是不行,那么./clean.sh ./unstack.sh,最关键的是要学会谷歌而不是百度,垃圾百度毁一生

安装Ubuntu虚拟机

首先虚拟机的配置能多少高就多少高,网卡选择桥接,之后正常安装ubuntu16.04,不要安装其他服务

配置ubuntu虚拟机

更新一下系统
sudo apt update && sudo apt upgrade
重启系统
之后openssh要安装上,之后在自己的实体机ssh到虚拟机,这样方便复制,还有git也要安装上。
sudo apt install openssh-server
sudo apt install git
接着给root用户设置密码
sudo passwd root
配置openssh使root用户可以登录
修改
sudo vim /etc/ssh/sshd_config
PermitRootLogin 修改为yes
之后重启ssh服务,在实体机用root登录
sudo service ssh restart

创建openstack用户,并且配置

创建用户
sudo useradd -s /bin/bash -d /opt/stack -m stack
让stack用户在使用sudo的时候不需要密码
echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack
切换到stack用户
sudo su - stack

安装下载devstack

因为国内的环境问题,所以下载的时候推荐使用trystack.cn的镜像
先创建一个文件夹
mkdir openstack
cd openstack/
git clone http://git.trystack.cn/openstack-dev/devstack

修改local.conf文件

cd devstack/
创建local.conf
touch local.conf

[[local|localrc]]

# use TryStack git 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

#OFFLINE=True
RECLONE=True

# Define images to be automatically downloaded during the DevStack built process.
DOWNLOAD_DEFAULT_IMAGES=False
IMAGE_URLS="http://download.cirros-cloud.net/0.3.5/cirros-0.3.5-x86_64-disk.img"

HOST_IP=192.168.1.107


# Credentials
DATABASE_PASSWORD=passwd
ADMIN_PASSWORD=passwd
SERVICE_PASSWORD=passwd
SERVICE_TOKEN=passwd
RABBIT_PASSWORD=passwd

HORIZON_BRANCH=master
KEYSTONE_BRANCH=master
NOVA_BRANCH=master
NEUTRON_BRANCH=master
GLANCE_BRANCH=master
CINDER_BRANCH=master


#keystone
KEYSTONE_TOKEN_FORMAT=UUID

##Heat
HEAT_BRANCH=master
enable_service h-eng h-api h-api-cfn h-api-cw


## Swift
SWIFT_BRANCH=master
ENABLED_SERVICES+=,s-proxy,s-object,s-container,s-account
SWIFT_REPLICAS=1
SWIFT_HASH=011688b44136573e209e


# Enabling Neutron (network) Service
disable_service n-net
enable_service q-svc
enable_service q-agt
enable_service q-dhcp
enable_service q-l3
enable_service q-meta
enable_service q-metering
enable_service neutron

## Neutron options
Q_USE_SECGROUP=True
FLOATING_RANGE="192.168.1.0/24"
FIXED_RANGE="10.0.0.0/24"
Q_FLOATING_ALLOCATION_POOL=start=192.168.1.102,end=192.168.1.110
PUBLIC_NETWORK_GATEWAY="192.168.1.2"
Q_L3_ENABLED=True
PUBLIC_INTERFACE=eth0
Q_USE_PROVIDERNET_FOR_PUBLIC=True
OVS_PHYSICAL_BRIDGE=br-ex
PUBLIC_BRIDGE=br-ex
OVS_BRIDGE_MAPPINGS=public:br-ex

# #VLAN configuration.
Q_PLUGIN=ml2
ENABLE_TENANT_VLANS=True

# Logging
LOGFILE=/opt/stack/logs/stack.sh.log
VERBOSE=True
LOG_COLOR=True
SCREEN_LOGDIR=/opt/stack/logs

下面这三句话是使用trystack.cn的openstack镜像的意思

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

上面这个配置文件有几个地方是要你去修改的
HOST_IP=192.168.1.107 你的主机ip

DATABASE_PASSWORD=passwd
ADMIN_PASSWORD=passwd
SERVICE_PASSWORD=passwd
SERVICE_TOKEN=passwd
RABBIT_PASSWORD=passwd

上面是一些openstack dashboard或者数据库等密码

HORIZON_BRANCH=master
KEYSTONE_BRANCH=master
NOVA_BRANCH=master
NEUTRON_BRANCH=master
GLANCE_BRANCH=master
CINDER_BRANCH=master

上面的master表示你下载的openstack所在的git分支,使用master就好了
SWIFT_BRANCH=master
HEAT_BRANCH=master
这上面两个参数也同理
FLOATING_RANGE="192.168.1.0/24"
这个参数的ip地址要和你的主机的ip地址处于同一网段
其他的参数自己研究把,反正不影响安装,记住百度很重要

安装

在这下面我会把我安装的时候碰到的错误详细的说出来
首先执行
./stack.sh
同志们,长征开始了

第一个报错

fatal: unable to access 'http://git.trystack.cn/openstack/requirements.git/': Failed to connect to git.trystack.cn port 80: Connection timed out
很明显的网络问题,我的方法是把local.conf中

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

注释掉,在每一行前面加上#就好了
接着运行./stack.sh

第二个错误

2017-10-12 03:01:19.251 | ++functions:get_extra_file:66               wget --progress=dot:giga -c https://github.com/coreos/etcd/releases/download/v3.1.7/etcd-v3.1.7-linux-amd64.tar.gz -O /opt/stack/openstack/devstack/files/etcd-v3.1.7-linux-amd64.tar.gz
2017-10-12 03:01:19.262 | --2017-10-12 11:01:19--  https://github.com/coreos/etcd/releases/download/v3.1.7/etcd-v3.1.7-linux-amd64.tar.gz
2017-10-12 03:01:19.275 | Resolving github.com (github.com)... 192.30.255.112, 192.30.255.113
2017-10-12 03:01:19.598 | Connecting to github.com (github.com)|192.30.255.112|:443... connected.
2017-10-12 03:01:20.575 | HTTP request sent, awaiting response... 302 Found
2017-10-12 03:01:20.576 | Location: https://github-production-release-asset-2e65be.s3.amazonaws.com/11225014/47a40780-2bfa-11e7-97bb-1a35d6126f1a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20171012%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20171012T030120Z&X-Amz-Expires=300&X-Amz-Signature=5b71e579773819ff1a9eba0bc13ed9d8e6aaf5d42d6a2c0a23c2cec939d1f7ed&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Detcd-v3.1.7-linux-amd64.tar.gz&response-content-type=application%2Foctet-stream [following]
2017-10-12 03:01:20.577 | --2017-10-12 11:01:20--  https://github-production-release-asset-2e65be.s3.amazonaws.com/11225014/47a40780-2bfa-11e7-97bb-1a35d6126f1a?X-Amz-Algorithm=AWS4-HMAC-SHA256&X-Amz-Credential=AKIAIWNJYAX4CSVEH53A%2F20171012%2Fus-east-1%2Fs3%2Faws4_request&X-Amz-Date=20171012T030120Z&X-Amz-Expires=300&X-Amz-Signature=5b71e579773819ff1a9eba0bc13ed9d8e6aaf5d42d6a2c0a23c2cec939d1f7ed&X-Amz-SignedHeaders=host&actor_id=0&response-content-disposition=attachment%3B%20filename%3Detcd-v3.1.7-linux-amd64.tar.gz&response-content-type=application%2Foctet-stream
2017-10-12 03:01:20.586 | Resolving github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)... 52.216.232.11
2017-10-12 03:01:21.051 | Connecting to github-production-release-asset-2e65be.s3.amazonaws.com (github-production-release-asset-2e65be.s3.amazonaws.com)|52.216.232.11|:443... connected.
2017-10-12 03:01:43.524 | Unable to establish SSL connection.

明显又是网络问题
我只要把etcd-v3.1.7-linux-amd64.tar.gz这个包在实体机挂代理下载过来放到/opt/stack/openstack/devstack/files/下就好了
proxychains wget https://github.com/coreos/etcd/releases/download/v3.1.7/etcd-v3.1.7-linux-amd64.tar.gz
scp etcd-v3.1.7-linux-amd64.tar.gz [email protected]:/opt/stack/openstack/devstack/files/
接着运行./stack.sh

最后

幸运的是我碰到的问题不是特别多,而且当你看到下面的样子的时候你的openstack就已经安装完成了
但是安装的时间是真的长,一部电影看样子是不够了,幸好美国派不只有一部


=========================
DevStack Component Timing
=========================
Total runtime    6490

run_process       34
test_with_retry    3
apt-get-update    12
pip_install      382
osc              298
wait_for_service  54
git_timed        4013
dbsync            42
apt-get          787
=========================



This is your host IP address: 192.168.1.107
This is your host IPv6 address: ::1
Horizon is now available at http://192.168.1.107/dashboard
Keystone is serving at http://192.168.1.107/identity/
The default users are: admin and demo
The password: passwd

WARNING: 
Using lib/neutron-legacy is deprecated, and it will be removed in the future
With the removal of screen support, tail_log is deprecated and will be removed after Queens


Services are running under systemd unit files.
For more information see: 
https://docs.openstack.org/devstack/latest/systemd.html

DevStack Version: pike
Change: f56a0ae2eca9c5d77799d85b57ea7dbb7cf601dc Merge "Fix devstack python detection if python3 is missing" 2017-09-14 23:42:06 +0000
OS Version: Ubuntu 16.04 xenial

之后,你可以用浏览器去访问你的openstack dashboard
只要输入你的虚拟机ip地址就可以

登录之后的样子

欢迎关注我的博客www.bboy.app
Have Fun