首页 > 数据库 > > 附录-HAProxy配置详情
本节描述HAProxy配置详情。
注意:不当修改可能造成系统HA故障或异常,需谨慎操作。
用户可修改该阶段的global和defaults配置。
#
# Update this configuration file for hardening HAProxy.
#
global
daemon
maxconn 1024
stats timeout 2m
defaults
mode tcp
timeout client 3000s
timeout server 3000s
timeout connect 3s
retries 30
frontend MyFrontend
bind 10.X.X.X:8990^M
default_backend TransparentBack_tcp
backend TransparentBack_tcp
server metricdb11 10.X.X.X:22204 check^M
server metricdb12 10.X.x.x:22204 check backup^M
其余配置将被启动Proxy的python脚本修改。
用户可修改任何信息,但修改后,需重启proxy文件。安装后修改的配置文件不能是安装包中的配置文件。
安装完成后,系统会生成新的WEB和MS、PRMARY DB及指标 DB配置文件。配置文件路径如下:
<dmserver-install-path>/ha
例如:
[dminstalluser@localhost ~]$ cd dmserver/ha
[dminstalluser@localhost ha]$ ll
total 7136
-rw-------. 1 dminstalluser dminstalluser 333 Aug 28 13:47 base_proxy.cfg
-r-x------. 1 dminstalluser dminstalluser 7265766 Aug 28 13:47 haproxy
-rw-------. 1 dminstalluser dminstalluser 457 Sep 4 17:21 haproxy_metricdb1_dm1.cfg
-rw-------. 1 dminstalluser dminstalluser 457 Sep 4 17:21 haproxy_metricdb1_dm2.cfg
-rw-------. 1 dminstalluser dminstalluser 451 Sep 4 17:21 haproxy_primdb_dm1.cfg
-rw-------. 1 dminstalluser dminstalluser 451 Sep 4 17:21 haproxy_primdb_dm2.cfg
-rw-------. 1 dminstalluser dminstalluser 449 Sep 4 17:21 haproxy_web_ms_dm1.cfg
-rw-------. 1 dminstalluser dminstalluser 449 Sep 4 17:21 haproxy_web_ms_dm2.cfg
-rw-------. 1 dminstalluser dminstalluser 1 Sep 4 17:21 last_saved_metricdb1.cfg
-rw-------. 1 dminstalluser dminstalluser 1 Sep 4 17:21 last_saved_primdb.cfg
-rw-------. 1 dminstalluser dminstalluser 1 Sep 4 17:21 last_saved_web_ms.cfg
[dminstalluser@localhost ha]$
6个配置文件中,每个组件(WEB和MS,PRMARY DB,及 指标 DB)生成两个配置文件。
上图中,以“1”结尾的文件(例如,haproxy_primdb_dm1.cfg)包含了将initial_primary_url的值(在install-default-conf文件中进行配置)配置为proxy主IP地址,以及将initial_slave_url的值(在install-default-conf文件进行配置)配置为proxy备份IP地址的信息。
类似的,以“2”结尾的文件(例如,haproxy_primdb_dm2.cfg)包含将initial_slave_url的值配置为proxy主IP地址,以及将initial_primary_url的值配置为proxy备份IP的信息。
用户可以修改任何组件的文件(组件的两个文件需同步修改),修改完成呢个后,进行重启,操作如下:
[dminstalluser@localhost ha]$ ps ux | grep haproxy
dminsta+ 2523 0.0 0.0 17080 976 ? Ss 17:21 :00 /home/dminstalluser/dmserver/ha/haproxy -f /home/dminstalluser/dmserver/ha/haproxy_web_ms_dm1.cfg
dminsta+ 2532 0.3 0.0 17344 1208 ? Ss 17:21 :06 /home/dminstalluser/dmserver/ha/haproxy -f /home/dminstalluser/dmserver/ha/haproxy_primdb_dm1.cfg
dminsta+ 2541 0.0 0.0 17212 1208 ? Ss 17:21 :00 /home/dminstalluser/dmserver/ha/haproxy -f /home/dminstalluser/dmserver/ha/haproxy_metricdb1_dm1.cfg
dminsta+ 25258 0.0 0.0 112664 972 pts/ S+ 17:49 :00 grep --color=auto haproxy
[dminstalluser@localhost ha]$ kill -9 17080 17344 17212 112664
Example: /dmserver/ha> ./haproxy -f haproxy_metricdb1_dm1.cfg
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/69959250/viewspace-3140156/ ,如需转载,请注明出处,否则将追究法律责任。