Tüm Ürünler
Search
Belge Merkezi

Virtual Private Cloud:HaVip

Son Güncelleme:Oct 02, 2026

Yüksek kullanılabilirlikli sanal IP adresi (HaVip), aynı alan içindeki ECS örnekleri arasında yük devretme sırasında hizmet IP'nizin değişmeden kalmasını sağlar.

Keepalived zaten sanal IP'ler için yüksek kullanılabilirliği destekliyorken neden HaVip kullanmalısınız?

Geleneksel veri merkezlerinde Keepalived, yük devretme sırasında yeni bir birincil örneği seçmek için VRRP protokolünü kullanır. Yeni birincil örnek, sanal IP'yi kendi ağ arabirimine bağlar ve ücretsiz bir ARP yayını gönderir. Yerel Ağ'daki (LAN) diğer cihazlar bu yayını alır ve sanal IP'yi yeni birincil örneğin MAC adresine eşlemek için ARP önbelleklerini günceller.

Cloud sağlayıcıları, IP tahsisini platformun yönettiği yazılım tanımlı ağ (SDN) ve sanallaştırma teknolojilerini kullanır. Uygulamalar ana bilgisayar IP'lerini doğrudan değiştiremez ve sanal ağ, ana bilgisayarların IP adreslerini duyurmasını engelleyerek ARP'yi kaynakta sonlandırır. Alibaba Cloud bu sorunu çözmek için HaVip sunar.

HaVip, bağımsız olarak yönetilen bir özel IP adresidir. Keepalived sanal IP'sini HaVip adresine ayarlayın ve HaVip'i birden fazla sunucuyla ilişkilendirin. Keepalived yeni bir birincil örnek seçtiğinde sistem HaVip-örnek eşlemesini günceller; bu işlem, ücretsiz ARP yayını ile aynı etkiyi yaratırken yük devretme sırasında hizmet IP'sinin değişmeden kalmasını sağlar.

Nasıl çalışır?

Tipik bir yüksek kullanılabilirlik kümesi, birincil/ikincil yapılandırmada bir HaVip ve iki ECS örneğinden oluşur:

  1. Keepalived yapılandırması: HaVip'i ECS1 ve ECS2 ile ilişkilendirin ve her ikisine de Keepalived yükleyin. virtual_ipaddress parametresini HaVip adresine ayarlayın ve bir priority değeri atayın; daha yüksek önceliğe sahip olan örnek birincil seçimi kazanır.

  2. Birincil seçimi: Keepalived, VRRP aracılığıyla priority değerlerini karşılaştırır ve daha yüksek önceliğe sahip örneği birincil olarak seçer. Sistem HaVip eşlemesini günceller ve HaVip'e yönelik tüm trafik ECS1'e yönlendirilir.

  3. Yük devretme: ECS1, advert_int ile belirtilen aralıkta ECS2'ye kalp atışı sinyalleri gönderir. ECS2 zaman aşımı süresi içinde bir kalp atışı sinyali almazsa Keepalived ECS2'yi birincil olarak yükseltir. Sistem HaVip eşlemesini ECS2'ye günceller ve tüm trafik buna göre aktarılır; hizmet IP'si değişmeden kalır.

Genel erişimi etkinleştirmek için HaVip'i bir EIP ile ilişkilendirin. Trafik daha sonra yüksek kullanılabilirliğe sahip internete yönelik hizmetler sağlamak üzere EIP üzerinden yönlendirilir.

image

Yük devretme için HaVip kullanma

Bir HaVip'i aynı vSwitch içindeki ECS örnekleri veya esnek ağ arabirimleri (ENI) ile ilişkilendirin. Bu işlem, Keepalived ile birlikte kullanıldığında yük devretme sırasında hizmet IP'nizin değişmeden kalmasını sağlar.

  • Kota: Quota Center konsoluna gidin ve HaVip oluşturma izni için başvurun. Kota değeri 1 ise HaVip oluşturma etkinleştirilmiş demektir.

  • IP sürümü: HaVip yalnızca IPv4'ü destekler.

  • İlişkili kaynaklar:

    • Bir HaVip aynı anda yalnızca bir kaynak türüyle ilişkilendirilebilir. Türü değiştirmek için önce mevcut kaynakların ilişkisini kaldırın.

    • Bir HaVip'i bir ENI ile ilişkilendirdiğinizde ENI'nin bir ECS örneğine ekli olduğundan emin olun.

    • İlişkili bir ECS örneği veya ENI silindiğinde sistem HaVip'in söz konusu kaynaktan ilişkisini otomatik olarak kaldırır.

    • İkincil bir ENI'yi bir ECS örneğinden ayırmak HaVip-ENI ilişkisini etkilemez.

Konsol

HaVip oluşturma ve ilişkilendirme

  1. VPC Konsolu - HaVip sayfasına şuraya gidin. ECS örneklerinizin bulunduğu bölgeyi seçin ve ardından Create HaVip öğesine tıklayın.

  2. ECS örneklerinin ait olduğu VPC ve vSwitch'i seçin. vSwitch'in CIDR bloğundan otomatik olarak bir özel IP adresi atayabilir veya atanmamış bir IP adresi belirtebilirsiniz.

  3. Birincil ve yedek ECS örneklerine Keepalived yükleyin ve Keepalived'i başlatmak için systemctl start keepalived komutunu çalıştırın.

    Keepalived kurulum örneği

    Bu örnekte Keepalived, iki düğümlü birincil/ikincil kümedeki CentOS tabanlı ECS örneklerine yüklenir. Keepalived V1.2.15 veya sonraki bir sürümü kullanın.

    Birden fazla yedek ECS örneğiniz varsa her ECS örneğinin unicast_peer bölümünde tüm eş örneklerin IP adreslerini belirtmeniz gerekir.
    Sorun bildirmek ve sorun giderme kaynaklarına erişmek için Keepalived GitHub sayfasını ziyaret edin.

    Birincil Sunucu Yapılandırması

    1. Birincil ECS örneğine bağlanın.

    2. Keepalived'i yüklemek için yum install keepalived komutunu çalıştırın.

    3. keepalived.conf dosyasını düzenlemek için vim /etc/keepalived/keepalived.conf komutunu çalıştırın.

      Bu örnekte yalnızca değiştirilmesi gereken parametreler gösterilmektedir. Kendi örneğiniz için yapılandırma yapın. Mevcut keepalived.conf dosyanızı bu örnekle üzerine yazmayın.
      ! Configuration File for keepalived
      vrrp_instance VI_1 {
          state MASTER            # Set as the primary instance.
          interface eth0          # The network interface controller (NIC) to which the virtual IP (VIP) address is bound. This example uses eth0.
          virtual_router_id 51    # The virtual_router_id of the primary/standby cluster. Different primary/standby clusters in the same Virtual Private Cloud (VPC) must have different virtual_router_id values.
          nopreempt               # Set to non-preemptive mode.
          priority 100            # The priority. A larger number indicates a higher priority. In this example, the priority is set to 100 to make this the primary instance.
          advert_int 1            # The interval, in seconds, for sending heartbeat packets. A small value can cause frequent failovers or a temporary split-brain due to network jitter. A large value can increase the failover time if the primary instance fails.
          authentication {
              auth_type PASS
              auth_pass 1111
          }
          unicast_src_ip 192.168.0.25     # The private IP address of this instance. This example uses 192.168.0.25.
          unicast_peer {
              192.168.0.26          # The private IP address of the peer instance. This example uses 192.168.0.26. If you have multiple standby ECS instances, list the IP address of each peer instance on a separate line without commas or other separators.
          }
          virtual_ipaddress {
              192.168.0.24          # The virtual IP address. Set this to the IP address of the HaVip. This example uses 192.168.0.24.
          }   
          garp_master_delay 1       # The delay, in seconds, to update the ARP cache after the instance becomes the primary.
          garp_master_refresh 5     # The interval, in seconds, for sending ARP packets.
      
          track_interface {
              eth0                  # The NIC bound to the VIP address. This example uses eth0.
          }
      }
    4. Keepalived'i başlatmak için systemctl start keepalived komutunu çalıştırın.

    İkincil Sunucu Yapılandırması

    1. İkincil ECS örneğine bağlanın.

    2. Keepalived'i yüklemek için yum install keepalived komutunu çalıştırın.

    3. keepalived.conf dosyasını düzenlemek için vim /etc/keepalived/keepalived.conf komutunu çalıştırın.

      Bu örnekte yalnızca değiştirilmesi gereken bölümler gösterilmektedir. Kendi örneğiniz için yapılandırma yapın. Mevcut keepalived.conf dosyanızı bu örnekle üzerine yazmayın.
      ! Configuration File for keepalived
      vrrp_instance VI_1 {
          state BACKUP            # Set the instance as the secondary instance.
          interface eth0          # The NIC to which the VIP is bound. This example uses eth0.
          virtual_router_id 51    # The virtual_router_id of the primary/secondary cluster. Different primary/secondary clusters in the same VPC must have different virtual_router_id values.
          nopreempt               # Set to non-preemptive mode.
          priority 10             # The priority. A larger value indicates a higher priority. In this example, the priority is set to 10 to configure this instance as the secondary instance.
          advert_int 1            # The interval for sending heartbeat packets, in seconds. If this value is too small, the service is susceptible to network jitter, which can cause frequent failovers and temporary dual-primary scenarios (split-brain). If this value is too large, the failover time may be long after the primary instance fails.
          authentication {
              auth_type PASS
              auth_pass 1111
          }
          unicast_src_ip 192.168.0.26   # The private IP address of this instance. In this example, it is 192.168.0.26.
          unicast_peer {
              192.168.0.25          # The private IP address of the peer instance. In this example, it is 192.168.0.25. You must declare the IP addresses of all peer instances. Each address must be on a separate line, without commas or other separators.
          }
          virtual_ipaddress {
              192.168.0.24          # The virtual IP address. Set this to the IP address of the HaVip. In this example, it is 192.168.0.24.
          }    
          garp_master_delay 1       # The delay, in seconds, to update the ARP cache after this instance becomes the primary instance.
          garp_master_refresh 5     # The interval for sending ARP packets, in seconds.
      
          track_interface {
              eth0                  # The NIC to which the VIP is bound. This example uses eth0.
          }
      }
    4. Keepalived'i başlatmak için systemctl start keepalived komutunu çalıştırın.

  4. Hedef HaVip'in kimliğine tıklayın. Resources bölümünde Bind seçeneğine tıklayın ve ardından ECS Instances öğesinin sağ tarafındaki ilişkilendirmek istediğiniz ECS örneklerini veya ENI'leri seçin.

    İlişkilendirme tamamlandıktan sonra birincil ve ikincil durumunu Associated Instance sütununda veya ayrıntılar sayfasının Resources bölümünde görüntüleyebilirsiniz.
  5. Sonucu doğrulayın:

    1. Farklı sonuçlar döndüren bir web test hizmeti oluşturmak için birincil ve ikincil örneklerde aşağıdaki komutları çalıştırın.

      Port kullanımını kontrol etmek için netstat -an | grep 8000 komutunu çalıştırın. 8000 numaralı bağlantı noktası kullanılıyorsa başka bir bağlantı noktası seçmeniz gerekir.

      Birincil örnek:

      echo "ECS 1" > index.html  # The primary instance returns "ECS 1"
      python3 -m http.server 8000

      İkincil örnek:

      echo "ECS 2" > index.html  # The secondary instance returns "ECS 2"
      python3 -m http.server 8000
    2. Aynı VPC içindeki başka bir ECS örneğinden curl <havip_private_ip>:8000 komutunu çalıştırdığınızda ECS 1 yanıtı döner. Birincil sunucu durdurulduktan sonra ECS 2 yanıtı döner.

      Birincil ve ikincil örneklerin güvenlik gruplarının, aynı VPC içinden 8000 numaralı bağlantı noktasına HTTP trafiğine izin verdiğinden emin olun.

Kaynakların ilişkisini kaldırma

Hedef HaVip'in kimliğine tıklayın. Resources bölümünde Associated kaynaklar listesinde hedef ECS örneğini veya esnek ağ arabirimini bulun ve Delete Association seçeneğine tıklayın.

HaVip silme

Bir HaVip'i silmeden önce herhangi bir ECS örneği, ENI veya EIP ile ilişkilendirilmemiş olduğundan emin olun. Hedef HaVip'in Actions sütununda veya ayrıntılar sayfasında Delete seçeneğine tıklayın.

API

  • Bir HaVip oluşturmak için CreateHaVip API'sini çağırın.

  • Bir HaVip'i bir ECS örneği veya ENI ile ilişkilendirmek için AssociateHaVip API'sini çağırın.

  • Bir HaVip'in bir ECS örneği veya ENI ile ilişkisini kaldırmak için UnassociateHaVip API'sini çağırın.

  • Bir HaVip'i silmek için DeleteHaVip API'sini çağırın.

Terraform

Kaynaklar: alicloud_havip , alicloud_havip_attachment , alicloud_instance , alicloud_security_group , alicloud_security_group_rule
# Specify the region where you want to create the HaVip.
provider "alicloud" {
  region = "cn-hangzhou"
}

# Specify the ID of the VPC.
variable "vpc_id" {
  default = "vpc-bp1k******" # Replace with the actual ID of your VPC.
}

# Specify the vSwitch ID.
variable "vswitch_id" {
  default = "vsw-bp1y******" # Replace with the actual ID of your vSwitch.
}

# Specify the instance type.
variable "instance_type" {
  default = "ecs.e-c1m1.large"
}

# Specify the image ID.
variable "image_id" {
  default = "aliyun_3_x64_20G_alibase_20221102.vhd"
}

# Create an HaVip.
resource "alicloud_havip" "test_havip" {
  ha_vip_name = "test_havip_name"
  vswitch_id  = var.vswitch_id
  ip_address  = "192.168.0.24" # Specify an IP address for the HaVip from the vSwitch CIDR block. If not specified, the system assigns one.
}

# Create a security group.
resource "alicloud_security_group" "test_security_group" {
  security_group_name = "test_security_group_name"
  vpc_id              = var.vpc_id
}

# Create a security group rule. You need to adjust the protocol, source, and port based on your actual traffic.
resource "alicloud_security_group_rule" "allow_vpc_tcp" {
  type              = "ingress"
  ip_protocol       = "tcp"
  nic_type          = "intranet"
  policy            = "accept"
  port_range        = "8000/8000"
  priority          = 1
  security_group_id = alicloud_security_group.test_security_group.id
  cidr_ip           = "192.168.0.0/24"
}

# Create the primary server. 
resource "alicloud_instance" "test_master_instance" {
  instance_name        = "test_master_instance_name"
  vswitch_id           = var.vswitch_id
  instance_type        = var.instance_type
  image_id             = var.image_id
  system_disk_category = "cloud_essd"
  security_groups      = [alicloud_security_group.test_security_group.id]
  user_data = base64encode(<<-EOT
    #!/bin/sh
    yum install keepalived -y

    printf '! Configuration File for keepalived
    vrrp_instance VI_1 {
        state MASTER            # Set as the primary instance.
        interface eth0          # The network interface to which the virtual IP address is bound. This example uses eth0.  
        virtual_router_id 51    # The virtual_router_id of the primary/secondary cluster. Different clusters in the same VPC require different virtual_router_id values.
        nopreempt               # Set to non-preemptive mode.
        priority 100            # The priority. A higher value indicates a higher priority. This example sets the priority to 100 to make this instance the primary instance.
        advert_int 1            # The interval at which heartbeat messages are sent, in seconds. A small value makes the configuration susceptible to network jitter, which can cause frequent failovers or temporary split-brain scenarios. A large value can increase the failover time after the primary instance fails.
        authentication {
            auth_type PASS
            auth_pass 1111
        }
        unicast_src_ip 192.168.0.25     # The private IP address of this instance. This example uses 192.168.0.25.
        unicast_peer {
            192.168.0.26                # The private IP address of the peer instance. This example uses 192.168.0.26. If you have multiple secondary ECS instances, declare the IP address of each peer instance on a new line. Do not use commas or other separators.
        }
        virtual_ipaddress {
            192.168.0.24                # The virtual IP address. Set this to the HaVip's IP address. This example uses 192.168.0.24.
        }   
        garp_master_delay 1             # The delay in seconds before updating the ARP cache after a failover to this instance. 
        garp_master_refresh 5           # The interval at which ARP messages are sent, in seconds. 

        track_interface {
            eth0                        # The network interface to which the virtual IP address is bound. This example uses eth0.
        }
    }' > /etc/keepalived/keepalived.conf
    systemctl start keepalived
  EOT
  )                                           # Specify the initialization script for the primary server to install Keepalived.
  private_ip           = "192.168.0.25"       # Specify the private IP address of the primary server.
  instance_charge_type = "PostPaid"           # Set the billing method to pay-as-you-go.
  spot_strategy        = "SpotWithPriceLimit" # Set as a spot instance with a price limit.
}

# Create the secondary server. 
resource "alicloud_instance" "test_backup_instance" {
  instance_name        = "test_backup_instance_name"
  vswitch_id           = var.vswitch_id
  instance_type        = var.instance_type
  image_id             = var.image_id
  system_disk_category = "cloud_essd"
  security_groups      = [alicloud_security_group.test_security_group.id]
  user_data = base64encode(<<-EOT
    #!/bin/sh
    yum install keepalived -y

    printf '! Configuration File for keepalived
    vrrp_instance VI_1 {
        state BACKUP            # Set as the secondary instance.
        interface eth0          # The network interface to which the virtual IP address is bound. This example uses eth0.  
        virtual_router_id 51    # The virtual_router_id of the primary/secondary cluster. Different clusters in the same VPC require different virtual_router_id values.
        nopreempt               # Set to non-preemptive mode.
        priority 10             # The priority. A higher value indicates a higher priority. This example sets the priority to 10 to make this instance the secondary instance.
        advert_int 1            # The interval at which heartbeat messages are sent, in seconds. A small value makes the configuration susceptible to network jitter, which can cause frequent failovers or temporary split-brain scenarios. A large value can increase the failover time after the primary instance fails.
        authentication {
            auth_type PASS
            auth_pass 1111
        }
        unicast_src_ip 192.168.0.26   # The private IP address of this instance. This example uses 192.168.0.26.
        unicast_peer {
            192.168.0.25          # The private IP address of the peer instance. This example uses 192.168.0.25. If you have multiple secondary ECS instances, declare the IP address of each peer instance on a new line. Do not use commas or other separators.
        }
        virtual_ipaddress {
            192.168.0.24          # The virtual IP address. Set this to the HaVip's IP address. This example uses 192.168.0.24. 
        }    
        garp_master_delay 1       # The delay in seconds before updating the ARP cache after a failover to this instance. 
        garp_master_refresh 5     # The interval at which ARP messages are sent, in seconds. 

        track_interface {
            eth0                  # The network interface to which the virtual IP address is bound. This example uses eth0.
        }
    }' > /etc/keepalived/keepalived.conf
    systemctl start keepalived
  EOT
  )                                           # Specify the initialization script for the secondary server to install Keepalived.
  private_ip           = "192.168.0.26"       # Specify the private IP address of the secondary server. 
  instance_charge_type = "PostPaid"           # Set the billing method to pay-as-you-go.
  spot_strategy        = "SpotWithPriceLimit" # Set as a spot instance with a price limit.
}

# Associate with the primary server.
resource "alicloud_havip_attachment" "test_havip_attachment" {
  ha_vip_id   = alicloud_havip.test_havip.id
  instance_id = alicloud_instance.test_master_instance.id # Specify the ID of the instance to associate with the HaVip.
}

# Associate with the secondary server.
resource "alicloud_havip_attachment" "test_havip_attachment_new" {
  ha_vip_id   = alicloud_havip.test_havip.id
  instance_id = alicloud_instance.test_backup_instance.id # Specify the ID of the instance to associate with the HaVip.
}

Genel erişim için EIP ilişkilendirme

HaVip, bir vSwitch içindeki özel bir IP adresidir. İnternet erişimini etkinleştirmek için Esnek IP Adresi (EIP) ile HaVip'i ilişkilendirin. EIP'lerin ücretlendirildiğini unutmayın.

1. EIP, HaVip ile aynı bölgede olmalı ve kullanılabilir durumda bulunmalıdır.
2. Bir ECS örneği, HaVip ile ilişkilendirilmiş bir EIP üzerinden internete eriştiğinde giden paketlerin kaynak IP'si ECS örneğinin özel IP'si değil HaVip'in özel IP'sidir.

Konsol

EIP ilişkilendirme veya ilişkinin kaldırılması

Bir EIP ilişkilendirmeden önce EIP konsolunda bir EIP oluşturun veya ilişkilendirme sayfasında Create EIP seçeneğine tıklayın.

Hedef HaVip'in Actions sütununda Associate EIP veya Disassociate EIP seçeneğine tıklayın.

API

Bir EIP ilişkilendirmeden önce bir tane oluşturmak için AllocateEipAddress API'sini çağırın.

Terraform

Kaynaklar: alicloud_eip_address , alicloud_eip_association
# Specify the region of the HaVip. 
provider "alicloud" {
  region = "cn-hangzhou"
}

# Specify the ID of the HaVip.
variable "havip_id" {
  default = "havip-8vb0******"  # Replace with the actual ID of your HaVip.
}

# Create an EIP.
resource "alicloud_eip_address" "test_eip" {
  address_name = "test_eip_name"
  isp          = "BGP"
  netmode      = "public"
  bandwidth    = "1"
  payment_type = "PayAsYouGo"
}

# Associate the EIP.
resource "alicloud_eip_association" "test_eip_havip_association" {
  allocation_id = alicloud_eip_address.test_eip.id
  instance_type = "HAVIP"
  instance_id   = var.havip_id # Specify the ID of the HaVip.
}

Daha fazla bilgi

Ücretlendirme

HaVip genel önizleme aşamasındadır ve ücretsizdir. Genel önizleme sırasında SLA sağlanmaz.

ECS örnekleri ve EIP'ler gibi ilişkili kaynaklar kendi fiyatlandırma kurallarına göre ücretlendirilir.

Desteklenen bölgeler

Alan

Bölgeler

Asya Pasifik - Çin

China (Hangzhou), China (Shanghai), China (Nanjing - Local Region, Closing Down), China (Qingdao), China (Beijing), China (Zhangjiakou), China (Hohhot), China (Ulanqab), China (Shenzhen), China (Heyuan), China (Guangzhou), China (Chengdu), China (Zhongwei), China (Hong Kong), China (Wuhan - Local Region) ve China (Fuzhou - Local Region, Closing Down)

Asya Pasifik - Diğerleri

Japan (Tokyo), South Korea (Seoul), Singapore, Malaysia (Kuala Lumpur), Indonesia (Jakarta), Philippines (Manila), Thailand (Bangkok) ve Malaysia (Johor)

Avrupa ve Amerika

Germany (Frankfurt), UK (London), France (Paris), US (Silicon Valley), US (Virginia), Mexico ve Brazil (São Paulo)

Orta Doğu

UAE (Dubai) ve Saudi Arabia (Riyadh - Partner Region)

Kotalar

HaVip genel önizleme aşamasındadır. Etkinleştirmek için Quota Center konsoluna gidin ve bir başvuru gönderin.

Kota adı

Açıklama

Varsayılan sınır

Ayarlanabilir

Yok

HaVip'leri destekleyen ağ türü.

VPC

Hayır

ECS örneği başına maksimum HaVip sayısı.

5

HaVip başına maksimum EIP sayısı.

1

Bir HaVip ile aynı anda ilişkilendirilebilecek maksimum ECS örneği veya esnek ağ arabirimi (ENI) sayısı.

10

1. Bir HaVip en fazla 10 ECS örneği veya 10 ENI ile ilişkilendirilebilir ancak aynı anda her ikisiyle birden ilişkilendirilemez.
2. Bir HaVip yalnızca HaVip ile aynı vSwitch içinde bulunan ECS örnekleri veya ENI'ler ile ilişkilendirilebilir.

HaVip'lerin yayın ve çoklu yayın iletişimini destekleyip desteklemediği.

Desteklenmez

HaVip yalnızca tekli yayın iletişimini destekler. Keepalived gibi üçüncü taraf yazılımları kullanarak yüksek kullanılabilirlik uyguluyorsanız yapılandırma dosyasında iletişim modunu tekli yayına değiştirmeniz gerekir.

vpc_quota_havip_custom_route_entry

Hedefi bir HaVip olan bir yönlendirme tablosundaki maksimum yönlendirme girişi sayısı.

5

Evet. Kota artışı talep etmek için Kota Yönetimi sayfasına veya Quota Center'a gidin.