博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
LVS _keepalived 配置
阅读量:4984 次
发布时间:2019-06-12

本文共 2648 字,大约阅读时间需要 8 分钟。

#!/bin/bashHOSTNAME=$(HOSTNAME)ETHNAME=ens34ID="LVS$(ifconfig  $ETHNAME |egrep  -o "[0-9]{
1,3}\.[0-9]{
1,3}\.[0-9]{
1,3}\.[0-9]{
1,3}" | awk -F . 'NR==1{print $4}')"VIP=192.168.204.200MASTER=192.168.204.135SLAVE=192.168.204.136RIP1=192.168.204.137RIP2=192.168.204.139
#!/bin/bash#install keepalived
#/bin/bash#config webyum install -y httpdrm -rf /etc/httpd/conf.d/welcome.conf ifconfig lo:0 $VIP netmask 255.255.255.255 broadcast $VIP  uproute add -host $VIP dev lo:0echo 1 > /proc/sys/net/ipv4/conf/lo/arp_ignoreecho 2 > /proc/sys/net/ipv4/conf/lo/arp_announceecho 1 > /proc/sys/net/ipv4/conf/all/arp_ignoreecho 2 > /proc/sys/net/ipv4/conf/all/arp_announcesystemctl restart httpd
! Configuration File for keepalivedglobal_defs {    notification_email {        root@localhost        }    notification_email_from root@localhost    smtp_server 127.0.0.1    smtp_connect_timeout 30    router_id ID}vrrp_instance VI_1 {    state STATE    interface ETHNAME    virtual_router_id 51    priority PRIORITY    advert_int 1    authentication {        auth_type PASS        auth_pass 1111    }    virtual_ipaddress {        VIP    }}virtual_server VIP 80 {    delay_loop 6    lb_algo rr    lb_kind DR    persistence_timeout 50    protocol TCP    real_server RIP1 80 {        weight 1        TCP_CHECK {            connect_timeout 3            nb_get_retry 3            delay_before_retry 2        }    }    real_server RIP2 80 {        weight 1        TCP_CHECK {            connect_timeout 3            nb_get_retry 3            delay_before_retry 2        }    }}
rm -rf /etc/keepalived/keepalived.conf.bakmv  /etc/keepalived/keepalived.conf /etc/keepalived/keepalived.conf.bakcp keepalived.conf /etc/keepalived/keepalived.confif [[ "$(ifconfig  $ETHNAME |egrep  -o "[0-9]{
1,3}\.[0-9]{
1,3}\.[0-9]{
1,3}\.[0-9]{
1,3}" | awk 'NR==1{print}')" == "$MASTER" ]]; then sed -i 's/STATE/MASTER/g' /etc/keepalived/keepalived.conf sed -i 's/PRIORITY/100/g' /etc/keepalived/keepalived.confelif [[ "$(ifconfig $ETHNAME |egrep -o "[0-9]{
1,3}\.[0-9]{
1,3}\.[0-9]{
1,3}\.[0-9]{
1,3}" | awk 'NR==1{print}')" == "$SLAVE" ]]; then sed -i 's/STATE/BACKUP/g' /etc/keepalived/keepalived.conf sed -i 's/PRIORITY/50/g' /etc/keepalived/keepalived.confelse echo "error"fised -i "s/ETHNAME/$ETHNAME/g" /etc/keepalived/keepalived.confsed -i "s/ID/$ID/g" /etc/keepalived/keepalived.confsed -i "s/VIP/$VIP/g" /etc/keepalived/keepalived.confsed -i "s/RIP1/$RIP1/g" /etc/keepalived/keepalived.confsed -i "s/RIP2/$RIP2/g" /etc/keepalived/keepalived.confsystemctl start keepalived

 

转载于:https://www.cnblogs.com/gaoyuanzhi/p/8948575.html

你可能感兴趣的文章
hdu2046 骨牌铺方格
查看>>
Linux下mysql启动失败
查看>>
同心圆闪烁扩散功能
查看>>
oracle 如何恢复误删的表记录数据
查看>>
Druid连接池错误(数据库版本问题)
查看>>
console对象-转
查看>>
洛谷 4216 BZOJ 4448 [SCOI2015]情报传递
查看>>
清北学堂2018DP&图论精讲班 DP部分学习笔记
查看>>
css3 2D变换 transform
查看>>
Fastjson获取天气信息封装bean
查看>>
不同编码字符所占大小
查看>>
使用迭代器优化代码
查看>>
JavaScript 获取随机数
查看>>
线程学习的几个实例
查看>>
dom4j读取XML文件内容
查看>>
Java虚拟机10:Client模式和Server模式的区别
查看>>
Blog搬家吧
查看>>
2017-2018-1 20155306 20155315《信息安全系统设计基础》实验二 固件程序设计
查看>>
自定义连接池
查看>>
MySQL 索引
查看>>