Windows XP Windows 7 Windows 2003 Windows Vista Windows 綜合教學 Linux 系統教學
Windows 10 Windows 8 Windows 2008 Windows NT Windows Server 電腦軟體教學
您现在的位置: Windows教程網 >> Windows教程 >  >> Linux 系統教學 >> Linux 教學

Linux named 服務啟動報錯 "named.pid permission denied" 根因與修復

編輯:Linux 教學

BIND DNS 服務啟動失敗,日志提示 couldn't open pid file '/var/run/named/named.pid': Permission denied。根因是 /var/run/named 目錄所有權不正確,修復極簡單。

一、 錯誤現場

[root@localhost etc]# named -g
...
Jun 13 11:18:01.250 couldn't open pid file '/var/run/named/named.pid': Permission denied
Jun 13 11:18:01.250 exiting (due to early fatal error)

二、 根因分析

named 進程以 named 用戶運行,需對 PID 文件目錄有寫入權限。目錄所有權若為 root:root,則 named 用戶無法創建 named.pid。

三、 一鍵修復

# 將目錄所有權授予 named 用戶
chown named:root /var/run/named

# 啟動服務驗證
service named start

四、 進階排查清單(若上述無效)

  1. 檢查目錄是否存在:ls -ld /var/run/named,不存在則 mkdir -p /var/run/named && chown named:root /var/run/named。
  2. SELinux 上下文:restorecon -Rv /var/run/named。
  3. 配置文件 pid-file 路徑:確認 /etc/named.conf 中 options { pid-file "/var/run/named/named.pid"; }; 路徑一致。
  4. 端口衝突:日志中 binding TCP socket: address in use 表明 53 端口被佔用,需 netstat -tulpn | grep :53 排查。

五、 最佳實踐

  • 使用 systemctl start named(CentOS 7+)或 service named start(CentOS 6)管理服務,避免直接執行 named -g。
  • 定期備份 /etc/named.conf 與區域文件。
  • 啟用 rndc 管理工具,實現熱加載配置。
Copyright © Windows教程網 All Rights Reserved