前言

先前总结了 OpenStack 部署方式,然后就开始上手进行实验,使用 Packstack 可以说是其中最简单的安装方式了,虽然也折腾了很久,但遇到的错误是相对最少的。

由于在 VirtualBox 上安装 CentOS 8 失败,于是就用 CentOS 7 作为实验环境,测试安装了两个版本的 OpenStack(Train/Stein)都没有问题,以下总结了使用 Packstack 部署 OpenStack 的流程。

环境准备

使用 VirtualBox 安装 CentOS 7 Minimal ,配置如下:

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

配置端口转发

ssh

修改配置文件,允许 root 用户使用密码远程登录

1
2
3
4
5
6
7
8
9
# 修改配置文件
vi /etc/ssh/sshd_config

# 激活以下两个配置
PermitRootLogin yes
PasswordAuthentication yes

# 重启 ssh 服务器
sudo systemctl restart sshd.service

安装 pip 并更换 pip 源

CentOS 7 自带 Python 2.7.5 ,但 pip 需要额外安装

1
2
3
4
5
# 添加 epel 仓库
sudo yum install epel-release

# 安装 pip
sudo yum install python-pip

pip 21.0 不支持 Python 2.7 ,所以得安装一个版本低一点的,否则无法使用

1
2
3
4
5
# 升级 pip
pip install --upgrade "pip < 21.0"

# pip 镜像源
pip config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple

更换 yum 源

配置阿里云 yum 源加速

1
2
3
4
5
6
7
8
9
10
11
12
13
14
# 备份原始文件
mv /etc/yum.repos.d/CentOS-Base.repo /etc/yum.repos.d/CentOS-Base.repo.bk

# 添加阿里云 yum 镜像源
wget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-7.repo

# 清理缓存
yum clean all

# 生成缓存
yum makecache

# 更新
yum update -y

防火墙与网络配置

关闭 firewalld、NetworkManager、SELinux,启用 network

  • 禁止开机自启
1
2
3
4
5
6
7
8
9
10
11
sudo systemctl disable firewalld
sudo systemctl stop firewalld

sudo systemctl disable NetworkManager
sudo systemctl stop NetworkManager

sudo systemctl enable network
sudo systemctl start network

sudo setenforce 0
sudo sed -i 's/^SELINUX=.*/SELINUX=permissive/g' /etc/selinux/config

Packstack 安装

添加相应的 OpenStack 仓库

1
2
3
4
# 添加仓库
sudo yum update -y
sudo yum install -y centos-release-openstack-train
# sudo yum install -y centos-release-openstack-stein

安装 Packstack

1
2
3
# 安装 Packstack
sudo yum update -y
sudo yum install -y openstack-packstack

单机部署

1
2
# 安装 OpenStack
sudo packstack --allinone

访问服务

安装完毕后,使用浏览器访问 horizon

命令行查看已安装服务(asciinema

问题解决

error while loading shared libraries: leatherman_curl.so.1.3.0

安装 OpenStack 的过程中报错,原因是使用的 leatherman 版本不兼容,降级后再次执行安装即可

1
2
# 降级 leatherman
sudo yum downgrade -y leatherman

主机上无法访问 Horizon

直接在浏览器输入 http://127.0.0.1:8899/dashboard 返回 302 错误,原因是访问该路径时会进行一次重定向,而 127.0.0.1 不是服务器的有效别名,修改配置添加别名即可。

PS:因为这个我还重装了好几次,没想到后来添加一个别名就好了xddd

1
2
3
4
5
6
7
# 编辑配置文件
vi /etc/httpd/conf.d/15-horizon_vhost.conf
# 添加别名
ServerAlias 127.0.0.1

# 重启 http 服务
service httpd restart

参阅