我们通常会碰到这样的业务场景:
b主机和c数据库在同一个内网,a主机不能直接访问c数据库,我们可以通过在b主机上搭建代理让a访问c数据库,我们使用haproxy来干这个事情
centos7环境
mysql自行安装
haproxy安装配置
yum install -y haproxy
配置haproxy:
vim /etc/haproxy/haproxy.cfg #内容如下
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.*