(5.16) mysql availability --keepalived + mysql series dual master ha

[1] KeepAlived basic concepts and principles

       Double main KeepAlived

  Using KeepAlived failover (mirroring similar MSSQL functionally similar to the windows form a failover cluster)

[1.1] keepalived Profile

  (1.1.1) origin

  keepalived software initially is designed for LVS load balancing software designed to manage and monitor the status of each service node of LVS cluster system, the background and can be added to achieve high availability VRRP function. (VRRP: full name of the virtual router redundancy protocol, Virtual Router Redundancy Protocol)

  Thus in addition to manage Keepalived LVS software, but can also serve as additional services: high availability (e.g. Nginx / Haproxy / Mysql) software solutions;

  (1.1.2) and make up to achieve

  keepalived software is to achieve high-availability functions through VRRP protocol.

  VRRP is an acronym for virtual route redundancyProtocol (virtual router honor the agreement), the purpose is to solve VRRP appear static routing single point of failure, it is possible to ensure that when an individual node goes down, the entire network can uninterrupted operation.

  (1.1.3) common operational scenarios

  A web server has at least two PC running Keepalived, one as the master server (master), one as a backup server (Backup), but outside the performance of a virtual IP, when Keepalived service policy work, the main Master node will continue to sent to the standby node (multicast, the multicast address 221.0.0.18) heartbeat messages to tell the standby node to be alive.

  When the primary node fails Master, you can not send a heartbeat message, the standby node will therefore not continue to monitor the arrival of self Master node heartbeat, then it calls itself to take over the program, to take over the IP resources and services of the main Master node.

  When the master node recovery Master, prepared Backup node will release the IP resources and services to take over when the primary node fails itself, and restored to its original standby role. (Preemptive mode) (may also be provided in a non-preemptive mode, the main holding allowed, without releasing the resources for the original owner, particularly see 1.1.7)

  So, keepAlived, on the one hand has LVS configuration management functions, but also has the following functions for LVS node health check, on the other hand can achieve high-availability network service functions of the system, and can work in Keepalived Layer3 network, 4 & 7, i.e. the network layer (IP layer), the transport layer (TCP layer), and the application layer, then back to the original place directly LVS software solutions in many scenes.

  Three important functions (1.1.4) keepalived services

    (1) Management LVS load balancing software

    (2) achieve health check LVS cluster node

    (3) High Availability (failover) as a system of network services

  

  Works (1.1.5) Keepalived services

  Keepalived communication between service through VRRP, VRRP is to determine the master and slave (a bit like a vote of Arbitration in a failover cluster), the main priority over the equipment through the electoral system, therefore the main priority will be to get all the work resources and backup nodes in a wait state, when the main hang time, the standby node will take over the resources of the master node, and then replace the master node external services.

  Between Keepalived service, only as the primary server will always send VRRP broadcast packets, prepared to tell it alive, not at this time prepared to seize the main, when the primary is unavailable (that is, not subject to backup VRRP broadcast packet information), it will related services start to take over resources, ensure business continuity, taking over the fastest possible less than 1 second.

  (1.1.6) keepalived three core modules

    They are the core / check / vrrp

    core: core keepalived, the main process responsible for starting, maintaining, and global configuration files are loaded and parsed.

    check: responsible for health checks, including a variety of common inspection method.

    vrrp: is used to implement the VRRP; (VRRP: full name of the virtual router redundancy protocol, Virtual Router Redundancy Protocol)

  (1.1.7) What is VRRP?

  VRRP, full name of the virtual router redundancy protocol, virtual routing redundancy protocol.

  Appears VRRP is to solve the static routing single point of failure problem, VRRP election is by means of a mechanism to route tasks to one of the VRRP router. 

  Keepalived multicast (default), Unicast (custom), to achieve the selection keepalived standby operating mode is divided into preemptive and non-preemptive.

  "1" preemptive mode

    When the primary server is working properly, the virtual IP will be on the primary and backup service is not available, when the main service of lower priority than equipment, equipment will automatically seize the virtual IP, then, the main provision of services, equipment to provide services.

    That is, the preemption mode, regardless of standby, just priority.

    No matter where the state keepalived.conf configured master or backup, just to see who the high-priority priority, a high priority and that priority, after recovery, VIP resource will automatically win back again.

  "2" non-preemptive mode

    In this manner the parameter nopreempt (generally disposed below the line that advert_int) controlled. Priority regardless of priority, as long as the master machine fails, VIP resources will be switched to the backup.

    And, when the master machine back, nor will the VIP resource grab back. Unless Backup machine failure, can automatically switch the VIP and other resources will be the main library.

    

    nopreempt This parameter can only be the case where the user state backup, so take the time to configure the master state and backup are set to backup, this will achieve a non-preemptive mode keepalived!

    That

    a) When the state status is a master, one of the backup, plus without nopreempt this parameter is the same effect.

      That is according to priority priority to determine who seize the VIP resources belong to preemptive mode!

    b) When the state status is set to backup, nopreempt If no parameters.

      Also based on priority priority to determine who seize the VIP resources belong to preemptive mode!

    c) When the state status is set to backup, if the nopreempt parameter configuration, so long not to consider the priority of priorities.

      Non preemptive mode! That is, only VIP currently resides machine fails, another machine to take over the VIP. Without regard to priority issues.

 

 

[1.2] Keepalived have any effect on MySQL?

  mysql dual-master replication, i.e. mutually Master-Slave (Master provides only a write operation) can be realized hot backup database server.

  But after a Master downtime can not be achieved dynamically switch, use Keepalived, through virtual IP, dual main external unified interface and automatic check failover mechanism, in order to achieve high availability MySQL database program.

 

  "1" Schema 1: standby cluster architecture (double main HA + keepalived)

  Program: mysql double master or master switch automatically from the master-slave + keepalived

  Server: 2 PC

  Advantages: simple structure, save resources

  Cons: not scale linearly, the main need to manually recover from the failure of a master-slave architecture

Guess you like

Origin www.cnblogs.com/gered/p/12328155.html