AWS网络负载均衡器的健康检查行为不符合预期
创始人
2024-09-27 18:30:22
0

可能的问题可能是使用不正确的监听器规则或未正确配置目标组。下面是一个示例代码,可用于运行健康检查。

import boto3

# Define the listener and target group ARNs
listener_arn = 'arn:aws:elasticloadbalancing:region:123456789012:listener/app/my-load-balancer/0123456789abcdef/0123456789abcdef'
target_group_arn = 'arn:aws:elasticloadbalancing:region:123456789012:targetgroup/my-targets/0123456789abcdef'

# Configure the client to use the us-west-2 region
client = boto3.client('elbv2', region_name='us-west-2')

# Register the targets with the target group
response = client.register_targets(
    TargetGroupArn=target_group_arn,
    Targets=[
        {
            'Id': 'i-0bcdefghijklmnopq',
            'Port': 80,
        },
        {
            'Id': 'i-0123456789abcdef',
            'Port': 80,
        },
    ]
)

# Set the health check parameters for the target group
response = client.modify_target_group_attributes(
    TargetGroupArn=target_group_arn,
    Attributes=[
        {
            'Key': 'deregistration_delay.timeout_seconds',
            'Value': '30',
        },
        {
            'Key': 'slow_start.duration_seconds',
            'Value': '10',
        },
        {
            'Key': 'stickiness.enabled',
            'Value': 'false',
        },
        {
            'Key': 'stickiness.lb_cookie.duration_seconds',
            'Value': '86400',
        },
        {
            'Key': 'stickiness.type',
            'Value': 'lb_cookie',
        },
        {
            'Key': 'unhealthy_threshold.count',
            'Value': '5',
        },
    ]
)

# Configure the listener to use the target group
response = client.modify_listener(
    ListenerArn=listener_arn,
    DefaultActions=[
        {
            'TargetGroupArn': target_group_arn,
            'Type': 'forward',
        },
    ]
)

这个示例代码注册了目标,设置了健康检查参数,并将监听器配置为使用目标组。您可以根据自己的需要来修改这份代码。

相关内容

热门资讯

科技通报!佛手在线大菠萝辅助(... 科技通报!佛手在线大菠萝辅助(辅助挂)真是存在有挂(确实有挂辅助器)1、上手简单,内置详细流程视频教...
玩家攻略!cloudpoker... 玩家攻略!cloudpoker作弊(辅助挂)真是是真的有挂(有挂技术辅助软件)1、进入到是否有挂之后...
科技通报!wpk可以作弊吗(辅... 科技通报!wpk可以作弊吗(辅助挂)真是有挂(有挂解密辅助软件)1、起透看视 辅助软件价格2、随意选...
发现玩家!htx矩阵wepok... 发现玩家!htx矩阵wepoker辅助(辅助挂)其实存在有挂(有挂规律辅助方法)1)免费钻石:进一步...
分享一款!hhpoker脚本(... 分享一款!hhpoker脚本(辅助挂)好像是有挂(有挂秘籍辅助脚本)1、起透看视 辅助软件价格2、随...
科技新动态!wepoker辅助... 科技新动态!wepoker辅助插件功能(辅助挂)其实真的是有挂(揭秘有挂辅助工具)1、实时透视辅助更...
一分钟了解!约局吧德州真的有透... 一分钟了解!约局吧德州真的有透视挂吗(辅助挂)真是真的是有挂(真的有挂辅助插件)1、一分钟了解!约局...
实测教程!wpk安卓下载辅助(... 实测教程!wpk安卓下载辅助(辅助挂)真是有挂(有挂功能辅助器)1、起透看视 辅助软件价格2、随意选...
玩家必备教程!aapoker能... 玩家必备教程!aapoker能控制牌吗(辅助挂)一直真的有挂(有挂细节辅助技巧)1、首先打开辅助器下...
玩家科普!wepoker辅助器... 玩家科普!wepoker辅助器(辅助挂)好像真的是有挂(有挂透视辅助方法)1、用户打开应用后不用登录...