MQTT haproxy 负载均衡代理服务
来源:互联网 发布:k姐陈洁淘宝为什么火 编辑:程序博客网 时间:2024/06/05 12:42
https://github.com/lelylan/haproxy-mqtt.git
实验环境:
两台Ubuntu 14 虚拟机:
第一台ubuntu设备为代理服务器 :
ubuntu 安装 haproxy 代理服务器
第二台ubuntu设备为 activemq 服务:
ubuntu 安装activemq 消息服务器
修改文件 haproxy.cfg :
global
ulimit-n 9999
maxconn 9999
maxpipes 9999
tune.maxaccept 500
log 127.0.0.1 local0
log 127.0.0.1 local1 notice
chroot /var/lib/haproxy
user haproxy
group haproxy
defaults
log global
mode http
option dontlognull
timeout connect 5000ms
timeout client 50000ms
timeout server 50000ms
errorfile 400 /etc/haproxy/errors/400.http
errorfile 403 /etc/haproxy/errors/403.http
errorfile 408 /etc/haproxy/errors/408.http
errorfile 500 /etc/haproxy/errors/500.http
errorfile 502 /etc/haproxy/errors/502.http
errorfile 503 /etc/haproxy/errors/503.http
errorfile 504 /etc/haproxy/errors/504.http
listen stats :80
stats enable
stats uri / # must be present to see the logs
stats auth admin:admin
listen mqtt
bind *:1883
#bind *:8883 ssl crt /certs/lelylan-mqtt.pem
mode tcp
#Use this to avoid the connection loss when client subscribed for a topic and its idle for sometime
option clitcpka # For TCP keep-alive
timeout client 3h #By default TCP keep-alive interval is 2hours in OS kernal, 'cat /proc/sys/net/ipv4/tcp_keepalive_time'
timeout server 3h #By default TCP keep-alive interval is 2hours in OS kernal
option tcplog
balance leastconn
server node 192.168.253.161:1883 check # 192.168..253.161 为 activemq 消息服务IP
# server mosca_1 178.62.122.204:1883 check
# server mosca_2 178.62.104.172:1883 check
启动 haproxy 服务
./restart.bash
启动 activemq 服务:
~/mqtt/apache-activemq-5.14.5$ ./bin/activemq console
win7 客户端
String user = env("APOLLO_USER", "admin"); String password = env("APOLLO_PASSWORD", "admin");// String host = env("APOLLO_HOST", "localhost"); String host = env("APOLLO_HOST", "192.168.253.134"); // 192.168.253.134 haproxy 服务器IP// int port = Integer.parseInt(env("APOLLO_PORT", "61613")); int port = Integer.parseInt(env("APOLLO_PORT", "1883"));// final String destination = arg(args, 0, "/topic/1/OOOOOOOOOO/aaaa"); final String destination = arg(args, 0, "topic");
- MQTT haproxy 负载均衡代理服务
- Haproxy——反向代理负载均衡
- haproxy 7层负载均衡代理转发实战讲解
- CentOS5.6 部署haproxy代理做负载均衡
- Mysql的Haproxy反向代理和负载均衡
- Mysql的Haproxy反向代理和负载均衡
- 使用haproxy实现反向代理负载均衡实战
- Haproxy+KeepAlived 负载均衡
- 负载均衡(haproxy+keepalive)
- haproxy负载均衡配置
- Haproxy+KeepAlived 负载均衡
- HAProxy MySQL负载均衡
- haproxy + redis 负载均衡
- Keepalived+HAproxy负载均衡
- Haproxy+KeepAlived 负载均衡
- haproxy安装.负载均衡
- Haproxy负载均衡算法
- Thrift+Haproxy负载均衡
- 如何建议一个数据库内的定时任务
- Linux 查看CPU信息,机器型号,内存等信息
- 微信清除缓存的两种方法
- 【Codeforces 814 B. An express train to reveries】+ 构造
- 大数据-十一
- MQTT haproxy 负载均衡代理服务
- C++学习笔记-----用位运算实现加减乘除
- Poedu_Windows_异步IO(2)
- JNI 数组返回值问题记录
- 程序员实用网站集锦
- Linux操作系统下,通过系统调用和库函数分别实现对文件的拷贝
- 【HTML5】WebSocket和SSE
- Latex 数学公式
- Netty实现简单HTTP服务器