记一次学习过程

这是一次学习过程的小感悟,在此记录下来。

背景

有个软件叫HAproxy,HAProxy是一个使用C语言编写的自由及开放源代码软件,其提供高可用性、负载均衡,以及基于TCP和HTTP的应用程序代理。

考虑到这个软件的功能,后期一些公司的业务可能会采用这个软件,需要提前进行一些准备。一些学习过程,这个学习过程挺有意思,再此记录一下。

过程

  1. 首先访问Haproxy官方网站
    426671-052d70569af6bec7.png
    网站标题

映入眼帘的就是这个软件的功能,然后软件主页面就是这个软件的描述,特性,支持的平台,还有性能。以及下载链接与文档。

  1. 打开文档进行翻阅,希望找到这个软件的用法。


    426671-90c5cf0d75276266.png
    软件的参考文档部分
  2. 点进文档之后,发现还是有点一脸懵逼。一般我们查阅软件,都是先看一下starter guide,或者get startd,这样会对软件有个基本的概览,也就是软件的overview。但是HAproxy的入门指导都是说特性的,没有告诉我怎么使用。

426671-eafa11f77eb15194.png
入门指导
  1. 文档给的有点让人摸不着头脑只好搜别人写的文章了。搜别人文章的时候看的也是有点不清不楚的..,可能不符合我想要的结果,反正就是花了一些时间。

注意:google搜出来的入门指引文章一般写的还都不错的,只是我当时直接用百度搜的,随便看了几个,觉得写的不够好,逻辑啰嗦。

  1. 曙光,其实百闻不如一见,我一直去搜这个软件是做什么的,怎么去用,自己还没有下载呢。一下载之后,立马恍然大悟,原来是这样的!
    5.1 首先看软件包的结构分布在那个目录。
    426671-84590d306d7d0248.png
    Haproxy 软件包的解构

5.2 再看软件的配置文件,让大家观赏一下Haproxy的配置文件,会觉得很清晰。总的来说有案例确实比光在哪里说理论容易让人懂。

[root@6dfeee293f4d /]# cat /etc/haproxy/haproxy.cfg
#---------------------------------------------------------------------
# Example configuration for a possible web application.  See the
# full configuration options online.
#
#   http://haproxy.1wt.eu/download/1.4/doc/configuration.txt
#
#---------------------------------------------------------------------

#---------------------------------------------------------------------
# Global settings
#---------------------------------------------------------------------
global
    # to have these messages end up in /var/log/haproxy.log you will
    # need to:
    #
    # 1) configure syslog to accept network log events.  This is done
    #    by adding the '-r' option to the SYSLOGD_OPTIONS in
    #    /etc/sysconfig/syslog
    #
    # 2) configure local2 events to go to the /var/log/haproxy.log
    #   file. A line like the following can be added to
    #   /etc/sysconfig/syslog
    #
    #    local2.*                       /var/log/haproxy.log
    #
    log         127.0.0.1 local2

    chroot      /var/lib/haproxy
    pidfile     /var/run/haproxy.pid
    maxconn     4000
    user        haproxy
    group       haproxy
    daemon

    # turn on stats unix socket
    stats socket /var/lib/haproxy/stats

#---------------------------------------------------------------------
# common defaults that all the 'listen' and 'backend' sections will
# use if not designated in their block
#---------------------------------------------------------------------
defaults
    mode                    http
    log                     global
    option                  httplog
    option                  dontlognull
    option http-server-close
    option forwardfor       except 127.0.0.0/8
    option                  redispatch
    retries                 3
    timeout http-request    10s
    timeout queue           1m
    timeout connect         10s
    timeout client          1m
    timeout server          1m
    timeout http-keep-alive 10s
    timeout check           10s
    maxconn                 3000

#---------------------------------------------------------------------
# main frontend which proxys to the backends
#---------------------------------------------------------------------
frontend  main *:5000
    acl url_static       path_beg       -i /static /images /javascript /stylesheets
    acl url_static       path_end       -i .jpg .gif .png .css .js

    use_backend static          if url_static
    default_backend             app

#---------------------------------------------------------------------
# static backend for serving up images, stylesheets and such
#---------------------------------------------------------------------
backend static
    balance     roundrobin
    server      static 127.0.0.1:4331 check

#---------------------------------------------------------------------
# round robin balancing between the various backends
#---------------------------------------------------------------------
backend app
    balance     roundrobin
    server  app1 127.0.0.1:5001 check
    server  app2 127.0.0.1:5002 check
    server  app3 127.0.0.1:5003 check
    server  app4 127.0.0.1:5004 check
  1. 知道了软件包的结构与配置文件结构,下面只需要看官方文档就好了,别人的文章可以稍微参考一些。接下来就可以使用这个软件了。

重点

我记录这次学习过程,主要是看案例的时候有种突然明白的感觉。想到了学习时候,怎么样学习才会高效一些呢。这在学习软件的时候还是挺有效果的。

  1. 先看整体的案例(example)。

  2. 看案例的部分,各个结构,有些东西不懂没关系,思考一下这个案例的内容,想通一些可以想通的东西。

  3. 试着去搜案例中的东西学习。了解每一块的内容,把它弄清楚。

我想了一下,除了软件领域,在生活中的领域,比如我要学习其他领域的某个东西。
我是不是要先了解Overview,然后对感兴趣的部分进行深入,找到参考,了解这个领域的功能特性之后,然后在需要的时候,再拿出来使用。

总结

这是一次个人学习过程中的一点小小的思考与发现,学习之道应该远不止这么简单,愿一起探索学习之路。

猜你喜欢

转载自blog.csdn.net/weixin_34345753/article/details/87635199