Version 2.4.0: Ajout limitation de bande passante
All checks were successful
Tests et Vérifications / Tests unitaires BATS (push) Successful in 27s
Tests et Vérifications / Vérification ShellCheck (push) Successful in 12s
Tests et Vérifications / Vérification syntaxe Bash (push) Successful in 4s
Tests et Vérifications / Résumé des tests (push) Successful in 1s
All checks were successful
Tests et Vérifications / Tests unitaires BATS (push) Successful in 27s
Tests et Vérifications / Vérification ShellCheck (push) Successful in 12s
Tests et Vérifications / Vérification syntaxe Bash (push) Successful in 4s
Tests et Vérifications / Résumé des tests (push) Successful in 1s
- Nouvelle variable BANDWIDTH_LIMIT_MBS (défaut: 40 MB/s) - Configuration automatique de mbuffer avec option -r (rate limit) - Limitation désactivable (mettre à 0 ou vide) - Avertissement si mbuffer non installé - Compatible avec configuration externe /etc/zfs-nfs-replica/config
This commit is contained in:
parent
ac085fffb2
commit
9499f5805c
1 changed files with 21 additions and 2 deletions
|
|
@ -18,13 +18,13 @@
|
||||||
# - Fichiers d'état séparés par pool (tailles, UUIDs disques, erreurs critiques)
|
# - Fichiers d'état séparés par pool (tailles, UUIDs disques, erreurs critiques)
|
||||||
#
|
#
|
||||||
# Auteur : BENE Maël
|
# Auteur : BENE Maël
|
||||||
# Version : 2.1.0
|
# Version : 2.4.0
|
||||||
#
|
#
|
||||||
|
|
||||||
set -euo pipefail
|
set -euo pipefail
|
||||||
|
|
||||||
# Configuration
|
# Configuration
|
||||||
SCRIPT_VERSION="2.3.2"
|
SCRIPT_VERSION="2.4.0"
|
||||||
REPO_URL="https://forgejo.tellserv.fr/Tellsanguis/zfs-sync-nfs-ha"
|
REPO_URL="https://forgejo.tellserv.fr/Tellsanguis/zfs-sync-nfs-ha"
|
||||||
SCRIPT_URL="${REPO_URL}/raw/branch/main/zfs-nfs-replica.sh"
|
SCRIPT_URL="${REPO_URL}/raw/branch/main/zfs-nfs-replica.sh"
|
||||||
SCRIPT_PATH="${BASH_SOURCE[0]}"
|
SCRIPT_PATH="${BASH_SOURCE[0]}"
|
||||||
|
|
@ -53,6 +53,11 @@ STATE_DIR="/var/lib/zfs-nfs-replica"
|
||||||
SIZE_TOLERANCE=20 # Tolérance de variation en pourcentage (±20%)
|
SIZE_TOLERANCE=20 # Tolérance de variation en pourcentage (±20%)
|
||||||
MIN_REMOTE_RATIO=50 # Le distant doit avoir au moins 50% de la taille du local
|
MIN_REMOTE_RATIO=50 # Le distant doit avoir au moins 50% de la taille du local
|
||||||
|
|
||||||
|
# Configuration de limitation de bande passante
|
||||||
|
# Limite le débit de transfert en MB/s (mégaoctets par seconde)
|
||||||
|
# Mettre à 0 ou laisser vide pour désactiver la limitation
|
||||||
|
BANDWIDTH_LIMIT_MBS=40 # Limite par défaut: 40 MB/s
|
||||||
|
|
||||||
# Configuration des logs (rotation 2 semaines)
|
# Configuration des logs (rotation 2 semaines)
|
||||||
LOG_DIR="/var/log/zfs-nfs-replica"
|
LOG_DIR="/var/log/zfs-nfs-replica"
|
||||||
LOG_RETENTION_DAYS=14
|
LOG_RETENTION_DAYS=14
|
||||||
|
|
@ -1157,6 +1162,20 @@ replicate_pool() {
|
||||||
# Syncoid utilise les options SSH via la variable d'environnement SSH
|
# Syncoid utilise les options SSH via la variable d'environnement SSH
|
||||||
export SSH="ssh -i ${SSH_KEY}"
|
export SSH="ssh -i ${SSH_KEY}"
|
||||||
|
|
||||||
|
# Configuration de la limitation de bande passante via mbuffer
|
||||||
|
if command -v mbuffer &>/dev/null && [[ -n "${BANDWIDTH_LIMIT_MBS}" ]] && [[ "${BANDWIDTH_LIMIT_MBS}" -gt 0 ]]; then
|
||||||
|
# -r: rate limit (débit max en MB/s)
|
||||||
|
# -m: taille du buffer (128MB par défaut)
|
||||||
|
export MBUFFER="mbuffer -r ${BANDWIDTH_LIMIT_MBS}M -m 128M"
|
||||||
|
log "info" "Limitation de bande passante activée: ${BANDWIDTH_LIMIT_MBS} MB/s"
|
||||||
|
else
|
||||||
|
if [[ -n "${BANDWIDTH_LIMIT_MBS}" ]] && [[ "${BANDWIDTH_LIMIT_MBS}" -gt 0 ]]; then
|
||||||
|
log "warning" "mbuffer non disponible - limitation de bande passante désactivée"
|
||||||
|
log "warning" "Installer mbuffer: apt install mbuffer"
|
||||||
|
fi
|
||||||
|
unset MBUFFER
|
||||||
|
fi
|
||||||
|
|
||||||
local syncoid_opts
|
local syncoid_opts
|
||||||
# Déterminer si c'est une première synchronisation
|
# Déterminer si c'est une première synchronisation
|
||||||
if check_common_snapshots "$remote_ip" "$pool"; then
|
if check_common_snapshots "$remote_ip" "$pool"; then
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue