在 Redhat7 上使用 systemctl start docker 命令启动 docker,遇到
Authorization not available. Check if polkit service is running or see debug message for more information.Failed to start docker.service: Connection timed outSee system logs and ‘systemctl status docker.service’ for details.
这不仅仅影响 docker,出现这个问题,几乎 systemctl 相关程序都无法进行操作。
查看 polkit 状态 systemctl status polkit
Active: failedFailed to start Authorization Manager
查看日志 cat /var/log/message
dbus[23761]: [system] Failed to activate service 'org.freedesktop.systemd1': timed out systemd-logind: Failed to enable subscription: Failed to activate service 'org.freedesktop.systemd1': timed out systemd-logind: Failed to fully start up daemon: Connection timed outsystemd: systemd-logind.service: main process exited, code=exited, status=1/FAILUREsystemd: Failed to start Login Service. systemd: Unit systemd-logind.service entered failed state. systemd: systemd-logind.service failed.
解决:
Redhat 官方有专门的解决方案:
地址:https://access.redhat.com/solutions/1543343
1、检查 polkitd 的用户和组信息
getent group polkitd >/dev/null && echo -e "\e[1;32mpolkitd group already exists\e[0m" || { groupadd -r polkitd && echo -e "\e[1;33mAdded missing polkitd group\e[0m" || echo -e "\e[1;31mAdding polkitd group FAILED\e[0m"; } getent passwd polkitd >/dev/null && echo -e "\e[1;32mpolkitd user already exists\e[0m" || { useradd -r -g polkitd -d / -s /sbin/nologin -c "User for polkitd" polkitd && echo -e "\e[1;33mAdded missing polkitd user\e[0m" || echo -e "\e[1;31mAdding polkitd user FAILED\e[0m"; }
如果都显示已存在,可进行第二步
2、对 polkit 的相关文件进行重新授权
rpm -Va polkit\* && echo -e "\e[1;32mpolkit* rpm verification passed\e[0m" || { echo -e "\e[1;33mResetting polkit* rpm user/group ownership & perms\e[0m"; rpm --setugids polkit polkit-pkla-compat; rpm --setperms polkit polkit-pkla-compat; }
3、重启计算机
重启后使用 systemctl status polkit
polkit.service - Authorization Manager Loaded: loaded (/usr/lib/systemd/system/polkit.service; static; vendor preset: enabled) Active: active (running) since Fri 2021-10-08 13:59:44 CST; 13min ago Docs: man:polkit(8) Main PID: 24034 (polkitd) Tasks: 7 Memory: 10.6M CGroup: /system.slice/polkit.service ?..24034 /usr/lib/polkit-1/polkitd --no-debugOct 08 13:59:44 mango27 systemd[1]: Starting Authorization Manager...Oct 08 13:59:44 mango27 polkitd[24034]: Started polkitd version 0.112Oct 08 13:59:44 mango27 polkitd[24034]: Loading rules from directory /etc/polkit-1/rules.dOct 08 13:59:44 mango27 polkitd[24034]: Loading rules from directory /usr/share/polkit-1/rules.dOct 08 13:59:44 mango27 polkitd[24034]: Finished loading, compiling and executing 11 rulesOct 08 13:59:44 mango27 polkitd[24034]: Acquired the name org.freedesktop.PolicyKit1 on the system busOct 08 13:59:44 mango27 systemd[1]: Started Authorization Manager.Oct 08 13:59:56 mango27 polkitd[24034]: Registered Authentication Agent for unix-session:c1 (system bus name :1.29 [/usr/bin/gnome-shell], object path /org/freedeskt...n_US.UTF-8)Oct 08 14:04:15 mango27 polkitd[24034]: Registered Authentication Agent for unix-process:25700:15686 (system bus name :1.74 [/usr/bin/pkttyagent --notify-fd 5 --fall...n_US.UTF-8)Oct 08 14:04:17 mango27 polkitd[24034]: Unregistered Authentication Agent for unix-process:25700:15686 (system bus name :1.74, object path /org/freedesktop/PolicyKit...d from bus)Hint: Some lines were ellipsized, use -l to show in full.
启动 docker 程序:systemctl start docker 即可
网友留言: