HAproxy

Ubuntu编译安装HAprox+Keepalived+MySQL负载高可用架构(结合Docker容器配置)

匆匆过客 提交于 2019-12-04 18:41:33
系统环境: Ubuntu16.04(Docker容器) 架构环境: Keepalived/HAproxy MASTER: 172.17.0.4 Keepalived/HAproxy BACKUP: 172.17.0.6 MySQL MASTER: 172.17.0.2 MySQL SLAVE: 172.17.0.3 HAproxy版本:haproxy-2.0.8.tar.gz Keepalived版本:keepalived-2.0.19.tar.gz 一、安装 HAproxy(MASTER/BACKUP两台都要装) 1、前往官网 https://www.haproxy.org/ 下载 HAproxy 解压,进入 haproxy-2.0.8目录 vim INSTALL;查看安装说明 2、编译安装HAproxy ( 1)编译 报错 1:bash: make: command not found 我直接用 docker容易,make命令没安装,安装一下: apt-get -y install make 然后执行: make -j 2 TARGET=generic USE_GZIP=1 报错 2:/bin/sh: 1: gcc: not found 未安装 gcc,安装gcc: apt-get -y install gcc 然后再执行: make -j 2 TARGET=generic

HAProxy doesn't start, can not bind UNIX socket [/run/haproxy/admin.sock]

狂风中的少年 提交于 2019-12-04 16:47:00
问题 I'm trying to start haproxy (version 1.5.8 2014/10/31) with an "empty" config file and I get: user@server:~$ sudo service haproxy start [....] Starting haproxy: haproxy[ALERT] 126/120540 (7363) : Starting frontend GLOBAL: cannot bind UNIX socket [/run/haproxy/admin.sock] altough it's enabled: user@server:~$ cat /etc/default/haproxy # Set ENABLED to 1 if you want the init script to start haproxy. ENABLED=1 Configuration file: global log /dev/log local0 log /dev/log local1 notice chroot /var

haproxy - unable to load SSL private key from PEM file

情到浓时终转凉″ 提交于 2019-12-04 15:07:13
问题 haproxy does not start anymore, it shows the error bind <ip>:443' : unable to load SSL private key from PEM file ... We did not change anything on the certificates or configuration. Since the last start we only made normal updates to the system. To find the error, I generated a completely new certificate (self signed) but the error still exists. This is the structure of the PEM file: -----BEGIN CERTIFICATE----- MIIDXjCCAkY... -----END CERTIFICATE----- -----BEGIN RSA PRIVATE KEY-----

Haproxy tuning for performance?

心不动则不痛 提交于 2019-12-04 14:56:03
We are trying to find the best tuning options for haproxy for get and post request that come from a client (not users browsing the web type of deal). Running a jmeter test with 30k threads that consists of 5 calls to the servers, 1 user reg, and a few update calls. These push json data though the pipeline. Here us our current config for haproxy global log /dev/log local0 #notice maxconn 14000 tune.bufsize 128000 user netcom group netcom pidfile /tmp/haproxy.pid daemon nbproc 7 #debug #quiet defaults log global mode http ### Options ### option httplog #option logasap option dontlog-normal

Haproxy + netty: Way to prevent exceptions on connection reset?

天涯浪子 提交于 2019-12-04 12:28:46
问题 We're using haproxy in front of a netty-3.6-run backend. We are handling a huge number of connections, some of which can be longstanding. Now the problem is that when haproxy closes a connection for means of rebalancing, it does so by sending a tcp-RST. When the sun.nio.ch-class employed by netty sees this, it throws an IOException: "Connection reset by peer". Trace: sun.nio.ch.FileDispatcherImpl.read0(Native Method):1 in "" sun.nio.ch.SocketDispatcher.read(SocketDispatcher.java:39):1 in ""

kubeadm安装k8s高可用集群

佐手、 提交于 2019-12-04 11:42:44
kubeadm安装k8s高可用集群 系统版本:CentOS7.5 Kubernetes版本:v1.15.0 docker版本:18.06 k8s-vip k8s-m1 k8s-m2 k8s-m3 192.168.1.200 192.168.1.201 192.168.1.202 192.168.1.203 配置主机名 cat /etc/hosts 127.0.0.1 localhost localhost.localdomain localhost4 localhost4.localdomain4 ::1 localhost localhost.localdomain localhost6 localhost6.localdomain6 192.168.1.201 k8s-m1 192.168.1.202 k8s-m2 192.168.1.203 k8s-m3 hostnamectl set-hostname k8s-m1/2/3 ssh免秘钥登录 ssh-keygen ssh-copy-id root@192.168.1.201/202/203 初始化脚本 cat init_env.sh #!/bin/bash #关闭防火墙 SELINUX systemctl stop firewalld && systemctl disable firewalld setenforce 0

三大主流负载均衡

倾然丶 夕夏残阳落幕 提交于 2019-12-04 11:42:29
LVS: 1、抗负载能力强。抗负载能力强、性能高,能达到F5硬件的60%;对内存和cpu资源消耗比较低 2、工作在网络4层,通过vrrp协议转发(仅作分发之用),具体的流量由linux内核处理,因此没有流量的产生。 2、稳定性、可靠性好,自身有完美的热备方案;(如:LVS+Keepalived) 3、应用范围比较广,可以对所有应用做负载均衡; 4、不支持正则处理,不能做动静分离。 5、支持负载均衡算法:rr(轮循)、wrr(带权轮循)、lc(最小连接)、wlc(权重最小连接) 6、配置 复杂,对网络依赖比较大,稳定性很高。 Ngnix: 1、工作在网络的7层之上,可以针对http应用做一些分流的策略,比如针对域名、目录结构; 2、Nginx对网络的依赖比较小,理论上能ping通就就能进行负载功能; 3、Nginx安装和配置比较简单,测试起来比较方便; 4、也可以承担高的负载压力且稳定,一般能支撑超过1万次的并发; 5、对后端服务器的健康检查,只支持通过端口来检测,不支持通过url来检测。 6、Nginx对请求的异步处理可以帮助节点服务器减轻负载; 7、Nginx仅能支持http、https和Email协议,这样就在适用范围较小。 8、不支持Session的直接保持,但能通过ip_hash来解决。、对Big request header的支持不是很好, 9、支持负载均衡算法

微服务化的十个设计要点

喜欢而已 提交于 2019-12-04 06:43:38
原文: https://juejin.im/entry/5b35a770e51d4558cc35d95c 微服务有哪些要点呢?先看下图是 SpringCloud 的整个生态。 设计要点一:API 网关 在实施微服务的过程中,不免要面临服务的聚合与拆分,当后端服务的拆分相对比较频繁的时候,作为手机 App 来讲,往往需要一个统一的入口,将不同的请求路由到不同的服务,无论后面如何拆分与聚合,对于手机端来讲都是透明的。 有了 API 网关以后,简单的数据聚合可以在网关层完成,这样就不用在手机 App 端完成,从而手机 App 耗电量较小,用户体验较好。 有了统一的 API 网关,还可以进行统一的认证和鉴权,尽管服务之间的相互调用比较复杂,接口也会比较多,API 网关往往只暴露必须的对外接口,并且对接口进行统一的认证和鉴权,使得内部的服务相互访问的时候,不用再进行认证和鉴权,效率会比较高。 有了统一的 API 网关,可以在这一层设定一定的策略,进行 A/B 测试,蓝绿发布,预发环境导流等等。API 网关往往是无状态的,可以横向扩展,从而不会成为性能瓶颈。 设计要点二:无状态化,区分有状态的和无状态的应用 影响应用迁移和横向扩展的重要因素就是应用的状态,无状态服务,是要把这个状态往外移,将 Session 数据,文件数据,结构化数据保存在后端统一的存储中,从而应用仅仅包含商务逻辑。

JWT Validation in HAProxy

被刻印的时光 ゝ 提交于 2019-12-04 05:11:09
I have an HAProxy configured to accept requests to *.mysubdomain.com. The HAProxy will parse the subdomain (prod or dev from prod.mysubdomain.com or dev.mysubdomain.com) and forward to the correct backend. Two backends exist, one for prod and one for dev. Each backend contains two server entries pointing towards Marathon LB instances on each subdomain. The subdomains require a JWT cookie for authentication on the backend. I have the public key to check the validity of the JWT, but would like to do so in the HAProxy. Is there a way to add my own code to perform the JWT validity check within the

How to redirect URL with HAProxy

孤人 提交于 2019-12-04 01:40:29
I need redirect www.foo.com and foo.com to www.bar.com in haproxy, this is my configuration: frontend http-in bind *:80 acl bar.com hdr(host) -i www.bar.com ... use_backend bar.com_cluster if bar.com ... redirect prefix http://foo.com code 301 if { hdr(host) -i www.bar.com } redirect prefix http://www.foo.com code 301 if { hdr(host) -i www.bar.com } ... backend bar.com_cluster balance roundrobin option httpclose option forwardfor server bar 10.0.0.1:80 check I have tried with redirect prefix but don't work, any idea? Change order of the hostname: redirect prefix http://www.bar.com code 301 if