zoukankan      html  css  js  c++  java
  • 关于Haproxy安装和配置:负载配置【haproxy.cfg】问题记录

    1.  存放地址:
    more /etc/haproxy/haproxy.cfg
    ps -ef | grep haproxy
    看看有没有haproxy的进程就是了
    或者看看服务器的23306的端口有没有打开
    netstat -an | grep 23306

    2. 问一个问题,安装了haproxy,自己默认就会产生/etc/haproxy.cfg
    这个文件吗? 还是安装好了之后要拷过去呢?
    都不是
    要自己创建!一般放在/etc/haproxy.cfg!
    这个文件和里面的内容都自己手工创建?  -- 对头

    另外,我自己创建的haproxy.cfg文件,haproxy怎么知道我这个文件在哪里呢?
     你启动haproxy的时候要加参数去指定配置文件的位置!
     也就是说我创建N个配置都可以,只要启动时告诉他加载哪一个就OK了?
    对头 

    我们启动haproxy命令
    /usr/local/haproxy/sbin/haproxy -f /etc/haproxy.cfg




    启动HA
     启动就是
    /usr/local/haproxy/sbin/haproxy -f /etc/haproxy.cfg



    3. 启动、停止HA
    haproxy没得停止的命令
    直接kill掉进程
    Last login: Wed Mar 5 18:04:33 2014 from 172.16.3.218
    [root@gsidc-4q-saas16 ~]# ps -ef | grep haproxy
    root 11687 1 0 Mar05 ? 00:00:00 /usr/local/haproxy/sbin/haproxy -f /etc/haproxy.cfg
    root 14188 14159 0 15:00 pts/1 00:00:00 grep haproxy
    [root@gsidc-4q-saas16 ~]# kill -9 11687
    [root@gsidc-4q-saas16 ~]# ps -ef | grep haproxy
    root 14197 14159 0 15:01 pts/1 00:00:00 grep haproxy
    [root@gsidc-4q-saas16 ~]# /usr/local/haproxy/sbin/haproxy -f /etc/haproxy.cfg
    [root@gsidc-4q-saas16 ~]# ps -ef | grep haproxy
    root 14199 1 0 15:01 ? 00:00:00 /usr/local/haproxy/sbin/haproxy -f /etc/haproxy.cfg
    root 14201 14159 0 15:01 pts/1 00:00:00 grep haproxy
    [root@gsidc-4q-saas16 ~]# 

    4. 实际配置文件

     haproxy.cfg

    global
            log     127.0.0.1   local0
            maxconn 4096
            stats socket /tmp/haproxy.socket uid haproxy mode 770 level admin
            # nbproc  2
            pidfile /tmp/haproxy.pid
            daemon

    defaults
            log     global
            log     127.0.0.1   local0
            mode    tcp
            option  tcplog
            option  dontlognull
            retries 3
            option  redispatch
            maxconn 2000
            timeout connect 5s
            timeout client  120s
            timeout server  120s

    listen mysql_proxy :23306
            mode    tcp
            balance roundrobin
            server  mysql_65 172.16.12.65:3306 check inter 5000 rise 2 fall 3
            server  mysql_67 172.16.12.67:3306 check inter 5000 rise 2 fall 3

    listen private_monitoring :8101
            mode    http
            option  httplog
            stats   enable
            stats   uri       /stats
            stats   refresh   5s


    5. 关键设置 

    【添加负载均衡,只需要设置这里】

     

    希望对安装的你有所帮助,喜欢请赞一下!

    Meet so Meet. C plusplus I-PLUS....
  • 相关阅读:
    c#报错信息 显示详细行号
    分析器错误消息: “webgroup.admin.index”不扩展类“System.Web.UI.Page”,因此此处不允许
    ASP.NET下AJAX.AJAXMETHOD使用方法,微软ajax 异步 同步的修改方法
    Jquery实际应用,判断radio,selelct,checkbox是否选中及选中的值,jquery如果获取多个重复name的input的值
    utf8编码的mysql数据库 按照 中文来对 名称进行排序
    MVC新手教程二:Action使用非默认视图,强类型和强类型视图
    gcc 编译多个源文件
    嵌入式学习路径
    C语言基础知识:printf的输出格式
    C语言的数据类型
  • 原文地址:https://www.cnblogs.com/iplus/p/4464711.html
Copyright © 2011-2022 走看看