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 Squid 代理伺服器安裝除錯常用指令大全

編輯:Linux 教學

核心管理指令

用途指令說明
初始化快取目錄squid -z首次啟動前必須執行,建立 cache_dir 結構
語法檢查squid -k parse驗證 squid.conf 無誤才能啟動
前台除錯啟動squid -N -d1前景執行並輸出除錯等級 1 訊息,見到 Ready to serve requests 即成功
背景啟動squid -s守護進程模式啟動,ps -A | grep squid 可見兩個進程
優雅關閉squid -k shutdown等待連線處理完畢再關閉
熱重載設定squid -k reconfigure修改 squid.conf 後無需重啟即時生效
加入開機自啟echo "/usr/local/squid/sbin/squid -s" >> /etc/rc.d/rc.local或寫 systemd service

權限設定 (關鍵)

# 快取目錄擁有者
chown -R squid:squid /home/cache

# 日誌目錄擁有者
chown -R squid:squid /usr/local/squid/var/logs

日誌分析常用管線

# 記憶體快取命中 (TCP_MEM_HIT)
grep TCP_MEM_HIT /usr/local/squid/var/logs/access.log

# 磁碟快取命中 (TCP_HIT)
grep TCP_HIT /usr/local/squid/var/logs/access.log

# 未命中,向源站取回 (TCP_MISS)
grep TCP_MISS /usr/local/squid/var/logs/access.log

# 指定域名過濾
grep www.example.com /usr/local/squid/var/logs/access.log

日誌輪替 (Log Rotation)

# squid.conf 設定保留份數
logfile_rotate 10

# crontab 每週六凌晨 2 點輪替
0 2 * * 6 /usr/local/squid/sbin/squid -k rotate

中文化錯誤頁面

# squid.conf 新增
error_directory /usr/share/squid/errors/Simplify_Chinese
Copyright © Windows教程網 All Rights Reserved