基于SaltStack完成LVS的配置管理
作者:网络转载 发布时间:[ 2014/12/1 15:47:44 ] 推荐标签:软件测试管理
编写States
/srv/salt/lvs/loadblance.sls
# config lvs
{% if 'lvs-loadblance' in pillar %}
{% for each_lvs in pillar['lvs-loadblance'] %}
# config lvs vip
{{each_lvs['name']}}-vip:
network.managed:
- name: {{each_lvs['vip-nic'] + ":" + each_lvs['name']}}
- enable: True
- type: eth
- proto: none
- ipaddr: {{each_lvs['vip']}}
- netmask: 255.255.255.255
{% set service_address = each_lvs['vip'] + ":" + each_lvs['port']|string() %}
{{each_lvs['name']}}-service:
lvs_service.present:
- protocol: {{each_lvs['protocol']}}
- service_address: {{service_address}}
- scheduler: {{each_lvs['scheduler']}}
{% for each_rs in each_lvs['realservers'] %}
{% set server_address = each_rs['ip'] + ":" + each_rs['port']|string() %}
{{each_rs['name']}}-server:
lvs_server.present:
- protocol: {{each_lvs['protocol']}}
- service_address: {{service_address}}
- server_address: {{server_address}}
- packet_forward_method: {{each_rs['packet_forward_method']}}
- weight: {{each_rs['weight']}}
{% endfor %}
{% endfor %}
{% endif %}
/srv/salt/lvs/realserver.sls
# ignore arp
net.ipv4.conf.all.arp_ignore:
sysctl.present:
- value: 1
net.ipv4.conf.lo.arp_ignore:
sysctl.present:
- value: 1
net.ipv4.conf.all.arp_announce:
sysctl.present:
- value: 2
net.ipv4.conf.lo.arp_announce:
sysctl.present:
- value: 2
# config lvs vip
{% if 'lvs-realserver' in pillar %}
{% for each_lvs in pillar['lvs-realserver'] %}
lvs-vip:
network.managed:
- name: {{"lo" + ":" + each_lvs['name']}}
- enable: True
- type: eth
- proto: none
- ipaddr: {{each_lvs['vip']}}
- netmask: 255.255.255.255
{% endfor %}
{% endif %}
/srv/salt/top.sls
base:
'lvs':
- lvs.loadblance
'web-0*':
- lvs.realserver
应用配置
如果之前进行 配置LVS模块 的操作,需要进行同步模块的操作:
salt 'lvs*' saltutil.sync_all
应用LVS配置:
salt '*' state.highstate
查看LVS当前状态:
salt 'lvs' lvs.list
总结
通过SaltStack LVS模块,可以快速的查询LVS状态,执行LVS常用指令及完成LVS的配置管理。如有需要调整RealServer规则或添加新的RealServer, 只需要修改 /srv/pillar/lvs/loadblance.sls ,然后应用配置即可.
相关推荐
更新发布
功能测试和接口测试的区别
2023/3/23 14:23:39如何写好测试用例文档
2023/3/22 16:17:39常用的选择回归测试的方式有哪些?
2022/6/14 16:14:27测试流程中需要重点把关几个过程?
2021/10/18 15:37:44性能测试的七种方法
2021/9/17 15:19:29全链路压测优化思路
2021/9/14 15:42:25性能测试流程浅谈
2021/5/28 17:25:47常见的APP性能测试指标
2021/5/8 17:01:11