HAProxy 学习笔记-- 配置日志
2012-06-27 15:47
225 查看
HAProxy, "The Reliable, High Performance TCP/HTTP Load Balancer"
使用HAProxy负载若干python websocket实例,安装完HAProxy后,默认情况下,HAProxy为了节省读写IO所消耗的性能,默认情况下没有日志输出,以下是我配置log的过程:
Fedora16 默认使用的是rsyslog管理log
可通过以下shell来检查:
#rpm -q sysklogd syslog-n rsyslog
package sysklogd is not installed
package syslog-n is not installed
rsyslog-5.8.7-1.fc16.i686
#rpm -ql rsyslog | grep conf$
/etc/rsyslog.conf
1.
vim /etc/rsyslog.conf
添加local0.* /var/log/haproxy.log
这里对路径如果修改为/home/xinz/haproxytest/log目录下,由于rsyslog默认情况下,没有访问home目录下的权限,可以参考:
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# grep rsyslogd /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp
2.
rsyslog 默认情况下,需要在514端口监听UDP,所以可以把/etc/rsyslog.conf如下的注释去掉
# Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514
3.重启 rsyslog
service rsyslog restart
service rsyslog status
4.在任意工作目录下,配置如下文件
Haproxy.conf代码
global
log 127.0.0.1 local0 info
maxconn 10000
ulimit-n 30000
defaults
log global
mode http
frontend pub-srv 0.0.0.0:8080
maxconn 10000
timeout client 40s
use_backend websocket if { hdr(Upgrade) -i WebSocket }
default_backend http
backend websocket
timeout connect 100s
timeout server 600s
server ws1 localhost:8084 weight 1 maxconn 5000 check
server ws2 localhost:8085 weight 1 maxconn 5000 check
backend http
timeout connect 40s
timeout server 30s
server www1 localhost:8084 weight 1 maxconn 5000 check
server www2 localhost:8085 weight 1 maxconn 5000 check
5. 如果是public 80端口需要root权限执行,这里简单测试使用8080
haproxy -f ./haproxy.conf
6. 日志输出在/var/log/haproxy.log下
在另一台linux26机器上配置log如下,使用的是syslog
vim /etc/sysconfig/syslog
SYSLOGD_OPTIONS="-m 0 -r"
添加-r参数
-r:enables logging from remote machines
vim /etc/syslog.conf
添加如下内容:
local0.* /var/log/haproxy.log
/sbin/service syslog restart
其他的配置内容步骤是一样的。
使用HAProxy负载若干python websocket实例,安装完HAProxy后,默认情况下,HAProxy为了节省读写IO所消耗的性能,默认情况下没有日志输出,以下是我配置log的过程:
Fedora16 默认使用的是rsyslog管理log
[align=center] [/align] |
#rpm -q sysklogd syslog-n rsyslog
package sysklogd is not installed
package syslog-n is not installed
rsyslog-5.8.7-1.fc16.i686
#rpm -ql rsyslog | grep conf$
/etc/rsyslog.conf
1.
vim /etc/rsyslog.conf
添加local0.* /var/log/haproxy.log
这里对路径如果修改为/home/xinz/haproxytest/log目录下,由于rsyslog默认情况下,没有访问home目录下的权限,可以参考:
You can generate a local policy module to allow this access.
Do
allow this access for now by executing:
# grep rsyslogd /var/log/audit/audit.log | audit2allow -M mypol
# semodule -i mypol.pp
2.
rsyslog 默认情况下,需要在514端口监听UDP,所以可以把/etc/rsyslog.conf如下的注释去掉
# Provides UDP syslog reception
$ModLoad imudp
$UDPServerRun 514
3.重启 rsyslog
service rsyslog restart
service rsyslog status
4.在任意工作目录下,配置如下文件
Haproxy.conf代码
global
log 127.0.0.1 local0 info
maxconn 10000
ulimit-n 30000
defaults
log global
mode http
frontend pub-srv 0.0.0.0:8080
maxconn 10000
timeout client 40s
use_backend websocket if { hdr(Upgrade) -i WebSocket }
default_backend http
backend websocket
timeout connect 100s
timeout server 600s
server ws1 localhost:8084 weight 1 maxconn 5000 check
server ws2 localhost:8085 weight 1 maxconn 5000 check
backend http
timeout connect 40s
timeout server 30s
server www1 localhost:8084 weight 1 maxconn 5000 check
server www2 localhost:8085 weight 1 maxconn 5000 check
5. 如果是public 80端口需要root权限执行,这里简单测试使用8080
haproxy -f ./haproxy.conf
6. 日志输出在/var/log/haproxy.log下
在另一台linux26机器上配置log如下,使用的是syslog
vim /etc/sysconfig/syslog
SYSLOGD_OPTIONS="-m 0 -r"
[align=center] [/align] |
-r:enables logging from remote machines
vim /etc/syslog.conf
添加如下内容:
local0.* /var/log/haproxy.log
/sbin/service syslog restart
其他的配置内容步骤是一样的。
相关文章推荐
- Tomcat学习笔记 - 错误日志 - Tomcat部署项目或修改xml配置出现无法保存的情况(拒绝访问)
- haproxy学习笔记2:1.3.0的配置文件解析
- mosquitto源码学习笔记(3)--日志、配置、database、loop
- haproxy学习笔记之配置文件参数详解
- ASP.NET Core 2.0系列学习笔记-NLog日志配置文件
- Hibernate学习笔记:配置hibernate日志
- nginx学习笔记5 nginx日志文件的配置
- haproxy学习笔记之配置文件参数详解
- Tomcat学习笔记 - 错误日志 - NetBeans配置tomcat出错情况总结 -- 部署错误: 启动 Tomcat 失败。-- '127.0.0.1' 不是内部或外部命令,也不是可运行的程序
- HaProxy学习笔记3: 1.4.23的配置文件解析-examples.cfg
- Tomcat学习笔记 - 错误日志 - Tomcat安装版安装后第二次启动后闪退(转)-- javac不是内部或外部命令 -- 配置java环境教程
- asp.net MVC日志插件Log4Net学习笔记二:保存日志到sqlserver的配置
- Tomcat学习笔记 - 错误日志 - NetBeans配置tomcat出错情况总结 -- 尚未授予访问 Tomcat 服务器的权限。请在服务器管理器的 Tomcat 定制器中设置 "manager-script" 角色的正确用户名和口令。 有关详细信息, 请查看服务器日志。
- hibernate3 学习笔记(三) hibernate 日志配置文件 log4j.properties
- nginx 学习笔记(二)nginx 配置相关
- Spring4学习笔记-AOP(基于配置文件的方式)
- iBatisNet学习笔记一:配置
- Linux 学习笔记_5_Linux引导流程解析_3_GRUB配置及Linux系统修复
- Hbase 学习笔记[1] 安装及配置
- struts2学习笔记一 基本配置及动态方法