3.全局参数

在global这个节点里的参数是“进程范围的”并且经常是“操作系统指定”的。它们通常是一次性设置而且一旦正确设置不需要动来动去的。它们中的
一些和命令行对应。

global节点支持以下关键词:

* 进程管理和安全
- ca-base
- chroot
- crt-base
- cpu-map
- daemon
- description
- deviceatlas-json-file
- deviceatlas-log-level
- deviceatlas-separator
- deviceatlas-properties-cookie
- external-check
- gid
- group
- hard-stop-after
- log
- log-tag
- log-send-hostname
- lua-load
- nbproc
- nbthread
- node
- pidfile
- presetenv
- resetenv
- uid
- ulimit-n
- user
- setenv
- stats
- ssl-default-bind-ciphers
- ssl-default-bind-ciphersuites
- ssl-default-bind-options
- ssl-default-server-ciphers
- ssl-default-server-ciphersuites
- ssl-default-server-options
- ssl-dh-param-file
- ssl-server-verify
- unix-bind
- unsetenv
- 51degrees-data-file
- 51degrees-property-name-list
- 51degrees-property-separator
- 51degrees-cache-size
- wurfl-data-file
- wurfl-information-list
- wurfl-information-list-separator
- wurfl-engine-mode
- wurfl-cache-size
- wurfl-useragent-priority

* 性能调节

- max-spread-checks
- maxconn
- maxconnrate
- maxcomprate
- maxcompcpuusage
- maxpipes
- maxsessrate
- maxsslconn
- maxsslrate
- maxzlibmem
- noepoll
- nokqueue
- nopoll
- nosplice
- nogetaddrinfo
- noreuseport
- profiling.tasks
- spread-checks
- server-state-base
- server-state-file
- ssl-engine
- ssl-mode-async
- tune.buffers.limit
- tune.buffers.reserve
- tune.bufsize
- tune.chksize
- tune.comp.maxlevel
- tune.h2.header-table-size
- tune.h2.initial-window-size
- tune.h2.max-concurrent-streams
- tune.http.cookielen
- tune.http.logurilen
- tune.http.maxhdr
- tune.idletimer
- tune.lua.forced-yield
- tune.lua.maxmem
- tune.lua.session-timeout
- tune.lua.task-timeout
- tune.lua.service-timeout
- tune.maxaccept
- tune.maxpollevents
- tune.maxrewrite
- tune.pattern.cache-size
- tune.pipesize
- tune.rcvbuf.client
- tune.rcvbuf.server
- tune.recv_enough
- tune.runqueue-depth
- tune.sndbuf.client
- tune.sndbuf.server
- tune.ssl.cachesize
- tune.ssl.lifetime
- tune.ssl.force-private-cache
- tune.ssl.maxrecord
- tune.ssl.default-dh-param
- tune.ssl.ssl-ctx-cache-size
- tune.ssl.capture-cipherlist-size
- tune.vars.global-max-size
- tune.vars.proc-max-size
- tune.vars.reqres-max-size
- tune.vars.sess-max-size
- tune.vars.txn-max-size
- tune.zlib.memlevel
- tune.zlib.windowsize

* 排错

- debug
- quiet

3.1 进程管理和安全

ca-base <dir>

当直接用“ca-file“表示ssL ca证书路径,“crl-file”关联crl路径,这个参数用来指定一个用来获取SSL CA证书和CRL(证书吊销列表)
的默认路径。绝对路径通常被指定在”ca-file“和“ctl-file”中,并且忽略"ca-base".

chroot <jail dir>

把当前目录切换到指定目录,并且在切换之前会抛弃所有的权限。这样做会增加安全等级以防止位置的漏洞被侦测。这样攻击者就很难
威胁到整个系统。这个选项只有用超级管理员权限启动进程的时候才有效。一定要确保你要切换的目录<jail_dir>是空的,并且任何用户没有写的权限。

cpu-map [auto:]<process-set>[/<thread-set>] <cpu-set>...

在Linux 2.6内核及以上版本,可以绑定一个进程或者线程到指定的CPU上。这意味着被指定的进程或者线程永远不会在指定以外的CPU上运行。“cpu-map”直接
指定CPU给指定的进程或线程用。第一个参数是一个进程,之后跟着一个线程。格式如下:

all | odd | even | number[-[number]]

<number> 必须是1到32者64中的一个,这取决于你的机器字节大小。任何在nbproc之上的进程ID和任何在nbthread之上的
线程ID都是被忽略的。可以用两个数字中间加("-")来指定一个范围。也可以用“all”指定所有的进程。只有奇数数字用“odd”
或者偶数数字用"even",就像用“bind-process”指令。第二个参数是CPU设置。每个CPU设置是一个介于0到31或者0到63或者两
个数字用“-”连接的唯一标识。你为每个cpu设置了标识,就可以绑定进程和线程了。显而易见,如果你想这样,你得设置
多个“cpu-map”指令。每个指令会覆盖之前与它发生冲突的指令。一个线程将绑定在它的映射和它附属的进程之一。如果线程没有
被映射而且它的进程也没有被映射,那么这个线程则不会被绑定。

我们可以定义部分范围。大的那个数字可以被省略。如果这样的话,大的那个数字就会被相应的最大数字替代,比如32或者64.这取决于你的机器字节大小。

你可以前面加上前缀“auto:”,这样可以在增加新的CPU或者新的进程、线程的时候让Haproxy自动绑定。为了确保设置有效,两个设置要有同样的size。
不管定义的CPU的顺序,它总是从下至上搜寻。把“auto:”前缀同时加到进程和线程的范围前面是不支持的。只有一个范围被支持,其他一个必须是精确的数字。

示例:
cpu-map 1-4 0-3 # 绑定标识为1到4的进程到前4个cpu

cpu-map 1/all 0-3 # 绑定第一个进程的所有线程到前4个CPU

cpu-map 1- 0- # 将会被替换成"cpu-map 1-64 0-63"
# 或者"cpu-map 1-32 0-31"这取决于你的机器字节大小

# 所有这些行绑定进程1到cpu0,进程2到cpu1,以此类推。
cpu-map auto:1-4 0-3
cpu-map auto:1-4 0-1 2-3
cpu-map auto:1-4 3 2 1 0

# 所有这些行绑定线程1到cpu0,线程2到cpu1,以此类推
cpu-map auto:1/1-4 0-3
cpu-map auto:1/1-4 0-1 2-3
cpu-map auto:1/1-4 3 2 1 0

# 使用all/odd/even关键词绑定每个进程到精确到cpu上
cpu-map auto:all 0-63
cpu-map auto:even 0-31
cpu-map auto:odd 32-63

# 无效的cpu-map设置,因为进程和cpu配置没有同样的数量
cpu-map auto:1-4 0 # invalid
cpu-map auto:1 0-3 # invalid

# 无效的cpu-map设置,因为自动绑定作用在了进程范围上
# and a thread range.
cpu-map auto:all/all 0 # invalid
cpu-map auto:all/1-4 0 # invalid
cpu-map auto:1-4/all 0 # invalid

crt-base <dir>

当用“crtfile”指令时,指定一个默认目录用来获取从这个指令SSL证书。在"crtfile"指令之后指定绝对路径会覆盖"crtfile"设置
并且忽略“crt-base”。

daemon

可以让进程在后台挂起。这种操作是被推荐的。相当于在命令行中用“-D”参数。也可以用“-db”来禁用。这个选项在systemd模式无效。

deviceatlas-json-file <path>

设置通过API加载的DeviceAtlas json数据的路径。这个路径必须是一个有效的json数据文件并且能被
HAProxy进程访问。

deviceatlas-log-level <value>

设置API返回信息的等级。这个指令是可选的如果不设置默认为0.

deviceatlas-separator <char>

设置API属性结果的字符分隔符。这个指令是可选的如果不设置默认为|。

deviceatlas-properties-cookie <name>

设置客户端的cooke名字,它是用来侦测在请求期间DeviceAtlas 客户端组件是否被使用。这个指令是可选的
如果不设置默认为DAPROPS.

external-check

允许使用外部代理来进行健康检查。这个指令由于安全原因默认被禁止的。

gid <number>

修改进程的group ID 为指定数字。推荐group id使用HAProxy的专用id或者一个类似的小的守护进程设置。
HAProxy必须用一个属于这个组的用户或者拥有超级用户权限的用户启动。注意,如果haproxy从一个
拥有额外组的用户启动了,那么如果从一个超级用户启动它只能丢弃这些额外组的权限。
你还可以参考“group”和“uid”。

hard-stop-after <time>

定义了用来处理一个清除软停止(clean soft-stop)所能执行的最大时间。

讨论:
<time> 是soft-stop在收到SIGUSR1信号后一个应用所能存活的最长时间(默认毫秒为单位)。

这可能是用来确保就算应用在软停止(soft-stop)期间,就算连接还在保持打开状态,应用依然会
被关闭。(比如tcp代理模式中的long timeouts)此设置TCP和HTTP模式都有效。

示例:
global
hard-stop-after 30s

group <group name>

类似于"gid",但是用/etc/group 中的group name来替代GID。可以参考gid和user指令。

未完待续,这章比较长,要分很多篇来完成。

------------------------------以下是英文原文-------------------------------

3. Global parameters

  1. Parameters in the "global" section are process-wide and often OS-specific. They
  2. are generally set once for all and do not need being changed once correct. Some
  3. of them have command-line equivalents.
  4.  
  5. The following keywords are supported in the "global" section :
  6.  
  7. * Process management and security
  8. - ca-base
  9. - chroot
  10. - crt-base
  11. - cpu-map
  12. - daemon
  13. - description
  14. - deviceatlas-json-file
  15. - deviceatlas-log-level
  16. - deviceatlas-separator
  17. - deviceatlas-properties-cookie
  18. - external-check
  19. - gid
  20. - group
  21. - hard-stop-after
  22. - log
  23. - log-tag
  24. - log-send-hostname
  25. - lua-load
  26. - nbproc
  27. - nbthread
  28. - node
  29. - pidfile
  30. - presetenv
  31. - resetenv
  32. - uid
  33. - ulimit-n
  34. - user
  35. - setenv
  36. - stats
  37. - ssl-default-bind-ciphers
  38. - ssl-default-bind-ciphersuites
  39. - ssl-default-bind-options
  40. - ssl-default-server-ciphers
  41. - ssl-default-server-ciphersuites
  42. - ssl-default-server-options
  43. - ssl-dh-param-file
  44. - ssl-server-verify
  45. - unix-bind
  46. - unsetenv
  47. - 51degrees-data-file
  48. - 51degrees-property-name-list
  49. - 51degrees-property-separator
  50. - 51degrees-cache-size
  51. - wurfl-data-file
  52. - wurfl-information-list
  53. - wurfl-information-list-separator
  54. - wurfl-engine-mode
  55. - wurfl-cache-size
  56. - wurfl-useragent-priority
  57.  
  58. * Performance tuning
  59. - max-spread-checks
  60. - maxconn
  61. - maxconnrate
  62. - maxcomprate
  63. - maxcompcpuusage
  64. - maxpipes
  65. - maxsessrate
  66. - maxsslconn
  67. - maxsslrate
  68. - maxzlibmem
  69. - noepoll
  70. - nokqueue
  71. - nopoll
  72. - nosplice
  73. - nogetaddrinfo
  74. - noreuseport
  75. - profiling.tasks
  76. - spread-checks
  77. - server-state-base
  78. - server-state-file
  79. - ssl-engine
  80. - ssl-mode-async
  81. - tune.buffers.limit
  82. - tune.buffers.reserve
  83. - tune.bufsize
  84. - tune.chksize
  85. - tune.comp.maxlevel
  86. - tune.h2.header-table-size
  87. - tune.h2.initial-window-size
  88. - tune.h2.max-concurrent-streams
  89. - tune.http.cookielen
  90. - tune.http.logurilen
  91. - tune.http.maxhdr
  92. - tune.idletimer
  93. - tune.lua.forced-yield
  94. - tune.lua.maxmem
  95. - tune.lua.session-timeout
  96. - tune.lua.task-timeout
  97. - tune.lua.service-timeout
  98. - tune.maxaccept
  99. - tune.maxpollevents
  100. - tune.maxrewrite
  101. - tune.pattern.cache-size
  102. - tune.pipesize
  103. - tune.rcvbuf.client
  104. - tune.rcvbuf.server
  105. - tune.recv_enough
  106. - tune.runqueue-depth
  107. - tune.sndbuf.client
  108. - tune.sndbuf.server
  109. - tune.ssl.cachesize
  110. - tune.ssl.lifetime
  111. - tune.ssl.force-private-cache
  112. - tune.ssl.maxrecord
  113. - tune.ssl.default-dh-param
  114. - tune.ssl.ssl-ctx-cache-size
  115. - tune.ssl.capture-cipherlist-size
  116. - tune.vars.global-max-size
  117. - tune.vars.proc-max-size
  118. - tune.vars.reqres-max-size
  119. - tune.vars.sess-max-size
  120. - tune.vars.txn-max-size
  121. - tune.zlib.memlevel
  122. - tune.zlib.windowsize
  123.  
  124. * Debugging
  125. - debug
  126. - quiet

3.1. Process management and security

ca-base <dir>
  1. Assigns a default directory to fetch SSL CA certificates and CRLs from when a
  2. relative path is used with "ca-file" or "crl-file" directives. Absolute
  3. locations specified in "ca-file" and "crl-file" prevail and ignore "ca-base".
chroot <jail dir>
  1. Changes current directory to <jail dir> and performs a chroot() there before
  2. dropping privileges. This increases the security level in case an unknown
  3. vulnerability would be exploited, since it would make it very hard for the
  4. attacker to exploit the system. This only works when the process is started
  5. with superuser privileges. It is important to ensure that <jail_dir> is both
  6. empty and non-writable to anyone.
cpu-map [auto:]<process-set>[/<thread-set>] <cpu-set>...
  1. On Linux 2.6 and above, it is possible to bind a process or a thread to a
  2. specific CPU set. This means that the process or the thread will never run on
  3. other CPUs. The "cpu-map" directive specifies CPU sets for process or thread
  4. sets. The first argument is a process set, eventually followed by a thread
  5. set. These sets have the format
  6.  
  7. all | odd | even | number[-[number]]
  8.  
  9. <number>> must be a number between 1 and 32 or 64, depending on the machine's
  10. word size. Any process IDs above nbproc and any thread IDs above nbthread are
  11. ignored. It is possible to specify a range with two such number delimited by
  12. a dash ('-'). It also is possible to specify all processes at once using
  13. "all", only odd numbers using "odd" or even numbers using "even", just like
  14. with the "bind-process" directive. The second and forthcoming arguments are
  15. CPU sets. Each CPU set is either a unique number between 0 and 31 or 63 or a
  16. range with two such numbers delimited by a dash ('-'). Multiple CPU numbers
  17. or ranges may be specified, and the processes or threads will be allowed to
  18. bind to all of them. Obviously, multiple "cpu-map" directives may be
  19. specified. Each "cpu-map" directive will replace the previous ones when they
  20. overlap. A thread will be bound on the intersection of its mapping and the
  21. one of the process on which it is attached. If the intersection is null, no
  22. specific binding will be set for the thread.
  23.  
  24. Ranges can be partially defined. The higher bound can be omitted. In such
  25. case, it is replaced by the corresponding maximum value, 32 or 64 depending
  26. on the machine's word size.
  27.  
  28. The prefix "auto:" can be added before the process set to let HAProxy
  29. automatically bind a process or a thread to a CPU by incrementing
  30. process/thread and CPU sets. To be valid, both sets must have the same
  31. size. No matter the declaration order of the CPU sets, it will be bound from
  32. the lowest to the highest bound. Having a process and a thread range with the
  33. "auto:" prefix is not supported. Only one range is supported, the other one
  34. must be a fixed number.
Examples:

  1. cpu-map 1-4 0-3 # bind processes 1 to 4 on the first 4 CPUs
  2. cpu-map 1/all 0-3 # bind all threads of the first process on the
  3. # first 4 CPUs
  4. cpu-map 1- 0- # will be replaced by "cpu-map 1-64 0-63"
  5. # or "cpu-map 1-32 0-31" depending on the machine's
  6. # word size.
  7. # all these lines bind the process 1 to the cpu 0, the process 2 to cpu 1
  8. # and so on.
  9. cpu-map auto:1-4 0-3
  10. cpu-map auto:1-4 0-1 2-3
  11. cpu-map auto:1-4 3 2 1 0
  12. # all these lines bind the thread 1 to the cpu 0, the thread 2 to cpu 1
  13. # and so on.
  14. cpu-map auto:1/1-4 0-3
  15. cpu-map auto:1/1-4 0-1 2-3
  16. cpu-map auto:1/1-4 3 2 1 0
  17. # bind each process to exactly one CPU using all/odd/even keyword
  18. cpu-map auto:all 0-63
  19. cpu-map auto:even 0-31
  20. cpu-map auto:odd 32-63
  21. # invalid cpu-map because process and CPU sets have different sizes.
  22. cpu-map auto:1-4 0 # invalid
  23. cpu-map auto:1 0-3 # invalid
  24. # invalid cpu-map because automatic binding is used with a process range
  25. # and a thread range.
  26. cpu-map auto:all/all 0 # invalid
  27. cpu-map auto:all/1-4 0 # invalid
  28. cpu-map auto:1-4/all 0 # invalid
crt-base <dir>
  1. Assigns a default directory to fetch SSL certificates from when a relative
  2. path is used with "crtfile" directives. Absolute locations specified after
  3. "crtfile" prevail and ignore "crt-base".
  1. Makes the process fork into background. This is the recommended mode of
  2. operation. It is equivalent to the command line "-D" argument. It can be
  3. disabled by the command line "-db" argument. This option is ignored in
  4. systemd mode.
  1. Sets the path of the DeviceAtlas JSON data file to be loaded by the API.
  2. The path must be a valid JSON data file and accessible by HAProxy process.
  1. Sets the level of information returned by the API. This directive is
  2. optional and set to 0 by default if not set.
  1. Sets the character separator for the API properties results. This directive
  2. is optional and set to | by default if not set.
  1. Sets the client cookie's name used for the detection if the DeviceAtlas
  2. Client-side component was used during the request. This directive is optional
  3. and set to DAPROPS by default if not set.
  1. Allows the use of an external agent to perform health checks.
  2. This is disabled by default as a security precaution.
  3. See "option external-check".
gid <number>
  1. Changes the process' group ID to <number>. It is recommended that the group
  2. ID is dedicated to HAProxy or to a small set of similar daemons. HAProxy must
  3. be started with a user belonging to this group, or with superuser privileges.
  4. Note that if haproxy is started from a user having supplementary groups, it
  5. will only be able to drop these groups if started with superuser privileges.
  6. See also "group" and "uid".
  1. Defines the maximum time allowed to perform a clean soft-stop.
Arguments :

  1. <time> is the maximum time (by default in milliseconds) for which the
  2. instance will remain alive when a soft-stop is received via the
  3. SIGUSR1 signal.
  1. This may be used to ensure that the instance will quit even if connections
  2. remain opened during a soft-stop (for example with long timeouts for a proxy
  3. in tcp mode). It applies both in TCP and HTTP mode.
Example:

  1. global
  2. hard-stop-after 30s
group <group name>
  1. Similar to "gid" but uses the GID of group name <group name> from /etc/group.
  2. See also "gid" and "user".

Haproxy官方文档翻译(第三章)全局参数(1) 附英文原文的更多相关文章

  1. Haproxy官方文档翻译(第二章)配置Haproxy 附英文原文

    2.配置 HAProxy 2.1 配置文件格式 Haproxy的配置过程包含了3部分的参数资源:- 命令行中的参数,此种参数总是享有优先权被使用- 配置文件中global节点中的参数,此种参数是进程范 ...

  2. MySQL文档翻译(八)附英文原文---性能优化概览

    优化概述 数据库性能表现依赖于数据库级别的几个因素,比如表,查询和配置设置.这些软件在硬件级别通过CPU和IO操作构筑结果,你需要尽可能的使用最少的资源达到最大的效果.当你专注于数据库的性能表现时,你 ...

  3. Spring官方文档翻译(1~6章)

    Spring官方文档翻译(1~6章) 转载至 http://blog.csdn.net/tangtong1/article/details/51326887 Spring官方文档.参考中文文档 一.S ...

  4. omnet++:官方文档翻译总结(三)

    翻译总结自:Turning it Into a Real Network - OMNeT++ Technical Articles 接官方文档翻译总结(二),本节主要是真实网络的搭建 Part 4 - ...

  5. kong插件官方文档翻译

    kong插件官方文档翻译 目录 介绍 文件结构 编写自定义逻辑 存储配置 访问数据存储 自定义实体 缓存自定义实体 扩展Admin API 编写测试 (卸载)安装你的插件 插件开发 - 介绍 什么是插 ...

  6. 简学Python第三章__函数式编程、递归、内置函数

    #cnblogs_post_body h2 { background: linear-gradient(to bottom, #18c0ff 0%,#0c7eff 100%); color: #fff ...

  7. 第三章 JavaScript操作BOM对象

    第三章   JavaScript操作BOM对象 一.window对象 浏览器对象模型(BOM)是javascript的组成之一,它提供了独立与浏览器窗口进行交换的对象,使用浏览器对象模型可以实现与HT ...

  8. Java Persistence with MyBatis 3(中文版) 第三章 使用XML配置SQL映射器

    关系型数据库和SQL是经受时间考验和验证的数据存储机制.和其他的ORM 框架如Hibernate不同,MyBatis鼓励开发者可以直接使用数据库,而不是将其对开发者隐藏,因为这样可以充分发挥数据库服务 ...

  9. 多线程---iOS-Apple苹果官方文档翻译

    本系列所有开发文档翻译链接地址:iOS7开发-Apple苹果iPhone开发Xcode官方文档翻译PDF下载地址(2013年12月29日更新版)   多线程  技术博客http://www.cnblo ...

随机推荐

  1. graph engine

    有个侥幸的机会,参与了微软的项目,侥幸的接触了,graph engine图形数据库,感觉很是新颖,做点记录,和大家分享,理解有限,发现不足之处,还请指点. 微软发分布式图处理引擎GraphEngine ...

  2. [No000019A]【波浪理论精典教学课程】

    波浪理论的产生和发展     拉尔夫·纳尔逊·艾略特(Ralph Nelson Elliott ),是波浪理论的创始人.1871年7月28日出生在美国密苏里州堪萨斯市的玛丽斯维利镇Marysville ...

  3. 2019年5款你必须知道的顶级ASO优化工具

    仅仅几年前,品牌一直在挣扎着进入顶级榜单的时候.但随着时代的变迁,以及技术承担着市场的每一个噱头,一切都发生了变化,包括市场的传播,消费者行为和品牌影响.今天,品牌不仅仅局限于广告和促销,而且品牌的影 ...

  4. ItunesConnect:"Missing Push Notification Entitlement"警告-----以及解决方法

    最近开发的cordova应用,要做ios的适配,并且发布版本,但是有一次在发测试版本的时候,突然收到一封邮件警告,原文如下: Missing Push Notification Entitlement ...

  5. java连接服务器语法

    一.连接sql步骤 1.加载数据库驱动类 2.获取数据库连接对象 3.写sql4.创建PreparedStatement对象5.执行查询返回ResultSet结果集对象7.释放资源 public st ...

  6. 实验八 Web基础 SQL注入原理

    实验八 Web基础 实验要求 (1)Web前端HTML 能正常安装.启停Apache.理解HTML,理解表单,理解GET与POST方法,编写一个含有表单的HTML. (2)Web前端javascipt ...

  7. 如何把一个vue组件改为ionic/angular组件

    同是mvvm框架,他们之间是很相似的,如何你已经熟悉其中的一个,那么另一个也就基本上也就会的差不多了. 一.动态属性.值.事件绑定 vue中使用v-bind:或者之间分号:进行绑定 ng中左括号[]进 ...

  8. java详细剖析

    1·类型加载主动初始化和被动初始化两种,通过访问静态变量或者给静态变量赋值都是可以使类初始化,如果有继承关系,所依赖的父类都会被动初始化. 2·如果在类的静态变量中添加final关键字,那这个变量就会 ...

  9. war 包tomcat部署和maven的tomcat插件部署的不同

    不用插件 1在linux服务器上下载号tomcat 或者上传tomcat 2上传war包,最好创建一个目录房war包,和tomcat 3解压war包,jar -xvf war   或者unzip wa ...

  10. 【转】Spring Boot 构建应用——快速构建 Spring Boot 应用

    Spring Boot 简化了 Spring 应用开发,不需要配置就能运行 Spring 应用,Spring Boot 的自动配置是通过 Spring 4.x 的条件注解 @Conditional 来 ...