入坑出坑
1.在 Ubuntu 22.04 发行版中进行软件安装时显示无法初始化前端界面 Dialog 工具问题解决.
适用环境: Ubuntu 22.04 TLS
错误信息:
debconf: unable to initialize frontend: Dialog
debconf: (No usable dialog-like program is installed, so the dialog based frontend cannot be used. at /usr/share/perl5/Debconf/FrontEnd/Dialog.pm line 76.)
debconf: falling back to frontend: Readline
问题原因: Dialog其实是一个可视化工具的名称, Dialog工具提供了在Shell中使用对话框的方式展示各类问题、信息的方式,这些问题包括Yes/No选项、菜单、文本框、单选框、复选框等等。换句话说,安装MySQL时提示设定的管理员密码;安装Postfix时要求输入的Hostname;选定时区的时区选择框等等都是由Dialog工具实现的, 由于我在默认安装ubuntu 22.04 选择了最小安装, 所以系统中不包括此工具。
解决办法: 使用apt-get重新安装相关组件
apt-get install dialog
2.在 Ubuntu 22.04 发行版中查看命令的帮助文档显示此系统已通过删除以下包和内容而最小化问题解决。
适用环境: Ubuntu 22.04 TLS
错误信息:
This system has been minimized by removing packages and content that are not required on a system that users do not log into.
To restore this content, including manpages, you can run the ‘unminimize’ command. You will still need to ensure the ‘man-db’ package is installed.
问题原因: 由于我们是最小化安装导致某些可能看起来不需要的软件未进行安装, 从而导致后续安装中出现错误。
解决办法: 执行unminimize命令按取消最小安装即可。
$ unminimize
This system has been minimized by removing packages and content that arenot required on a system that users do not log into.
This script restores content and packages that are found on a default Ubuntu server system in order to make this system more suitable for interactive use.
Reinstallation of packages may fail due to changes to the system configuration, the presence of third-party packages, or for other reasons.
This operation may take some time.
Would you like to continue? [y/N] y
..
3.在 Ubuntu 22.04 发行版中执行软件源更新与软件安装时出现Sub-process /usr/bin/dpkg returned an error code错误问题解决
适用环境: Ubuntu 22.04 TLS
错误信息:
dpkg: error processing package libpam-cracklib:amd64 (--configure):
dependency problems - leaving unconfigured
No apport report written because MaxReports is reached already Errors were encountered while processing:
chrony
ufw
man-db
nfs-common
wamerican
sysstat
libpam-cracklib:amd64
needrestart is being skipped since dpkg has failed
E: Sub-process /usr/bin/dpkg returned an error code (1)
解决办法:进入到 /var/lib/dpkg/info 将有问题的套件档案删除。
# 删除有问题的套件
cd /var/lib/dpkg/info
rm -rf chrony ufw man-db nfs-common wamerican sysstat libpam-cracklib:amd64
# 卸载有问题的软件
apt remove chrony ufw man-db nfs-common wamerican sysstat libpam-cracklib:amd64
apt-get autoclean
apt-get autoremove
apt-get update
apt-get upgrade
4.在 Ubuntu 22.04 发行版中remove cloud-init 包后导致netplan被删除从而无法进行网络管理问题的解决办法。
问题复现: 以 root 用户身份运行以删除这些包, 在进行删除 netplan.io 不会立即产生任何影响(网络仍然有效),但下次重新启动服务器时没有网络(需要手动配置IP地址及其路由网关)。
# 异常操作
apt remove ifupdown cloud-init
dpkg --ignore-depends=ubuntu-minimal -r netplan.io
# 机器重启后网卡down掉的
ubuntu@ubuntu-212:~$ ip addr
1: lo: <LOOPBACK,UP,LOWER_UP> mtu 65536 qdisc noqueue state UNKNOWN group default qlen 1000
link/loopback 00:00:00:00:00:00 brd 00:00:00:00:00:00
inet 127.0.0.1/8 scope host lo
.....
4: enp44s0f0: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 50:7c:6f:07:ad:f0 brd ff:ff:ff:ff:ff:ff
5: enp44s0f1: <BROADCAST,MULTICAST> mtu 1500 qdisc noop state DOWN group default qlen 1000
link/ether 50:7c:6f:07:ad:f1 brd ff:ff:ff:ff:ff:ff
# 无 netplan 命令
ubuntu@ubuntu-212:~$ net
netstat networkctl networkd-dispatcher
# 使用networkctl查看网络状态
ubuntu@ubuntu-212:~$ networkctl list
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier unmanaged
2 enp64s0f0 ether off unmanaged
3 enp64s0f1 ether off unmanaged
4 enp44s0f0 ether routable unmanaged
5 enp44s0f1 ether carrier unmanaged
# 系统中无 NetworkManager.service服务
systemctl status NetworkManager.service
# Unit NetworkManager.service could not be found.
问题原因: 意味着 netplan.io 负责配置的某些方面(显然),当然如果你手动的配置正确操作系统仍然可以使用网络, 我已经尝试了这些步骤来尝试手动启动网络
# 1.在机器重启后网卡会DOWN掉,此时我们需要执行如下命令让网卡启动,在 ifup 命令不存在的情况下可以执行。
ip link set dev enp44s0f0 up
ifconfig enp44s0f0 up
# 2.配置网卡IP地址虽然同C段机器可以连接,但是跨网段的机器不能链接。
ip addr add 192.168.1.1/24 dev brd 192.168.1.255 enp44s0f0
解决恢复办法:
# 1.正确配置网络的命令
ifconfig enp44s0f0 <address> netmask 255.255.255.0
route add default gw <gateway4> enp44s0f0
ifconfig enp44s0f0 up
# 2.重新安装 netplan.io 包
apt install netplan.io
# apt update && apt upgrade -y
# 3.验证安装是否正常
$ netplan get
network:
version: 2
ethernets:
enp44s0f0:
addresses:
- "192.168.1.210/24"
nameservers:
addresses:
- 192.168.1.254
search: []
routes:
- to: "default"
via: "192.168.1.1"
# 4.重载网络
netplan apply
# 5.在次使用 networkctl 命令查看网络
$ networkctl
IDX LINK TYPE OPERATIONAL SETUP
1 lo loopback carrier unmanaged
2 enp64s0f0 ether no-carrier configuring
3 enp64s0f1 ether no-carrier configuring
4 enp44s0f0 ether routable configuring
5 enp44s0f1 ether degraded configuring
5 links listed.
最后提示: 非常注意,非常注意,非常注意,删除 cloud-init 会导致无法使用netplan管理网络,从而需要手动配置网络, 有带外管理的可能还好,要是只能远程登录的那就GG了!