生活如麻 发表于 2018-7-31 14:01:40

SaltStack实践(一)-- 安装配置HAproxy

# mkdir -p /srv/salt/prod/cluster/files  
# cd /srv/salt/prod/cluster/files/
  
# vim haproxy-outside.cfg
  
global
  
maxconn 100000
  
chroot /usr/local/haproxy
  
uid 99
  
gid 99
  
daemon
  
nbproc 1
  
pidfile /usr/local/haproxy/logs/haproxy.pid
  
log 127.0.0.1 local3 info
  
defaults
  
option http-keep-alive
  
maxconn 100000
  
mode http
  
timeout connect 5000ms
  
timeout client50000ms
  
timeout server 50000ms
  
listen stats
  
mode http
  
bind 0.0.0.0:8888
  
stats enable
  
stats uri   /haproxy-status
  
stats auth    haproxy:saltstack
  
frontend frontend_www_example_com
  
bind 10.0.0.11:80
  
mode http
  
option httplog
  
log global
  
   default_backend backend_www_example_com
  
backend backend_www_example_com
  
option forwardfor header X-REAL-IP
  
option httpchk HEAD / HTTP/1.0
  
balance source
  
server web-node110.0.0.7:8080 check inter 2000 rise 30 fall 15   #
  
server web-node210.0.0.8:8080 check inter 2000 rise 30 fall 15
  
#cd ..
  
# vim haproxy-outside.sls
  
include:
  
- haproxy.install
  
haproxy-service:
  
file.managed:
  
   - name: /etc/haproxy/haproxy.cfg
  
   - source: salt://cluster/files/haproxy-outside.cfg
  
   - user: root
  
   - group: root
  
   - mode: 644
  
service.running:
  
   - name: haproxy
  
   - enable: True
  
   - reload: True
  
   - require:
  
   - cmd: haproxy-init
  
   - watch:
  
   - file: haproxy-service
  
# cd /srv/salt/base/
  
# vim top.sls
  
base:
  
'*':
  
   - init.env_init
  
prod:
  
'linux-node.example.com':
  
   - cluster.haproxy-outside
  
# salt '*' state.highstate
  
linux-node1.example.com:
  
----------
  
......
  

  
Summary
  
-------------
  
Succeeded: 21 (unchanged=2, changed=1)
  
Failed:   0
  
-------------
  
Total states run:   21
  
linux-node2.example.com:
  
----------
  
......
  
Summary
  
-------------
  
Succeeded: 21 (unchanged=9, changed=3)
  
Failed:   0
  
-------------
  
Total states run:   21
页: [1]
查看完整版本: SaltStack实践(一)-- 安装配置HAproxy