非生产环境,仅学习用。
实验环境
- Ubuntu Server 20.04 LTS
- Ubuntu 20.04 LTS
准备工作
内存配足了
不管实机虚机,内存≥6G。
血的教训,4G内存装一半就报错,本以为安装文件配置问题,结果偶然发现Out of memory: Killed process 79546 (mysqld)
。记录查错的多种命令:
sudo egrep -i -r 'killed process' /var/log
dmesg | grep -i 'out of memory'
sudo journalctl -kx | grep -i 'out of memory'
创建用户 stack
sudo useradd -s /bin/bash -d /opt/stack -m stack
echo "stack ALL=(ALL) NOPASSWD: ALL" | sudo tee /etc/sudoers.d/stack
sudo su - stack
下载DevStack
git clone http://git.trystack.cn/openstack/devstack
cd devstack
修改pypi国内镜像
pip3 config set global.index-url https://pypi.tuna.tsinghua.edu.cn/simple
否则容易pip失败。
修改ebtables的指向
sudo update-alternatives --set ebtables /usr/sbin/ebtables-legacy || true
否则对于Ubuntu 20.04会报错table 'broute' is incompatible, use 'nft' tool
。
据说是Ubuntu 20.04才会出现的问题,18.04无此问题。感谢How to Install OpenStack on Ubuntu 18.04 with DevStack文后的回复者Gyan。
安装DevStack
单节点模式single-node
创建local.conf文件
cat <<EOF > local.conf
[[local|localrc]]
HOST_IP=192.168.127.132
LOGFILE=/opt/stack/logs/stack.sh.log
ADMIN_PASSWORD=secret
DATABASE_PASSWORD=$ADMIN_PASSWORD
RABBIT_PASSWORD=$ADMIN_PASSWORD
SERVICE_PASSWORD=$ADMIN_PASSWORD
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
以下三行似乎没必要,没用他们也安装成功了,做个记录:
Q_PLUGIN=ml2
ENABLE_TENANT_VLANS=True
ML2_VLAN_RANGES=physnet1:1000:2000
开始安装
./stack.sh
如遇到问题,跳至Troubleshooting。
成功!
=========================
DevStack Component Timing
(times are in seconds)
=========================
wait_for_service 26
pip_install 136
apt-get 8
run_process 72
dbsync 45
apt-get-update 3
test_with_retry 3
osc 196
-------------------------
Unaccounted time 657
=========================
Total runtime 1146
This is your host IP address: 192.168.0.109
This is your host IPv6 address: ::1
Horizon is now available at http://192.168.0.109/dashboard
Keystone is serving at http://192.168.0.109/identity/
The default users are: admin and demo
The password: secret
Services are running under systemd unit files.
For more information see:
https://docs.openstack.org/devstack/latest/systemd.html
DevStack Version: victoria
Change: 1f8109ac29c6222fea2f02ffd487701de29e2355 Merge "Further py2 cleanup for Fedora" 2020-09-19 11:36:12 +0000
OS Version: Ubuntu 20.04 focal
2020-09-23 02:51:43.021 | stack.sh completed in 1148 seconds.
Troubleshooting
github etcd
无法下载,走梯子。
curl -x http://192.168.127.1:58591 -fsSL https://github.com/etcd-io/etcd/releases/download/v3.3.12/etcd-v3.3.12-linux-amd64.tar.gz -o /opt/stack/devstack/files/etcd-v3.3.12-linux-amd64.tar.gz
- 提示pip版本不够新
出现如下警示,然后就报错停止。试着运行./stack.sh
重装,应能解决。
WARNING: You are using pip version 20.2.2; however, version 20.2.3 is available.
You should consider upgrading via the '/opt/stack/tempest/.tox/tempest/bin/python -m pip install --upgrade pip' command.
- 反复遇到
Failure creating NET_ID for private
问题
清理以后再多装几次。
./unstack.sh
./clean.sh
./stack.sh
之前google baidu bing了n多,该有的ML2_VLAN_RANGES=physnet1:1000:2000
、vni_ranges = 1:1000
之类也都搞了,再安装依然报同样错。特别感谢通过devstack,在Vmware中使用Centos7快速安装体验openstack(单节点安装)作者提到的卸载再装的方法。
推测其他一些难解的问题也可以尝试该法。
- 其他错误
做好心理准备,安装过程可能产生各种错误,然后就自己停下来。如果不是上面几种错误,可以简单尝试重装1..2..n次,具体几次,是个玄学。
使用
网页版
开端口
本机访问跳过此步骤。
sudo ufw allow 80/tcp
访问
http://192.168.127.132/dashboard
用户名:admin 或 demo
密码:secret
命令行cli
当前用户为stack的情况下:
source ~/devstack/openrc admin admin
# 查看指令清单
openstack command list
创建volume group
Cinder将LVM作为默认的volume provider(backend),查看/etc/cinder/cinder.conf
得知已经配置了lvmdriver-1
的volume backend,其volume group名为stack-volumes-lvmdriver-1
。
Devstack并未创建volume group,因此需手工创建。
vmware添加一个scsi硬盘
加好后重启验证:
sudo fdisk -l
Disk /dev/sdb: 2 GiB, 2147483648 bytes, 4194304 sectors
创建physical volume /dev/sdb
sudo pvcreate /dev/sdb
Physical volume "/dev/sdb" successfully created.
创建volume group stack-volumes-lvmdriver-1
sudo vgcreate stack-volumes-lvmdriver-1 /dev/sdb
Volume group "stack-volumes-lvmdriver-1" successfully created
重启cinder volume服务
前面都创建好了,就差重加载了。
sudo systemctl restart devstack@c-vol.service
Troubleshooting
Host '...' is not mapped to any cell
Controller node 上,使用stack用户执行:
nova-manage cell_v2 discover_hosts --verbose
参考链接:
DevStack
openstack学习之devstack安装
devstack安装使用openstack常见问题与解决办法
How to Install OpenStack on Ubuntu 18.04 with DevStack
通过devstack,在Vmware中使用Centos7快速安装体验openstack(单节点安装)
TryStack Git Mirror
Multi-Node Lab
devstack fails while running ./stack.sh in master/queens in ubuntu 16.04 while starting n-cpu
Linux进程被杀掉(OOM killer),查看系统日志
OpenStack报错:Host is not mapped to any cell