官方安装文档
Single node OpenStack on your workstation
重要参考文章
变通方式重设外网卡10.20.20.0/24
虚拟机 2 CPU , 16 G RAM
网卡 eth0: 192.168.0.121
网卡 eth1: 不设 IP
Ubuntu 20.04
snap 安装
sudo snap install microstack --beta
或者
sudo snap install microstack --devmode --beta
可以 snap list 确认一下
初始化
sudo microstack init --auto --control
这一步会完成这些服务:
Glance (Image service),
Horizon (Dashboard),
Keystone (Security),
Neutron (Network)
Nova (Compute).
暂时不要执行 3. Launch an instance
执行也没有关系,后续操作会先删除
获取 dashboard 登录密码
sudo snap get microstack config.credentials.keystone-password
得到 admin 登录密码
sq2UB6aIXK28QJXBcz0azgnCFBy09Xa5
设置 CLI 命令别名
openstack 命令:
sudo snap alias microstack.openstack openstack
网络命令 ovs-vsctl:
sudo snap alias microstack.ovs-vsctl ovs-vsctl
获取外网物理设备名称(dashboard 设置 flat 外网时用)
sudo ovs-vsctl get open . external_ids:ovn-bridge-mappings | awk -F: '{gsub("\"","");; print $1}'
一般都是 : physnet1
据说是 10.20.20.1 写死了,咱也找一下
root@ubuntu2004-121:/snap# cat ./microstack/245/bin/set-default-config.py
./microstack/245/bin/set-default-config.py: 'config.network.ext-gateway': '10.20.20.1',
./microstack/245/bin/set-default-config.py: 'config.network.control-ip': '10.20.20.1',
./microstack/245/bin/set-default-config.py: 'config.network.compute-ip': '10.20.20.1',
./microstack/245/bin/set-default-config.py: 'config.network.ext-cidr': '10.20.20.1/24',
./microstack/245/lib/python3.8/site-packages/init/main.py: 'Falling back on 10.20.20.1')
./microstack/245/lib/python3.8/site-packages/openstackclient/tests/unit/network/v2/test_subnet.py: 'nexthop': '10.20.20.1'},
./microstack/245/lib/python3.8/site-packages/openstackclient/tests/unit/network/v2/test_subnet.py: 'nexthop': '10.20.20.1'}],
./microstack/245/lib/python3.8/site-packages/openstackclient/tests/unit/network/v2/test_subnet.py: 'nexthop': '10.20.20.1'}],
./microstack/245/lib/python3.8/site-packages/openstackclient/tests/unit/network/v2/test_subnet.py: 'nexthop': '10.20.20.1'}],
./microstack/245/lib/python3.8/site-packages/openstackclient/tests/unit/network/v2/test_subnet.py: 'nexthop': '10.20.20.1'},
./microstack/245/lib/python3.8/site-packages/openstackclient/tests/unit/network/v2/test_subnet.py: "destination": "10.20.20.0/24", "nexthop": "10.20.20.1"}],
./microstack/245/templates/05_snap_tweaks.j2:OPENSTACK_HOST = "10.20.20.1"
./microstack/245/templates/05_snap_tweaks.j2: 'LOCATION': '10.20.20.1:11211',
./microstack/245/usr/share/mysql/charsets/hp8.xml: 10 20 20 10 10 10 10 10 10 10 10 10 10 10 10 10
root@ubuntu2004-121:/snap# cat ./microstack/245/bin/set-default-config.py
#!/usr/bin/env python3
import os
import socket
from init import shell
from init import credentials
def _get_default_config():
snap_common = os.getenv('SNAP_COMMON')
return {
'config.is-clustered': False,
'config.cluster.tls-cert-path':
f'{snap_common}/etc/cluster/tls/cert.pem',
'config.cluster.tls-key-path':
f'{snap_common}/etc/cluster/tls/key.pem',
'config.cluster.fingerprint': 'null',
'config.cluster.hostname': 'null',
'config.cluster.credential-id': 'null',
'config.cluster.credential-secret': 'null',
'config.post-setup': True,
'config.keystone.region-name': 'microstack',
'config.credentials.key-pair': '/home/{USER}/snap/{SNAP_NAME}'
'/common/.ssh/id_microstack',
'config.network.node-fqdn': socket.getfqdn(),
'config.network.dns-servers': '1.1.1.1',
'config.network.dns-domain': 'microstack.example.',
'config.network.ext-gateway': '10.20.20.1',
'config.network.control-ip': '10.20.20.1',
'config.network.compute-ip': '10.20.20.1',
'config.network.ext-cidr': '10.20.20.1/24',
......
按照 变通方式重设外网卡10.20.20.0/24 操作,删除前面安装时常见的 test 虚拟机、external 网卡和 test 网卡
eth0 连接到 br-ex
sudo ovs-vsctl add-port br-ex eth0
这两步最好在一行命令完成
sudo ip addr flush dev eth0
sudo ip addr add 192.168.0.121/24 dev br-ex
合并后:
sudo ip addr flush dev eth0 && sudo ip addr add 192.168.0.121/24 dev br-ex
br-ex 已经存在并启动,这一步不需要
sudo ip link set br-ex up
查看当前 IP
$ ip a
......
2: eth0: mtu 1500 qdisc mq master ovs-system state UP group default qlen 1000
link/ether 00:15:5d:5a:a6:60 brd ff:ff:ff:ff:ff:ff
3: eth1: mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 00:15:5d:5a:a6:61 brd ff:ff:ff:ff:ff:ff
4: ovs-system: mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether f6:77:a1:b8:f3:d9 brd ff:ff:ff:ff:ff:ff
5: br-ex: mtu 1500 qdisc noqueue state UNKNOWN group default qlen 1000
link/ether 00:15:5d:5a:a6:60 brd ff:ff:ff:ff:ff:ff
inet 10.20.20.1/24 scope global br-ex
valid_lft forever preferred_lft forever
inet 192.168.0.121/24 scope global br-ex
valid_lft forever preferred_lft forever
inet6 fe80::ac6b:41ff:fe3e:964c/64 scope link
valid_lft forever preferred_lft forever
6: br-int: mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether a2:81:9b:cb:7b:40 brd ff:ff:ff:ff:ff:ff
......
现在 br-ex 链接了 2 个网卡
00:15:5d:5a:a6:60 对应刚刚增加的 eth0
dashboard 重新设置网卡和路由
创建外网
外网子网
IP分配范围
创建内网和路由
创建过程(略)
创建路由结果
测试一下
microstack 安装已经设置了 ICMP 和 SSH 安全策略,无需再设置
如果这个路由器 ping 不通,那就是外网不对,请重新尝试!
$ ping 192.168.0.25
PING 192.168.0.25 (192.168.0.25) 56(84) bytes of data.
64 bytes from 192.168.0.25: icmp_seq=1 ttl=254 time=1.01 ms
64 bytes from 192.168.0.25: icmp_seq=2 ttl=254 time=1.20 ms
......
开始我这里一直报错,害得我重复好多次
Error: Failed to perform requested operation on instance "test-vm", the instance has an error status: Please try again later [Error: Build of instance 431c5dee-8f7c-48e0-81d0-e1c8d92ed76f aborted: Invalid input received: Invalid image identifier or unable to access requested image. (HTTP 400) (Request-ID: req-98871a6d-7795-4bfb-9828-a75cb130b8bc)].
仔细阅读官方操作 Launch instances through the OpenStack dashboard
注意: Create New Volume - Choose No
其他步骤(略)
按照 变通方式重设外网卡10.20.20.0/24 中加入一个 service 的方法,经过几次测试,总是不成功!
按照他的文章建立 microstack-br-workaround 和 microstack-br-workaround.service 文件
抄录一下
编写服务脚本
$ cat /usr/local/bin/microstack-br-workaround
#!/bin/bash
#
# Workaround to enable physical network access to MicroStack
#
# Adds the server physical ip address to br-ex.
physicalcidr=192.168.0.121/24
# gateway=192.168.1.1
#
# ovs-vsctl add-port br-ex eth0
# ip addr flush dev eth0
# ip address add $physicalcidr dev br-ex
#
# Add IP address to br-ex
ip address add $physicalcidr dev br-ex || :
ip link set br-ex up || :
# ip route add default via $gateway dev br-ex || :
#
加入到 service
$ cd /etc/systemd/system
$ cat microstack-br-workaround.service
[Unit]
Description=Service for adding physical ip to microstack bridge
Requires=snap.microstack.external-bridge.service
After=snap.microstack.external-bridge.service
[Service]
ExecStart=/usr/local/bin/microstack-br-workaround
SyslogIdentifier=microstack-br-workaround
Restart=no
WorkingDirectory=/usr/local/bin
TimeoutStopSec=30
Type=oneshot
[Install]
WantedBy=multi-user.target
设置为 enable
systemctl daemon-reload
systemctl enable microstack-br-workaround.service
查看失败原因
$ sudo systemctl status microstack-br-workaround.service
● microstack-br-workaround.service - Service for adding physical ip to microstack bridge
Loaded: loaded (/etc/systemd/system/microstack-br-workaround.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since Sun 2022-10-23 15:09:00 CST; 55s ago
Process: 2266 ExecStart=/usr/local/bin/microstack-br-workaround (code=exited, status=203/EXEC)
Main PID: 2266 (code=exited, status=203/EXEC)
Oct 23 15:09:00 ubuntu2004-121 systemd[1]: Starting Service for adding physical ip to microstack bridge...
Oct 23 15:09:00 ubuntu2004-121 systemd[1]: microstack-br-workaround.service: Main process exited, code=exited, status=203/EXEC
Oct 23 15:09:00 ubuntu2004-121 systemd[1]: microstack-br-workaround.service: Failed with result 'exit-code'.
Oct 23 15:09:00 ubuntu2004-121 systemd[1]: Failed to start Service for adding physical ip to microstack bridge.
暂时找不到好办法!
只好再次执行
sudo ip addr flush dev eth0 && sudo ip addr add 192.168.0.121/24 dev br-ex
测试一下
$ ping 192.168.0.25
PING 192.168.0.25 (192.168.0.25) 56(84) bytes of data.
64 bytes from 192.168.0.25: icmp_seq=1 ttl=254 time=5.29 ms
64 bytes from 192.168.0.25: icmp_seq=2 ttl=254 time=0.989 ms
......
另外找一个单网卡的虚拟机进行测试
虽然 microstack-br-workaround 服务总是有错,但是,只是 ovs-vsctl del-port br-ex eth0 ,重启之后,还是可以继续
$ sudo vim /usr/local/bin/microstack-br-workaround
#!/bin/bash
#
# Workaround to enable physical network access to MicroStack
#
# Adds the server physical ip address to br-ex.
physicalcidr=192.168.0.128/24
ovs-vsctl del-port br-ex eth0
#
# gateway=192.168.1.81
#
# ovs-vsctl add-port br-ex eth0
# ip addr flush dev eth0 || :
# ip address add $physicalcidr dev br-ex || :
# ip link set br-ex up || :
# ip route add default via $gateway dev br-ex || :