文章目录
一、基本环境参数
- 环境:centos7.6
- opentack-zun版本stein
- python2.7.5/python3.6,都是系统自带python环境
- 默认zun数据库及zun服务密码 123456,可根据需要更改
二、controller节点zun安装
2.1 创建数据库
登录数据库:mysql -uroot -p123456
# 创建 zun 数据库
MariaDB [(none)] CREATE DATABASE zun;
# 配置 zun数据的 zun用户的库访问权限
MariaDB [(none)]> GRANT ALL PRIVILEGES ON zun.* TO 'zun'@'localhost' IDENTIFIED BY '123456';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON zun.* TO 'zun'@'%' IDENTIFIED BY '123456';
# 更新权限表
MariaDB [(none)]> flush privileges;
# 配置完成,退出数据库
MariaDB [(none)]> exit
2.2 创建openstack用户、服务、端点
加载admin凭据,用于以管理员权限使用openstack shell命令:. admin-openrc 或者 source /root/admin-openrc
# 默认zun数据库及zun服务密码 password: 123456,可根据需要更改
[root@controller ~]$ openstack user create --domain default --password 123456 zun
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | e4442931c8e445188d2f5e3220649e05 |
| name | zun |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
# 给zun用户添加admin角色
[root@controller ~]$ openstack role add --project service --user zun admin
# 创建zun服务实例
[root@controller ~]$ openstack service create --name zun --description "Container Service" container
+-------------+----------------------------------+
| Field | Value |
+-------------+----------------------------------+
| description | Container Service |
| enabled | True |
| id | e00970de38c74228a98857fdfce3d3f8 |
| name | zun |
| type | container |
+-------------+----------------------------------+
# 创建容器服务 API 后端
[root@controller ~]$ openstack endpoint create --region RegionOne container public http://controller:9517/v1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | fbb6eafd604e4dcab77b57498715c024 |
| interface | public |
| region | RegionOne |
| region_id | RegionOne |
| service_id | e00970de38c74228a98857fdfce3d3f8 |
| service_name | zun |
| service_type | container |
| url | http://controller:9517/v1 |
+--------------+----------------------------------+
[root@controller ~]$ openstack endpoint create --region RegionOne container internal http://controller:9517/v1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | 28a45bda04fb4bbcb71e7fcf5a5c1c90 |
| interface | internal |
| region | RegionOne |
| region_id | RegionOne |
| service_id | e00970de38c74228a98857fdfce3d3f8 |
| service_name | zun |
| service_type | container |
| url | http://controller:9517/v1 |
+--------------+----------------------------------+
[root@controller ~]$ openstack endpoint create --region RegionOne container admin http://controller:9517/v1
+--------------+----------------------------------+
| Field | Value |
+--------------+----------------------------------+
| enabled | True |
| id | c0afd38fd59343cab43739ff3c7cfdd8 |
| interface | admin |
| region | RegionOne |
| region_id | RegionOne |
| service_id | e00970de38c74228a98857fdfce3d3f8 |
| service_name | zun |
| service_type | container |
| url | http://controller:9517/v1 |
+--------------+----------------------------------+
2.3 安装、启动zun服务
2.3.1 创建用户、组
[root@controller ~]$ groupadd --system zun
[root@controller ~]$ useradd --home-dir "/var/lib/zun" --create-home --system --shell /bin/false -g zun zun
2.3.2 创建目录
[root@controller ~]$ mkdir -p /etc/zun
[root@controller ~]$ chown zun:zun /etc/zun
2.3.3 安装zun
# 安装依赖
[root@controller ~]$ yum install epel-release python-pip git python-devel libffi-devel gcc openssl-devel -y
# 升级pip
python -m pip install --upgrade pip
# 使用git下载并安装zun
[root@controller ~]$ cd /var/lib/zun
[root@controller zun]$ git clone -b stable/stein https://git.openstack.org/openstack/zun.git
# 国内使用git clone会比较慢,可以将git仓库的协议由 https 修改成 http即可(git clone -b stable/stein http://git.openstack.org/openstack/zun.git)
[root@controller zun]$ chown -R zun:zun zun
[root@controller zun]$ cd zun
[root@controller zun]$ pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
[root@controller zun]$ python setup.py install
2.3.4 生成配置文件并配置
[root@controller zun]$ su -s /bin/sh -c "oslo-config-generator --config-file etc/zun/zun-config-generator.conf" zun
[root@controller zun]$ su -s /bin/sh -c "cp etc/zun/zun.conf.sample /etc/zun/zun.conf" zun
复制api-paste.ini配置文件
[root@controller zun]$ su -s /bin/sh -c "cp etc/zun/api-paste.ini /etc/zun" zun
编辑配置文件vim /etc/zun/zun.conf
,在合适位置添加以下内容
[DEFAULT]
transport_url = rabbit://openstack:123456@controller
[api]
host_ip = 192.168.204.194
port = 9517
[database]
connection = mysql+pymysql://zun:123456@controller/zun
[keystone_auth]
memcached_servers = controller:11211
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = zun
password = 123456
auth_protocol = http
auth_version = v3
service_token_roles_required = True
endpoint_type = internalURL
[keystone_authtoken]
memcached_servers = controller:11211
www_authenticate_uri = http://controller:5000
auth_url = http://controller:5000
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = zun
password = 123456
auth_protocol = http
auth_version = v3
service_token_roles_required = True
endpoint_type = internalURL
[oslo_concurrency]
lock_path = /var/lib/zun/tmp
[oslo_messaging_notifications]
driver = messaging
[websocket_proxy]
wsproxy_host = 192.168.204.194
wsproxy_port = 6784
base_url = ws://controller:6784
2.3.5 填充数据库
[root@controller zun]$ su -s /bin/sh -c "zun-db-manage upgrade" zun
2.3.6 创建启动文件
vim /etc/systemd/system/zun-api.service
[Unit]
Description = OpenStack Container Service API
[Service]
ExecStart = /usr/bin/zun-api
User = zun
[Install]
WantedBy = multi-user.target
vim /etc/systemd/system/zun-wsproxy.service
[Unit]
Description = OpenStack Container Service Websocket Proxy
[Service]
ExecStart = /usr/bin/zun-wsproxy
User = zun
[Install]
WantedBy = multi-user.target
2.3.7启动服务
[root@controller ~]$ systemctl daemon-reload
[root@controller ~]$ systemctl enable zun-api zun-wsproxy
[root@controller ~]$ systemctl start zun-api zun-wsproxy
[root@controller ~]$ systemctl status zun-api zun-wsproxy
如果启动报websocket或者selectors 报错
pip install docker==4.4.4
pip install websocket-client==0.32.0
pip install websocket
2.4 Etcd安装与配置
2.4.1 Etcd安装
[root@controller ~]$ yum install -y etcd
2.4.2 配置Etcd
vim /etc/etcd/etcd.conf
#[Member]
ETCD_DATA_DIR="/var/lib/etcd/default.etcd"
ETCD_LISTEN_PEER_URLS="http://192.168.204.194:2380"
ETCD_LISTEN_CLIENT_URLS="http://192.168.204.194:2379"
ETCD_NAME="controller"
#[Clustering]
ETCD_INITIAL_ADVERTISE_PEER_URLS="http://192.168.204.194:2380"
ETCD_ADVERTISE_CLIENT_URLS="http://192.168.204.194:2379"
ETCD_INITIAL_CLUSTER="controller=http://192.168.204.194:2380"
ETCD_INITIAL_CLUSTER_TOKEN="etcd-cluster-01"
ETCD_INITIAL_CLUSTER_STATE="new"
#ETCD_INITIAL_CLUSTER_STATE="existing"
2.4.3 启动Etcd
[root@controller ~]$ systemctl enable etcd
[root@controller ~]$ systemctl start etcd
[root@controller ~]$ systemctl status etcd
三、计算节点zun安装
在计算节点安装zun-compute服务前,需要在计算节点按顺序安装docker和kuryr-libnetwork
在控制节点安装Etcd
安装一点必备的依赖
yum -y upgrade # 只更新包,不更新内核和系统
yum install -y epel-release yum-utils device-mapper-persistent-data lvm2 python-pip git python-devel libffi-devel gcc openssl-devel wget vim net-tools
3.1 时间同步
# 1、安装软件包
[root@zun ~]# yum install -y chrony
# 2、将时间同步服务器修改为controller节点
[root@zun ~]# sed -i '/^server/d' /etc/chrony.conf
[root@zun ~]# sed -i '2aserver controller iburst' /etc/chrony.conf
# 3、启动 NTP 服务并将其配置为随系统启动
[root@zun ~]# systemctl enable chronyd.service
[root@zun ~]# systemctl start chronyd.service
# 4、设置时区
[root@zun ~]# timedatectl set-timezone Asia/Shanghai
# 5、查看时间同步源
[root@zun ~]# chronyc sources
# 6、查看时间是否正确
[root@zun ~]# timedatectl status
3.2 docker安装
参照博客
https://blog.csdn.net/SpiritedAway1106/article/details/117106616
3.3 安装kuryr-libnetwork
3.3.1 控制节点
3.3.1.1 创建kuryr用户
. admin-openrc
# 123456
[root@controller ~]$ openstack user create --domain default --password 123456 kuryr
+---------------------+----------------------------------+
| Field | Value |
+---------------------+----------------------------------+
| domain_id | default |
| enabled | True |
| id | b6974ecd4b7a44f8be9fc9f6728085c5 |
| name | kuryr |
| options | {} |
| password_expires_at | None |
+---------------------+----------------------------------+
# 添加角色
[root@controller ~]$ openstack role add --project service --user kuryr admin
3.3.2 计算节点
3.3.2.1 创建用户
[root@zun ~]# groupadd --system kuryr
[root@zun ~]# useradd --home-dir "/var/lib/kuryr" --create-home --system --shell /bin/false -g kuryr kuryr
3.3.2.2 创建目录
[root@zun ~]# mkdir -p /etc/kuryr
[root@zun ~]# chown kuryr:kuryr /etc/kuryr
3.3.2.3 安装kuryr-libnetwork
[root@zun ~]# yum install epel-release python-pip git python-devel libffi-devel gcc openssl-devel -y
[root@zun ~]# cd /var/lib/kuryr
# 这里拉取git仓库时,仍使用http协议,这样会比较快些
[root@zun kuryr]# git clone -b stable/stein http://git.openstack.org/openstack/kuryr-libnetwork.git
[root@zun kuryr]# chown -R kuryr:kuryr kuryr-libnetwork
[root@zun kuryr]# cd kuryr-libnetwork
# 升级pip
[root@zun kuryr-libnetwork]# pip install --upgrade pip
# pip升级失败,可尝试已下方法
# wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
# sudo python get-pip.py
# pip install setuptools --upgrade
# 安装python包
[root@zun kuryr-libnetwork]# pip install -r requirements.txt -i https://pypi.tuna.tsinghua.edu.cn/simple
# 提示Could not find suitable distribution for Requirement.parse('pbr>=2.0.0'), 可手动执行pbr安装:pip install pbr
# 提示 ERROR: Cannot uninstall 'ipaddress'. It is a distutils installed project and thus we cannot accurately determine which files belong to it which would lead to only a partial uninstall. 原因是这里需要ipaddress>=1.0.17,需要卸载默认安装的低版本ipaddress模块,可以使用 :pip install ipaddress --ignore-installed 来安装,--ignore-installed 表示忽视已有的安装,直接安装新的版本
# 或者使用源码安装
# wget https://cbs.centos.org/kojifiles/packages/python-ipaddress/1.0.18/5.el7/noarch/python2-ipaddress-1.0.18-5.el7.noarch.rpm
# yum install -y python2-ipaddress-1.0.18-5.el7.noarch.rpm
# 安装 kuryr-libnetwork
[root@zun kuryr-libnetwork]# python setup.py install
3.3.2.4 生成配置文件
[root@zun kuryr-libnetwork]# su -s /bin/sh -c "./tools/generate_config_file_samples.sh" kuryr
[root@zun kuryr-libnetwork]# su -s /bin/sh -c "cp etc/kuryr.conf.sample /etc/kuryr/kuryr.conf" kuryr
3.3.2.5 编辑配置文件
sed -i.default -e "/^#/d" -e "/^$/d" /etc/kuryr/kuryr.conf
vim /etc/kuryr/kuryr.conf
[DEFAULT]
bindir = /usr/libexec/kuryr
[neutron]
www_authenticate_uri = http://controller:5000/v3
auth_url = http://controller:5000/v3
auth_type = password
project_domain_name = default
user_domain_name = default
project_name = service
username = kuryr
password = 123456
3.3.2.6 创建启动文件
vim /etc/systemd/system/kuryr-libnetwork.service
[Unit]
Description = Kuryr-libnetwork - Docker network plugin for Neutron
[Service]
ExecStart = /usr/bin/kuryr-server --config-file /etc/kuryr/kuryr.conf
CapabilityBoundingSet = CAP_NET_ADMIN
[Install]
WantedBy = multi-user.target
3.3.2.7 启动服务
[root@zun kuryr-libnetwork]# systemctl enable kuryr-libnetwork
[root@zun kuryr-libnetwork]# systemctl start kuryr-libnetwork
[root@zun kuryr-libnetwork]# systemctl restart docker
[root@zun kuryr-libnetwork]# systemctl status docker kuryr-libnetwork
# 启动kuryr-libnetwork报错
● kuryr-libnetwork.service - Kuryr-libnetwork - Docker network plugin for Neutron
Loaded: loaded (/etc/systemd/system/kuryr-libnetwork.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2021-09-18 14:05:08 CST; 3s ago
Process: 69860 ExecStart=/usr/bin/kuryr-server --config-file /etc/kuryr/kuryr.conf (code=exited, status=1/FAILURE)
Main PID: 69860 (code=exited, status=1/FAILURE)
Sep 18 14:05:07 zun kuryr-server[69860]: from kuryr.lib.binding.drivers import utils
Sep 18 14:05:07 zun kuryr-server[69860]: File "/usr/lib/python2.7/site-packages/kuryr/lib/binding/drivers/utils.py", line 14, in <module>
Sep 18 14:05:07 zun kuryr-server[69860]: import pyroute2
Sep 18 14:05:07 zun kuryr-server[69860]: File "/usr/lib/python2.7/site-packages/pyroute2/__init__.py", line 84
Sep 18 14:05:07 zun kuryr-server[69860]: origin=None, loader_state=None, is_package=None):
Sep 18 14:05:07 zun kuryr-server[69860]: ^
Sep 18 14:05:07 zun kuryr-server[69860]: SyntaxError: invalid syntax
Sep 18 14:05:08 zun systemd[1]: kuryr-libnetwork.service: main process exited, code=exited, status=1/FAILURE
Sep 18 14:05:08 zun systemd[1]: Unit kuryr-libnetwork.service entered failed state.
Sep 18 14:05:08 zun systemd[1]: kuryr-libnetwork.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
# 解决方案
# 直接回退pyroute2的版本,默认安装的 0.6.4.试了几个0.6版本的都会报这个错(python2.7),0.5版本的可用
# 比如 pip install pyroute2==0.5.19
# https://pypi.org/project/pyroute2/#history
# 启动kuryr-libnetwork报错
● kuryr-libnetwork.service - Kuryr-libnetwork - Docker network plugin for Neutron
Loaded: loaded (/etc/systemd/system/kuryr-libnetwork.service; enabled; vendor preset: disabled)
Active: failed (Result: exit-code) since Sat 2021-09-18 14:31:46 CST; 2s ago
Process: 70254 ExecStart=/usr/bin/kuryr-server --config-file /etc/kuryr/kuryr.conf (code=exited, status=1/FAILURE)
Main PID: 70254 (code=exited, status=1/FAILURE)
Sep 18 14:31:46 zun kuryr-server[70254]: 2021-09-18 14:31:46.791 70254 ERROR kuryr return self.request(url, 'POST', **kwargs)
Sep 18 14:31:46 zun kuryr-server[70254]: 2021-09-18 14:31:46.791 70254 ERROR kuryr File "/usr/lib/python2.7/site-packages/keystoneauth1/session.py", line 913, in request
Sep 18 14:31:46 zun kuryr-server[70254]: 2021-09-18 14:31:46.791 70254 ERROR kuryr resp = send(**kwargs)
Sep 18 14:31:46 zun kuryr-server[70254]: 2021-09-18 14:31:46.791 70254 ERROR kuryr File "/usr/lib/python2.7/site-packages/keystoneauth1/session.py", line 1020, in _send_request
Sep 18 14:31:46 zun kuryr-server[70254]: 2021-09-18 14:31:46.791 70254 ERROR kuryr raise exceptions.ConnectFailure(msg)
Sep 18 14:31:46 zun kuryr-server[70254]: 2021-09-18 14:31:46.791 70254 ERROR kuryr ConnectFailure: Unable to establish connection to http://controller:5000/v3/auth/tokens: HTTPConnectionPool(host='controller',...
Sep 18 14:31:46 zun kuryr-server[70254]: 2021-09-18 14:31:46.791 70254 ERROR kuryr
# 错误原因是 未配置本地hosts文件,无法解析controller的ip
# vim /etc/hosts 添加 192.168.204.203 zun-01 即可
3.3.2.8 验证
# 创建网络
[root@zun kuryr]# docker network create --driver kuryr --ipam-driver kuryr --subnet 10.10.0.0/16 --gateway=10.10.0.1 test_net2
7ea1d9cc1dfcae89195602579cb6e04d996c283b9ecdf07a7afa7ad1be62ec50
# 查看网络
[root@zun kuryr]# docker network ls
NETWORK ID NAME DRIVER SCOPE
...
7ea1d9cc1dfc test_net2 kuryr global
# 使用网络
[root@zun kuryr]# docker run --net test_net2 cirros ifconfig
eth0 Link encap:Ethernet HWaddr 02:42:A5:E1:00:7A
inet addr:10.10.3.123 Bcast:10.10.255.255 Mask:255.255.0.0
UP BROADCAST RUNNING MULTICAST MTU:1450 Metric:1
RX packets:7 errors:0 dropped:0 overruns:0 frame:0
TX packets:5 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:602 (602.0 B) TX bytes:426 (426.0 B)
lo Link encap:Local Loopback
inet addr:127.0.0.1 Mask:255.0.0.0
UP LOOPBACK RUNNING MTU:65536 Metric:1
RX packets:0 errors:0 dropped:0 overruns:0 frame:0
TX packets:0 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)
由于neutron使用的是linux-bridge,需要修改下成kuryr的源码
vim /usr/lib/python2.7/site-packages/kuryr/lib/binding/drivers/veth.py
# 第 84行,直接写死 kind='bridge'
否则在执行docker run --net test_net2 cirros ifconfig
时会报错
docker: Error response from daemon: failed to create endpoint elastic_galois on network test_net2: NetworkDriver.CreateEndpoint: vif_type(binding_failed) is not supported. A binding script for this type can't be found.
ERRO[0004] error waiting for container: context canceled
修改好之后,执行systemctl restart kuryr-libnetwork
重启下服务即可
3.4 zun-compute服务安装与配置
3.4.1 创建用户
[root@zun ~]# groupadd --system zun
[root@zun ~]# useradd --home-dir "/var/lib/zun" --create-home --system --shell /bin/false -g zun zun
3.4.2 创建目录
[root@zun ~]# mkdir -p /etc/zun
[root@zun ~]# chown zun:zun /etc/zun
3.4.3 安装zun包依赖
yum install epel-release python-pip git python-devel libffi-devel gcc openssl-devel -y
3.4.4 安装zun
[root@zun ~]# cd /var/lib/zun
[root@zun zun]# git clone -b stable/stein http://git.openstack.org/openstack/zun.git
[root@zun zun]# chown -R zun:zun zun
[root@zun zun]# cd zun
# python2安装
[root@zun zun]# pip install -r requirements.txt
[root@zun zun]# python setup.py install
3.4.5 生成示例配置文件
[root@zun zun]# su -s /bin/sh -c "oslo-config-generator --config-file etc/zun/zun-config-generator.conf" zun
[root@zun zun]# su -s /bin/sh -c "cp etc/zun/zun.conf.sample /etc/zun/zun.conf" zun
[root@zun zun]# su -s /bin/sh -c "cp etc/zun/rootwrap.conf /etc/zun/rootwrap.conf" zun
[root@zun zun]# su -s /bin/sh -c "mkdir -p /etc/zun/rootwrap.d" zun
[root@zun zun]# su -s /bin/sh -c "cp etc/zun/rootwrap.d/* /etc/zun/rootwrap.d/" zun
# su -s /bin/sh -c "cp etc/cni/net.d/* /etc/cni/net.d/" zun
3.4.6 配置zun用户
[root@zun zun]# echo "zun ALL=(root) NOPASSWD: /usr/bin/zun-rootwrap /etc/zun/rootwrap.conf *" | sudo tee /etc/sudoers.d/zun-rootwrap
3.4.7 编辑配置文件
vim /etc/zun/zun.conf
[DEFAULT]
transport_url = rabbit://openstack:123456@controller
state_path = /var/lib/zun
[database]
connection = mysql+pymysql://zun:123456@controller/zun
[keystone_auth]
memcached_servers = controller:11211
www_authenticate_uri = http://controller:5000
project_domain_name = default
project_name = service
user_domain_name = default
password = 123456
username = zun
auth_url = http://controller:5000
auth_type = password
auth_version = v3
auth_protocol = http
service_token_roles_required = True
endpoint_type = internalURL
[keystone_authtoken]
memcached_servers = controller:11211
www_authenticate_uri= http://controller:5000
project_domain_name = default
project_name = service
user_domain_name = default
password = 123456
username = zun
auth_url = http://controller:5000
auth_type = password
[websocket_proxy]
base_url = ws://controller:6784/
[oslo_concurrency]
lock_path = /var/lib/zun/tmp
[compute]
# If you want to run both containers and nova instances in this compute node, in the [compute] section, configure the host_shared_with_nova:
host_shared_with_nova = true
3.4.8 配置docker和kuryr
3.4.8.1 创建docker配置文件夹
[root@zun zun]# mkdir -p /etc/systemd/system/docker.service.d
3.4.8.2 创建docker配置文件
此处把compute和controller替换成对应的服务host名称或者ip地址
vim /etc/systemd/system/docker.service.d/docker.conf
[Service]
ExecStart=
ExecStart=/usr/bin/dockerd --group zun -H tcp://compute:2375 -H unix:///var/run/docker.sock --cluster-store etcd://controller:2379
3.4.8.3 重启docker
[root@zun ~]# systemctl daemon-reload
[root@zun ~]# systemctl restart docker
3.4.8.4 编辑kuryr配置文件
vim /etc/kuryr/kuryr.conf
[DEFAULT]
capability_scope = global
process_external_connectivity = False
3.4.8.5 重启kuryr
[root@zun ~]# systemctl restart kuryr-libnetwork
3.4.9 配置containerd
[root@zun ~]# containerd config default > /etc/containerd/config.toml
[root@zun ~]# chown zun:zun /etc/containerd/config.toml
# 获取zun_group_id的方法如下
[root@zun ~]# getent group zun | cut -d: -f3
992
# 编辑配置文件
## /etc/containerd/config.toml
[grpc]
...
gid = 992
# 重启容器
[root@zun ~]# systemctl restart containerd
3.4.10 创建启动文件
vim /etc/systemd/system/zun-compute.service
[Unit]
Description = OpenStack Container Service Compute Agent
[Service]
ExecStart = /usr/bin/zun-compute
User = zun
[Install]
WantedBy = multi-user.target
3.4.11 启动zun-compute
[root@zun ~]# systemctl enable zun-compute
[root@zun ~]# systemctl start zun-compute
[root@zun ~]# systemctl status zun-compute
# 报错
[root@zun ~]# systemctl status zun-compute
● zun-compute.service - OpenStack Container Service Compute Agent
Loaded: loaded (/etc/systemd/system/zun-compute.service; enabled; vendor preset: disabled)
Active: active (running) since Wed 2021-09-22 11:32:34 CST; 7min ago
Main PID: 81247 (zun-compute)
Tasks: 1
Memory: 84.7M
CGroup: /system.slice/zun-compute.service
└─81247 /usr/bin/python /usr/bin/zun-compute
Sep 22 11:39:43 zun zun-compute[81247]: 2021-09-22 11:39:43.398 81247 ERROR oslo_service.periodic_task engine = sqlalchemy.create_engine(url, **engine_args)
Sep 22 11:39:43 zun zun-compute[81247]: 2021-09-22 11:39:43.398 81247 ERROR oslo_service.periodic_task File "<string>", line 2, in create_engine
Sep 22 11:39:43 zun zun-compute[81247]: 2021-09-22 11:39:43.398 81247 ERROR oslo_service.periodic_task File "/usr/lib64/python2.7/site-packages/sqlalchemy/util/deprecations.py", line 298, in warned
Sep 22 11:39:43 zun zun-compute[81247]: 2021-09-22 11:39:43.398 81247 ERROR oslo_service.periodic_task return fn(*args, **kwargs)
Sep 22 11:39:43 zun zun-compute[81247]: 2021-09-22 11:39:43.398 81247 ERROR oslo_service.periodic_task File "/usr/lib64/python2.7/site-packages/sqlalchemy/engine/create.py", line 548, in create_engine
Sep 22 11:39:43 zun zun-compute[81247]: 2021-09-22 11:39:43.398 81247 ERROR oslo_service.periodic_task dbapi = dialect_cls.dbapi(**dbapi_args)
Sep 22 11:39:43 zun zun-compute[81247]: 2021-09-22 11:39:43.398 81247 ERROR oslo_service.periodic_task File "/usr/lib64/python2.7/site-packages/sqlalchemy/dialects/mysql/pymysql.py", line 68, in dbapi
Sep 22 11:39:43 zun zun-compute[81247]: 2021-09-22 11:39:43.398 81247 ERROR oslo_service.periodic_task return __import__("pymysql")
Sep 22 11:39:43 zun zun-compute[81247]: 2021-09-22 11:39:43.398 81247 ERROR oslo_service.periodic_task ImportError: No module named pymysql
Sep 22 11:39:43 zun zun-compute[81247]: 2021-09-22 11:39:43.398 81247 ERROR oslo_service.periodic_task
# pip install pymysql
# 再次重启 zun-compute服务,报错
● zun-compute.service - OpenStack Container Service Compute Agent
Loaded: loaded (/etc/systemd/system/zun-compute.service; enabled; vendor preset: disabled)
Active: inactive (dead) since Wed 2021-09-22 14:12:28 CST; 4s ago
Process: 82704 ExecStart=/usr/bin/zun-compute (code=exited, status=0/SUCCESS)
Main PID: 82704 (code=exited, status=0/SUCCESS)
Sep 22 14:12:28 zun zun-compute[82704]: 2021-09-22 14:12:28.835 82704 ERROR oslo_service.service File "/usr/lib/python2.7/site-packages/amqp/method_framing.py", line 55, in on_frame
Sep 22 14:12:28 zun zun-compute[82704]: 2021-09-22 14:12:28.835 82704 ERROR oslo_service.service callback(channel, method_sig, buf, None)
Sep 22 14:12:28 zun zun-compute[82704]: 2021-09-22 14:12:28.835 82704 ERROR oslo_service.service File "/usr/lib/python2.7/site-packages/amqp/connection.py", line 521, in on_inbound_method
Sep 22 14:12:28 zun zun-compute[82704]: 2021-09-22 14:12:28.835 82704 ERROR oslo_service.service method_sig, payload, content,
Sep 22 14:12:28 zun zun-compute[82704]: 2021-09-22 14:12:28.835 82704 ERROR oslo_service.service File "/usr/lib/python2.7/site-packages/amqp/abstract_channel.py", line 145, in dispatch_method
Sep 22 14:12:28 zun zun-compute[82704]: 2021-09-22 14:12:28.835 82704 ERROR oslo_service.service listener(*args)
Sep 22 14:12:28 zun zun-compute[82704]: 2021-09-22 14:12:28.835 82704 ERROR oslo_service.service File "/usr/lib/python2.7/site-packages/amqp/connection.py", line 651, in _on_close
Sep 22 14:12:28 zun zun-compute[82704]: 2021-09-22 14:12:28.835 82704 ERROR oslo_service.service (class_id, method_id), ConnectionError)
Sep 22 14:12:28 zun zun-compute[82704]: 2021-09-22 14:12:28.835 82704 ERROR oslo_service.service AccessRefused: (0, 0): (403) ACCESS_REFUSED - Login was refused using authentication mechanism AMQPLAIN. For details see the broker logfile.
Sep 22 14:12:28 zun zun-compute[82704]: 2021-09-22 14:12:28.835 82704 ERROR oslo_service.service
# 为rabbitmq的密码配置错误,修改
# vim /etc/zun/zun.conf
# [DEFAULT]
# transport_url = rabbit://openstack:123456@controller 配置正确的密码即可
3.4.12 验证
控制节点执行
[root@controller ~]# pip install python-zunclient
[root@controller ~]# source /root/admin-openrc
[root@controller ~]$ openstack appcontainer service list
+----+------+-------------+-------+----------+-----------------+---------------------+-------------------+
| Id | Host | Binary | State | Disabled | Disabled Reason | Updated At | Availability Zone |
+----+------+-------------+-------+----------+-----------------+---------------------+-------------------+
| 1 | zun | zun-compute | up | False | None | 2021-09-22 09:51:21 | nova |
+----+------+-------------+-------+----------+-----------------+---------------------+-------------------+
四、zun-ui安装
官方文档:https://docs.openstack.org/zun-ui/latest/install/index.html
4.1 克隆代码,并安装zun-ui
[root@controller zun_ui]$ git clone https://github.com/openstack/zun-ui
[root@controller zun_ui]$ cd zun-ui/
[root@controller zun-ui]$ git checkout stable/stein
[root@controller zun-ui]$ pip install .
4.2 在Horizon中启用zun-ui
[root@controller zun-ui]$ cp zun_ui/enabled/* /usr/share/openstack-dashboard/openstack_dashboard/local/enabled
[root@controller zun-ui]$ python /usr/share/openstack-dashboard/manage.py collectstatic
[root@controller zun-ui]$ python /usr/share/openstack-dashboard/manage.py compress
4.3 重启Horizon
[root@controller zun-ui]$ systemctl restart httpd.service memcached.service
# 我本地机器使用nginx启动 horizon. 需重启 uwsgi
# systemctl restart uwsgi
4.3 验证
访问horzion页面,可看到容器
列表