当安装Containerd,在重启Containerd时出现
Job for containerd.service failed because the control process exited with error code. See "systemctl status containerd.service" and "journalctl -xe" for details.
根据提示查询Containerd状态
systemctl status containerd.service发现是无法启动容器运行时
[root@master ~]# systemctl restart containerd
Job for containerd.service failed because the control process exited with error code. See "systemctl status containerd.service" and "journalctl -xe" for details.
[root@master ~]# systemctl status containerd.service
● containerd.service - containerd container runtime
Loaded: loaded (/etc/systemd/system/containerd.service; enabled; vendor preset: disabled)
Active: activating (auto-restart) (Result: exit-code) since 日 2022-07-31 13:49:38 CST; 2s ago
Docs: https://containerd.io
Process: 5531 ExecStart=/usr/local/bin/containerd (code=exited, status=1/FAILURE)
Process: 5529 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
Main PID: 5531 (code=exited, status=1/FAILURE)
7月 31 13:49:38 master systemd[1]: containerd.service: main process exited, code=exited, status=1/FAILURE
7月 31 13:49:38 master systemd[1]: Failed to start containerd container runtime.
7月 31 13:49:38 master systemd[1]: Unit containerd.service entered failed state.
7月 31 13:49:38 master systemd[1]: containerd.service failed.
journalctl -xe查看具体原因如下
Unit containerd.service has begun starting up.
7月 31 14:17:20 master containerd[8619]: containerd: Near line 0 (last key parsed ''): bare keys cannot contain '.'
7月 31 14:17:20 master systemd[1]: containerd.service: main process exited, code=exited, status=1/FAILURE
7月 31 14:17:20 master systemd[1]: Failed to start containerd container runtime.
-- Subject: Unit containerd.service has failed
排查发现是Containerd启动时配置文件的问题
解决方案,删除以前的Containerd配置文件,重新执行一下Containerd的安装过程
具体看文章
kubeadm部署指定版本的K8s+containerd+docker——图文详细版(上)
移除以前的配置文件
rm -rf /etc/containerd
重新执行文章中的安装部分
sudo tar -C / -xzf cri-containerd-cni-1.4.3-linux-amd64.tar.gz
export PATH=$PATH:/usr/local/bin:/usr/local/sbin
source ~/.bashrc
mkdir /etc/containerd
containerd config default > /etc/containerd/config.toml
镜像加速的配置就在 cri 插件配置块下面的 registry 配置块
修改镜像
vim /etc/containerd/config.toml
修改为如下配置文件格式
[plugins."io.containerd.grpc.v1.cri".registry.mirrors]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."docker.io"]
endpoint = ["https://dockerhub.mirrors.nwafu.edu.cn"]
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."k8s.gcr.io"]
endpoint = ["https://registry.aliyuncs.com/k8sxio"]
保存并退出
启动Containerd,并查询状态
systemctl daemon-reload
systemctl enable containerd
systemctl restart containerd
systemctl status containerd
本文执行该操作过程如下:
[root@master ~]# rm -rf /etc/containerd
[root@master ~]# ll
总用量 96864
-rw-------. 1 root root 1758 7月 31 09:17 anaconda-ks.cfg
-rw-r--r--. 1 root root 99176835 12月 8 2021 cri-containerd-cni-1.4.3-linux-amd64.tar.gz
-rw-r--r--. 1 root root 1806 7月 31 09:25 initial-setup-ks.cfg
drwxr-xr-x. 2 root root 6 7月 31 09:26 公共
drwxr-xr-x. 2 root root 6 7月 31 09:26 模板
drwxr-xr-x. 2 root root 6 7月 31 09:26 视频
drwxr-xr-x. 2 root root 6 7月 31 09:26 图片
drwxr-xr-x. 2 root root 6 7月 31 09:26 文档
drwxr-xr-x. 2 root root 6 7月 31 09:26 下载
drwxr-xr-x. 2 root root 6 7月 31 09:26 音乐
drwxr-xr-x. 2 root root 6 7月 31 09:26 桌面
[root@master ~]# sudo tar -C / -xzf cri-containerd-cni-1.4.3-linux-amd64.tar.gz
[root@master ~]# export PATH=$PATH:/usr/local/bin:/usr/local/sbin
[root@master ~]# source ~/.bashrc
[root@master ~]# ctr version
Client:
Version: v1.4.3
Revision: 269548fa27e0089a8b8278fc4fc781d7f65a939b
Go version: go1.15.5
Server:
Version: v1.4.3
Revision: 269548fa27e0089a8b8278fc4fc781d7f65a939b
UUID: e4c49cb6-919e-4093-b787-e6835710f1a0
[root@master ~]# containerd config default > /etc/containerd/config.toml
-bash: /etc/containerd/config.toml: 没有那个文件或目录
[root@master ~]# mkdir /etc/containerd
[root@master ~]# containerd config default > /etc/containerd/config.toml
[root@master ~]# vim /etc/containerd/config.toml
[root@master ~]# systemctl daemon-reload
[root@master ~]# systemctl enable containerd
Created symlink from /etc/systemd/system/multi-user.target.wants/containerd.service to /etc/systemd/system/containerd.service.
[root@master ~]# systemctl restart containerd
[root@master ~]# systemctl status containerd
● containerd.service - containerd container runtime
Loaded: loaded (/etc/systemd/system/containerd.service; enabled; vendor preset: disabled)
Active: active (running) since 日 2022-07-31 14:20:03 CST; 9s ago
Docs: https://containerd.io
Process: 8737 ExecStartPre=/sbin/modprobe overlay (code=exited, status=0/SUCCESS)
Main PID: 8740 (containerd)
Tasks: 8
Memory: 26.1M
CGroup: /system.slice/containerd.service
└─8740 /usr/local/bin/containerd
7月 31 14:20:03 master containerd[8740]: time="2022-07-31T14:20:03.916462356+08:00" level=info msg=serving... addres....ttrpc
7月 31 14:20:03 master containerd[8740]: time="2022-07-31T14:20:03.916489762+08:00" level=info msg=serving... addres...d.sock
7月 31 14:20:03 master containerd[8740]: time="2022-07-31T14:20:03.916524027+08:00" level=info msg="containerd succe...8398s"
7月 31 14:20:03 master systemd[1]: Started containerd container runtime.
7月 31 14:20:03 master containerd[8740]: time="2022-07-31T14:20:03.926063256+08:00" level=info msg="Start subscribin...event"
7月 31 14:20:03 master containerd[8740]: time="2022-07-31T14:20:03.926129974+08:00" level=info msg="Start recovering state"
7月 31 14:20:03 master containerd[8740]: time="2022-07-31T14:20:03.926210412+08:00" level=info msg="Start event monitor"
7月 31 14:20:03 master containerd[8740]: time="2022-07-31T14:20:03.926218400+08:00" level=info msg="Start snapshots syncer"
7月 31 14:20:03 master containerd[8740]: time="2022-07-31T14:20:03.926225195+08:00" level=info msg="Start cni networ...yncer"
7月 31 14:20:03 master containerd[8740]: time="2022-07-31T14:20:03.926229330+08:00" level=info msg="Start streaming server"
Hint: Some lines were ellipsized, use -l to show in full.