Pgpool-watchdog : Différence entre versions

De DiouxX's Wiki
Aller à : navigation, rechercher
(Page créée avec « == Introduction == Watchdog est un service directement implémenté dans pgpool afin de permettre une haute disponibilité de Pgpool et donc des serveurs postgresql. Il ... »)
 
 
(Une révision intermédiaire par le même utilisateur non affichée)
Ligne 207 : Ligne 207 :
 
{{ Avertissement | Vérifier les IP et Port via le [[Postgres-table|tableau]] }}
 
{{ Avertissement | Vérifier les IP et Port via le [[Postgres-table|tableau]] }}
 
<br>
 
<br>
==== Le premier pgpool ( debpool : 192.168.168.13 ) ====
+
==== Le premier pgpool ( IP1 ) ====
 
<pre>
 
<pre>
 
#------------------------------------------------------------------------------
 
#------------------------------------------------------------------------------
Ligne 218 : Ligne 218 :
 
                                     # to confirm network connection
 
                                     # to confirm network connection
 
                                     # (hostA,hostB,hostC,...)
 
                                     # (hostA,hostB,hostC,...)
delegate_IP = '192.168.168.15'
+
delegate_IP = 'IP DELEGATE'
 
                                     # delegate IP address
 
                                     # delegate IP address
 
wd_hostname = ''
 
wd_hostname = ''
Ligne 232 : Ligne 232 :
 
# Other pgpool Connection Settings
 
# Other pgpool Connection Settings
  
other_pgpool_hostname0 = '192.168.168.14'
+
other_pgpool_hostname0 = 'IP POLL 2'
 
                                     # Host name or IP address to connect to for other pgpool 0
 
                                     # Host name or IP address to connect to for other pgpool 0
 
other_pgpool_port0 = 5433
 
other_pgpool_port0 = 5433
Ligne 241 : Ligne 241 :
 
<br>
 
<br>
  
==== Le deuxième pgpool ( debpool2 : 192.168.168.14 ) ====
+
==== Le deuxième pgpool ( IP2 ) ====
 
<pre>
 
<pre>
 
#------------------------------------------------------------------------------
 
#------------------------------------------------------------------------------
Ligne 252 : Ligne 252 :
 
                                     # to confirm network connection
 
                                     # to confirm network connection
 
                                     # (hostA,hostB,hostC,...)
 
                                     # (hostA,hostB,hostC,...)
delegate_IP = '192.168.168.15'
+
delegate_IP = 'IP DELEGATE'
 
                                     # delegate IP address
 
                                     # delegate IP address
 
wd_hostname = ''
 
wd_hostname = ''
Ligne 266 : Ligne 266 :
 
# Other pgpool Connection Settings
 
# Other pgpool Connection Settings
  
other_pgpool_hostname0 = '192.168.168.13'
+
other_pgpool_hostname0 = 'IP1'
 
                                     # Host name or IP address to connect to for other pgpool 0
 
                                     # Host name or IP address to connect to for other pgpool 0
 
other_pgpool_port0 = 5433
 
other_pgpool_port0 = 5433
Ligne 276 : Ligne 276 :
 
{{ Note | les variables qui ne sont pas listé, sont laissées par défaut }}
 
{{ Note | les variables qui ne sont pas listé, sont laissées par défaut }}
 
<br>
 
<br>
[[Catégorie:Système]]
+
[[Catégorie:Database]]

Version actuelle datée du 14 novembre 2013 à 20:39

Introduction

Watchdog est un service directement implémenté dans pgpool afin de permettre une haute disponibilité de Pgpool et donc des serveurs postgresql.

Il se base sur une IP virtuelle et le protocole ping et arp pour tester et réaliser le basculement de cette IP partagé entre les différentes instances Pgpool renseignée.

Configuration

Pour cette exemple :

  • Premier serveur pgpool : 192.168.100.6
  • Deuxième serveur pgpool : 192.168.100.7
  • IP virtuelle partagée : 192.168.100.8

Configuration sur le premier serveur Pgpool :

#------------------------------------------------------------------------------
# WATCHDOG
#------------------------------------------------------------------------------
use_watchdog = on
                                    # Activates watchdog
trusted_servers = ''
                                    # trusted server list which are used
                                    # to confirm network connection
                                    # (hostA,hostB,hostC,...)
delegate_IP = '192.168.100.8'
                                    # delegate IP address
wd_hostname = ''
                                    # Host name or IP address of this watchdog
wd_port = 9000
                                    # port number for watchdog service
wd_interval = 1
                                    # lifecheck interval (sec) > 0
ping_path = '/bin'
                                    # ping command path
ifconfig_path = '/sbin'
                                    # ifconfig command path
if_up_cmd = 'ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0'
                                    # startup delegate IP command
if_down_cmd = 'ifconfig eth0:0 down'
                                    # shutdown delegate IP command

arping_path = '/usr/sbin'           # arping command path

arping_cmd = 'arping -U $_IP_$ -w 1'
                                    # arping command
wd_life_point = 3

wd_lifecheck_query = 'SELECT 1'
                                    # lifecheck query to pgpool from watchdog
# Other pgpool Connection Settings

other_pgpool_hostname0 = '192.168.100.7'
                                    # Host name or IP address to connect to for other pgpool 0
other_pgpool_port0 = 9999
                                    # Port number for othet pgpool 0
other_wd_port0 = 9000
                                    # Port number for othet watchdog 0


Configuration sur le deuxième serveur pgpool

#------------------------------------------------------------------------------
# WATCHDOG
#------------------------------------------------------------------------------
use_watchdog = on
                                    # Activates watchdog
trusted_servers = ''
                                    # trusted server list which are used
                                    # to confirm network connection
                                    # (hostA,hostB,hostC,...)
delegate_IP = '192.168.100.8'
                                    # delegate IP address
wd_hostname = ''
                                    # Host name or IP address of this watchdog
wd_port = 9000
                                    # port number for watchdog service
wd_interval = 1
                                    # lifecheck interval (sec) > 0
ping_path = '/bin'
                                    # ping command path
ifconfig_path = '/sbin'
                                    # ifconfig command path
if_up_cmd = 'ifconfig eth0:0 inet $_IP_$ netmask 255.255.255.0'
                                    # startup delegate IP command
if_down_cmd = 'ifconfig eth0:0 down'
                                    # shutdown delegate IP command

arping_path = '/usr/sbin'           # arping command path

arping_cmd = 'arping -U $_IP_$ -w 1'
                                    # arping command
wd_life_point = 3

wd_lifecheck_query = 'SELECT 1'
                                    # lifecheck query to pgpool from watchdog
# Other pgpool Connection Settings

other_pgpool_hostname0 = '192.168.100.6'
                                    # Host name or IP address to connect to for other pgpool 0
other_pgpool_port0 = 9999
                                    # Port number for othet pgpool 0
other_wd_port0 = 9000
                                    # Port number for othet watchdog 0


BlocNotes.png
À noter !
Pensez a vérifier si la commande arping est bien installé sur les serveurs hébergeant les instances pgpool


Tests

Connection à l'IP virtuelle

On essaye de pinger l'IP virtuelle

[user@local]$ ping 192.168.100.8
PING 192.168.100.8 (192.168.100.8) 56(84) bytes of data.
64 bytes from 192.168.100.8: icmp_seq=1 ttl=64 time=0.328 ms
64 bytes from 192.168.100.8: icmp_seq=2 ttl=64 time=0.264 ms
64 bytes from 192.168.100.8: icmp_seq=3 ttl=64 time=0.412 ms

On vérifie que le serveur Actif a bien démarré avec l'IP virtuelle

[root@pgPool-I]# ifconfig
eth0      ...

eth0:0    inet addr:192.168.100.8 ...

lo        ...

On vérifie que le serveur en Standby n'a pas démarré avec l'IP virtuelle.

[root@pgPoll-II]# ifconfig
eth0      ...

lo        ...

On essaie de se connecter à Postgresql "psql -h IP_Virtuelle -p port".

[user@local]$ psql -h 192.168.100.8 -p 9999 -l

Basculement de l'IP Virtuelle

On test que le serveur en Standby prend bien le relais lorsque le serveur Actif rencontre un soucis.

On arrête pgpool sur le serveur Actif.

[root@pgPool-I]# {installed_dir}/bin/pgpool stop

Alors, le serveur en Standbye recupère l'IP virtuelle:

LOG:   wd_escalation: eslcalated to master pgpool
ERROR: wd_create_send_socket: connect() is failed(Connection refused)
LOG:   wd_escalation:  escaleted to delegate_IP holder

On vérifie en pingant l'ip Virtuelle.

[user@local]$ ping 192.168.100.8
PING 192.168.100.8 (192.168.100.8) 56(84) bytes of data.
64 bytes from 192.168.100.8: icmp_seq=1 ttl=64 time=0.328 ms
64 bytes from 192.168.100.8: icmp_seq=2 ttl=64 time=0.264 ms
64 bytes from 192.168.100.8: icmp_seq=3 ttl=64 time=0.412 ms


BlocNotes.png
À noter !
il peut exister un délai d'attente de plusieurs secondes avant que le ping reprenne


On vérifie que le serveur Actif ne possède plus l'IP virtuelle.

[root@pgPool-I]# ifconfig
eth0      ...

lo        ...

On vérifie que le serveur en Standby a bien récupéré l'IP virtuelle

[root@pgPool-II]# ifconfig
eth0      ...

eth0:0    inet addr:192.168.100.8 ...

lo        ...

On essaie de se connecter à PostgreSQL "psql -h 192.168.100.8 -p port".

[user@local]$ psql -h 192.168.100.8 -p 9999 -l


Warning.png
Attention !
Après que le serveur Actif soit tombé, le serveur secondaire reprend l'IP virtuelle. Cependant, dés que le serveur actif est de nouveau opérationnel, il est nécessaire de redémarrer pgpool sur les serveurs afin d'éviter tous soucis de basculement d'adresse IP


Procédure

Nouvelle instance

Pour activer le watchdog sur la nouvelle instance pgpool que vous avez créer précedemment, il suffit d'éditer les variables de la section watchdog :

Warning.png
Attention !
Vérifier les IP et Port via le tableau


Le premier pgpool ( IP1 )

#------------------------------------------------------------------------------
# WATCHDOG
#------------------------------------------------------------------------------
use_watchdog = on
                                    # Activates watchdog
trusted_servers = ''
                                    # trusted server list which are used
                                    # to confirm network connection
                                    # (hostA,hostB,hostC,...)
delegate_IP = 'IP DELEGATE'
                                    # delegate IP address
wd_hostname = ''
                                    # Host name or IP address of this watchdog
wd_port = 9033
                                    # port number for watchdog service
                                    # ifconfig command path
if_up_cmd = 'ifconfig eth1:X inet $_IP_$ netmask 255.255.255.0'
                                    # startup delegate IP command
if_down_cmd = 'ifconfig eth1:X down'
                                    # shutdown delegate IP command

# Other pgpool Connection Settings

other_pgpool_hostname0 = 'IP POLL 2'
                                    # Host name or IP address to connect to for other pgpool 0
other_pgpool_port0 = 5433
                                    # Port number for othet pgpool 0
other_wd_port0 = 9033
                                    # Port number for othet watchdog 0


Le deuxième pgpool ( IP2 )

#------------------------------------------------------------------------------
# WATCHDOG
#------------------------------------------------------------------------------
use_watchdog = on
                                    # Activates watchdog
trusted_servers = ''
                                    # trusted server list which are used
                                    # to confirm network connection
                                    # (hostA,hostB,hostC,...)
delegate_IP = 'IP DELEGATE'
                                    # delegate IP address
wd_hostname = ''
                                    # Host name or IP address of this watchdog
wd_port = 9033
                                    # port number for watchdog service
                                    # ifconfig command path
if_up_cmd = 'ifconfig eth0:1 inet $_IP_$ netmask 255.255.255.0'
                                    # startup delegate IP command
if_down_cmd = 'ifconfig eth0:1 down'
                                    # shutdown delegate IP command

# Other pgpool Connection Settings

other_pgpool_hostname0 = 'IP1'
                                    # Host name or IP address to connect to for other pgpool 0
other_pgpool_port0 = 5433
                                    # Port number for othet pgpool 0
other_wd_port0 = 9033
                                    # Port number for othet watchdog 0


BlocNotes.png
À noter !
les variables qui ne sont pas listé, sont laissées par défaut