环境准备

DevStack 支持最新的 Ubuntu 长期支持版本、 CentOS/RHEL 8 以及 OpenSUSE ,Ubuntu 18.04 (Bionic Beaver) 是经过最多测试的推荐。

使用 VirtualBox 安装 Ubuntu 18.04.5 ,配置如下:

  • CPU:4 Cores
  • 内存:8 GB
  • 硬盘:100 GB
  • 网卡:NAT

更换 pip 源

在用户根目录创建文件夹 .pip ,添加配置文件 pip.conf

1
2
3
4
5
# 创建文件夹
cd && mkdir .pip && cd .pip

# 创建并编辑配置文件
sudo vim pip.conf

pip 源配置如下

1
2
3
4
[global]
timeout = 6000
index-url = http://mirrors.aliyun.com/pypi/simple/
trusted-host = mirrors.aliyun.com

更换 Ubuntu 源

备份源文件,再替换成清华的镜像源

1
2
3
4
5
6
7
8
# 备份
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bk

# 设置镜像源
sudo vim /etc/apt/sources.list

# 更新
sudo apt update

镜像源设置如下

1
2
3
4
5
6
7
8
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-updates main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-backports main restricted universe multiverse
deb https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse
deb-src https://mirrors.tuna.tsinghua.edu.cn/ubuntu/ bionic-security main restricted universe multiverse

添加用户

DevStack 应该以非 root 用户(但拥有 sudo 权限)执行,手动添加 stack 用户

1
2
3
4
5
6
7
8
# 添加 stack 用户
sudo useradd -s /bin/bash -d /opt/stack -m stack

# 授予 sudo 权限
echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack

# 以 stack 用户登录
sudo su - stack

DevStack 部署 OpenStack

下载 DevStack

使用 -b 指定下载的版本,这里选择下载 Ussuri 版本

1
2
3
4
5
6
7
# 下载 DevStack
# git clone https://opendev.org/openstack/devstack -b stable/ussuri
# git clone https://github.com/openstack/devstack -b stable/ussuri
git clone https://github.com.cnpmjs.org/openstack/devstack -b stable/ussuri

# 进入文件夹
cd devstack

创建配置文件 local.conf

在目录下创建 local.conf 配置文件

  • ADMIN_PASSWORD:OpenStack 用户 admindemo 的密码
  • DATABASE_PASSWORD:MySQL 管理员用户密码
  • RABBIT_PASSWORD:RabbitMQ 密码
  • SERVICE_PASSWORD:服务组件和 KeyStone 交互的密码
  • GIT_BASE:源代码托管服务器
  • HOST_IP:绑定的 IP 地址
1
2
3
4
5
6
7
8
[[local|localrc]]
HOST_IP=10.0.2.15
GIT_BASE=https://github.com.cnpmjs.org

ADMIN_PASSWORD=password
DATABASE_PASSWORD=$ADMIN_PASSWORD
RABBIT_PASSWORD=$ADMIN_PASSWORD
SERVICE_PASSWORD=$ADMIN_PASSWORD

开始安装

执行目录下的脚本开始自动安装

1
2
3
4
5
6
7
8
# 安装
./stack.sh

# 停止 DevStack
./unstack.sh

# 停止 DevStack 并删除配置文件等
./clean.sh

安装时间根据网络状况而定(我试了好几天xdd)以下是成功安装后输出的信息

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
...
=========================
DevStack Component Timing
(times are in seconds)
=========================
run_process 36
test_with_retry 4
apt-get-update 46
osc 138
wait_for_service 16
dbsync 78
pip_install 678
apt-get 7
-------------------------
Unaccounted time 1720
=========================
Total runtime 2723



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

WARNING:
Using lib/neutron-legacy is deprecated, and it will be removed in the future


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

DevStack Version: ussuri
Change: a6ede1b7a6e1698b3820b4c992e7cbce36b9acd5 Remove tempest deprecated img_dir option 2021-01-13 09:32:31 +0000
OS Version: Ubuntu 18.04 bionic

2021-02-05 04:06:28.733 | stack.sh completed in 2724 seconds.
stack@ubuntu1804:~/devstack$

在 NAT 模式下配置端口转发无法访问 Horizon,还没找到配置文件虚拟机就出问题了… 解决方法应当和使用 PackStack 安装时相同:主机上无法访问 Horizon

参阅