版本检查
haproxy -v
重要文件与目录
- 配置文件:
/etc/haproxy/haproxy.cfg - 二进制:
/usr/sbin/haproxy
服务管理
启动 HAProxy:
systemctl start haproxy
配置变更后重启:
systemctl restart haproxy
检查状态:
systemctl status haproxy
查看实时日志:
journalctl -u haproxy -f
配置
编辑配置
vim /etc/haproxy/haproxy.cfg
验证配置:
haproxy -c -f /etc/haproxy/haproxy.cfg
变更后重启:
systemctl restart haproxy
笔记
- HAProxy 已安装,但未自动完成配置
- 确保
/etc/haproxy/haproxy.cfg请在使用前确认已正确设置 - 每次变更后都需要重启服务
- 默认配置为空,服务将无法正常运行