跳转到内容
搜索 AlmaLinux 文档

    浏览当前文档目录

    AlmaLinux 9:新装系统的 7 项核对

    在 almalinux:9 容器(AlmaLinux 9.8,aarch64)中实际执行:cat /etc/almalinux-release、dnf repolist --enabled、ls -l /etc/localtime、cat /etc/hostname、安装 firewalld 后 firewall-offline-cmd、安装 yum-utils 后 needs-restarting -r。日志:plans/content-expansion/evidence/logs/alma-first-steps.log。

    timedatectl、getenforce、hostnamectl 依赖 systemd / SELinux 运行态,容器不可用,未在本环境实测。

    Terminal window
    cat /etc/almalinux-release
    dnf repolist --enabled
    AlmaLinux release 9.8 (Olive Jaguar)
    repo id repo name
    appstream AlmaLinux 9 - AppStream
    baseos AlmaLinux 9 - BaseOS
    extras AlmaLinux 9 - Extras

    默认只有这三个源,CRB 未启用。需要 glibc-static、*-devel 时用 --enablerepo=crb 临时开,不必永久启用。

    Terminal window
    ls -l /etc/localtime
    lrwxrwxrwx ... /etc/localtime -> ../usr/share/zoneinfo/UTC

    容器默认 UTC。真实系统上用 timedatectl set-timezone Asia/Shanghai,并确认 systemctl status chronyd 为 active(需真实系统)。

    Terminal window
    cat /etc/hostname

    容器里是随机容器 ID;真实系统用 hostnamectl set-hostname app01.example.com,hostname -f 应返回 FQDN(需真实系统)。

    Terminal window
    getenforce
    sestatus | head -5

    需真实系统:容器没有 SELinux 运行态。AlmaLinux 9 安装后默认为 enforcing;排查用 ausearch -m avc 与 sealert,不要用 setenforce 0 掩盖。

    Terminal window
    firewall-offline-cmd --get-default-zone
    firewall-offline-cmd --zone=public --list-services
    public
    cockpit dhcpv6-client ssh

    默认 zone 是 public,只放行 cockpit、dhcpv6-client、ssh。开新服务记得放行端口:/firewalld-zones/。

    Terminal window
    sudo dnf -y install yum-utils
    sudo dnf -y update
    sudo needs-restarting -r
    No core libraries or services have been updated since boot-up.
    Reboot should not be necessary.

    退出码 0 表示不用重启,1 表示需要。命令来自 yum-utils,不是 dnf-plugins-core。

    Terminal window
    dnf list installed | wc -l
    rpm -q firewalld chrony

    需真实系统:容器是精简 rootfs,包数不可比。真实最小化安装通常 400–600 个包,且不一定预装 firewalld 与 chrony;用 rpm -q 确认,缺了用 dnf install -y firewalld chrony 再 systemctl enable --now。

    在一台新装 AlmaLinux 9 上逐条执行并记录:

    1. dnf repolist --enabled → 恰为 baseos/appstream/extras
    2. timedatectl status | grep "Time zone" → 与预期一致
    3. hostname -f → FQDN
    4. getenforce → Enforcing
    5. firewall-cmd --zone=public --list-services → 只有三个默认服务
    6. needs-restarting -r; echo $? → 0
    7. rpm -q firewalld chrony → 两个都有输出

    常见问题

    为什么 `dnf repolist` 里没有 crb?

    CRB 默认不启用。需要构建依赖时用 `--enablerepo=crb` 临时打开,或按需在 repo 文件里永久启用;默认保持关闭可减少包来源混杂。

    容器里 `getenforce` 显示 Disabled 正常吗?

    正常。容器没有 SELinux 运行态,这个结果不代表真实主机。真实 AlmaLinux 9 安装后默认 enforcing,请在主机上核对。

    `needs-restarting` 提示需要重启,能直接重启吗?

    先看它报告的是内核还是核心库更新,确认业务已做维护窗口与健康检查再重启;不确定时先 `dnf history list` 看这轮更新装了什么。