Vous avez choisi Manticore Search parce que la recherche legacy basée sur Sphinx dans l’application a tourné une décennie et que le chemin de migration est « modifier la chaîne de connexion ». Le hic, c’est que la pile legacy faisait tourner un seul searchd contre une seule VM, et que vous voulez maintenant trois nœuds avec des index real-time répliqués — écrire sur n’importe quel nœud, lire sur n’importe quel nœud, perdre un nœud sans incident. Manticore 6.x supporte ça nativement via des groupes de réplication basés sur Galera plus des index distribués avec agents miroirs, mais la doc suppose que vous maîtrisez déjà les idiomes SphinxQL et passe vite sur les détails opérationnels d’une exploitation sous systemd avec une vraie histoire de sauvegarde. Voici l’installateur qui comble ce trou.
Ce qui se passe
Un déploiement Manticore en grappe a deux primitives de réplication, et elles ne sont pas interchangeables. La première est la grappe de réplication — un groupe de réplication par write-set, façon Galera, à travers trois (ou plus) nœuds. Vous créez la grappe sur le nœud 1 avec CREATE CLUSTER mc_cluster, puis JOIN CLUSTER mc_cluster AT '10.10.0.61:9312' sur les nœuds 2 et 3. Les index ajoutés à la grappe (ALTER CLUSTER mc_cluster ADD products) sont répliqués synchronement entre tous les membres. C’est l’outil qu’il faut pour les index à écritures intenses et durabilité critique — chaque transaction est confirmée par un quorum avant le commit.
La seconde primitive est l’index distribué avec agents miroirs. Un index distribué idx_dist est un index logique qui éclate sur N « agents » (autres searchd sur d’autres nœuds) et fusionne les résultats. Avec agent_persistent et ha_strategy = roundrobin, un seul SELECT contre idx_dist pulvérise vers tous les miroirs en santé, et un miroir tombé est exclu automatiquement. C’est l’outil qu’il faut pour le scale-out en lecture — vous répliquez à la main des index qui changent lentement (ou par tâches batch INDEXER) sur N nœuds et utilisez l’index distribué comme façade de lecture.
Les déploiements production combinent souvent les deux : les index real-time qui prennent les écritures live vont dans une grappe de réplication (synchrone, écritures plus lentes, durable) ; les index reconstruits par indexer qui prennent les écritures batch sont miroirisés à la main avec rsync et lus à travers des index distribués (rapide, cohérent à terme, peu cher à scaler).
L’histoire du binlog : searchd écrit un binlog par index real-time pour la récupération sur crash. Mettez binlog_path = /var/lib/manticore/binlog et binlog_flush = 1 (flush à chaque commit) pour la durabilité ; binlog_max_log_size contrôle la rotation. Les sauvegardes : un BACKUP INDEX SQL quotidien qui dump un snapshot cohérent vers un chemin dédié, puis rclone vers S3, plus le binlog comme histoire WAL pour la récupération point-in-time.
Comment vérifier
Statut de grappe depuis n’importe quel nœud via SphinxQL sur le port 9306 :
mysql -h 10.10.0.61 -P 9306 -e "SHOW STATUS LIKE 'cluster_%'"
# cluster_name = mc_cluster
# cluster_status = synced
# cluster_size = 3
# cluster_ready = yes
Chaque nœud voit les deux autres :
mysql -h 10.10.0.61 -P 9306 -e "SHOW STATUS LIKE 'cluster_node_state'"
# cluster_node_state = primary
mysql -h 10.10.0.62 -P 9306 -e "SHOW STATUS LIKE 'cluster_node_state'"
mysql -h 10.10.0.63 -P 9306 -e "SHOW STATUS LIKE 'cluster_node_state'"
Un index distribué résout tous ses agents en santé :
mysql -h 10.10.0.61 -P 9306 -e "SHOW AGENT STATUS"
# Chaque ligne d'agent doit montrer ha_strategy=roundrobin et un success_count
# non nul, avec un last_query_time sous votre seuil d'alerte.
Flush du binlog :
ls -lh /var/lib/manticore/binlog/
mysql -h 10.10.0.61 -P 9306 -e "SHOW STATUS LIKE 'binlog%'"
Le correctif
Enregistrez le script sous /root/setup-manticore-node.sh et lancez-le sur chacun des trois nœuds Ubuntu 22.04. L’installateur gère le durcissement de base, le dépôt APT Manticore officiel, un /etc/manticoresearch/manticore.conf par nœud (le fichier que Manticore 6 appelle un « config » mais qui est plutôt un config daemon — les définitions d’index vivent dans des CREATE TABLE SphinxQL), l’unité systemd avec des limites élevées, les règles de pare-feu pour le port 9312 (protocole binaire, grappe + agents) et 9306 (SphinxQL/MySQL), un timer de sauvegarde qui appelle BACKUP INDEX chaque jour et rclone la sortie, et les commandes post-installation à imprimer pour chaque nœud afin que vous puissiez les passer à la main et regarder la grappe se former.
#!/usr/bin/env bash
set -euo pipefail
### Ubuntu 22.04 Manticore Search 6.x cluster installer
### Run on each of 3 nodes; after install, manually run the SQL commands printed
### at the end on node 1 (CREATE CLUSTER) then nodes 2/3 (JOIN CLUSTER).
if [[ "$(id -u)" -ne 0 ]]; then
echo "Run as root."
exit 1
fi
# === EDIT PER NODE ===
NODE_NAME="mc01"
NODE_IP="10.10.0.61"
PEER_IPS=("10.10.0.61" "10.10.0.62" "10.10.0.63")
PEER_NAMES=("mc01" "mc02" "mc03")
CLUSTER_NAME="mc_cluster"
S3_ENDPOINT="s3.us-east-2.wasabisys.com"
S3_BUCKET="acme-mc-backups"
S3_ACCESS_KEY="CHANGE_ME"
S3_SECRET_KEY="CHANGE_ME"
# =====================
echo
echo "========================================"
echo "Manticore node ${NODE_NAME} (${NODE_IP})"
echo "========================================"
echo
echo "==> Updating base OS"
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get -y upgrade
apt-get -y install curl wget gnupg apt-transport-https ca-certificates \
ufw fail2ban unattended-upgrades chrony jq socat net-tools dnsutils \
mysql-client rsync rclone
systemctl enable --now chrony
echo "==> Kernel/sysctl"
cat > /etc/sysctl.d/99-manticore.conf <<'SYSCTL'
fs.file-max = 2097152
net.core.somaxconn = 4096
net.ipv4.tcp_max_syn_backlog = 8192
net.ipv4.ip_local_port_range = 10240 65535
SYSCTL
sysctl --system
cat > /etc/security/limits.d/99-manticore.conf <<'LIMITS'
manticore soft nofile 65535
manticore hard nofile 65535
LIMITS
echo "==> Hardening SSH"
sed -i 's|^[#[:space:]]*PermitRootLogin.*|PermitRootLogin prohibit-password|' /etc/ssh/sshd_config
sed -i 's|^[#[:space:]]*PasswordAuthentication.*|PasswordAuthentication no|' /etc/ssh/sshd_config
sshd -t && systemctl restart ssh
echo "==> UFW: allow peer-only access to 9312, app access to 9306"
ufw --force reset
ufw default deny incoming
ufw default allow outgoing
ufw allow OpenSSH
for p in "${PEER_IPS[@]}"; do
ufw allow from "$p" to any port 9312 proto tcp
ufw allow from "$p" to any port 9306 proto tcp
# Galera SST port range
ufw allow from "$p" to any port 9315:9325 proto tcp
done
ufw allow 9306/tcp comment "Manticore SphinxQL — restrict to app subnet in prod"
ufw --force enable
cat > /etc/fail2ban/jail.d/sshd.local <<'FAIL2BAN'
[sshd]
enabled = true
port = ssh
backend = systemd
maxretry = 4
findtime = 10m
bantime = 1h
FAIL2BAN
systemctl enable --now fail2ban
echo "==> Adding Manticore APT repository"
wget -qO /tmp/manticore-repo.deb \
https://repo.manticoresearch.com/manticore-repo.noarch.deb
dpkg -i /tmp/manticore-repo.deb
rm -f /tmp/manticore-repo.deb
apt-get update
apt-get -y install manticore manticore-extra
apt-mark hold manticore manticore-extra
echo "==> Stopping default service to write our config"
systemctl stop manticore || true
echo "==> /etc/manticoresearch/manticore.conf"
mkdir -p /var/lib/manticore /var/log/manticore /var/lib/manticore/binlog
chown -R manticore:manticore /var/lib/manticore /var/log/manticore
cat > /etc/manticoresearch/manticore.conf <<EOF
common {
plugin_dir = /usr/share/manticore/modules
lemmatizer_base = /usr/share/manticore
}
searchd {
listen = ${NODE_IP}:9312
listen = ${NODE_IP}:9306:mysql
listen = ${NODE_IP}:9308:http
listen = ${NODE_IP}:9315-9325:replication
log = /var/log/manticore/searchd.log
query_log = /var/log/manticore/query.log
query_log_format = sphinxql
read_timeout = 30
client_timeout = 600
max_connections = 1024
pid_file = /run/manticore/searchd.pid
data_dir = /var/lib/manticore
binlog_path = /var/lib/manticore/binlog
binlog_flush = 1
binlog_max_log_size = 256M
# Production-grade: require auth for the cluster API
shutdown_timeout = 30s
network_timeout = 5s
# Distributed-index agent defaults
agent_connect_timeout = 1000
agent_query_timeout = 3000
ha_period_karma = 60
ha_ping_interval = 1000
}
EOF
chown root:manticore /etc/manticoresearch/manticore.conf
chmod 640 /etc/manticoresearch/manticore.conf
mkdir -p /run/manticore
chown manticore:manticore /run/manticore
echo "==> systemd override for limits + tmpfiles"
mkdir -p /etc/systemd/system/manticore.service.d
cat > /etc/systemd/system/manticore.service.d/override.conf <<'OV'
[Service]
LimitNOFILE=65535
Restart=on-failure
RestartSec=5s
RuntimeDirectory=manticore
RuntimeDirectoryMode=0755
OV
systemctl daemon-reload
systemctl enable --now manticore
echo "==> Waiting for SphinxQL on :9306"
for i in {1..30}; do
if mysql -h "${NODE_IP}" -P 9306 -e "SELECT 1" >/dev/null 2>&1; then break; fi
sleep 2
done
echo "==> /usr/local/bin/mc-backup.sh (daily BACKUP INDEX + rclone)"
cat > /usr/local/bin/mc-backup.sh <<'BCK'
#!/usr/bin/env bash
set -euo pipefail
NODE_IP="$(awk '/listen = .*:9306/ {gsub(/listen = /,""); split($0,a,":"); print a[1]; exit}' /etc/manticoresearch/manticore.conf)"
STAMP=$(date -u +"%Y%m%dT%H%M%SZ")
DEST="/var/lib/manticore/backups/${STAMP}"
mkdir -p "$DEST"
chown manticore:manticore "$DEST"
# Run BACKUP for every replicated index on this node
INDEXES=$(mysql -h "${NODE_IP}" -P 9306 -BNe "SHOW TABLES" | awk '{print $1}')
for idx in $INDEXES; do
mysql -h "${NODE_IP}" -P 9306 -e "BACKUP ${idx} TO '${DEST}'" || true
done
# Push to S3
rclone sync "$DEST" "wasabi:acme-mc-backups/${STAMP}/" --transfers=4 --checkers=8 || true
# Keep 14 days locally
find /var/lib/manticore/backups/ -mindepth 1 -maxdepth 1 -type d -mtime +14 -exec rm -rf {} \;
BCK
chmod 750 /usr/local/bin/mc-backup.sh
cat > /etc/systemd/system/mc-backup.service <<'SVC'
[Unit]
Description=Manticore daily BACKUP INDEX
After=manticore.service
[Service]
Type=oneshot
ExecStart=/usr/local/bin/mc-backup.sh
SVC
cat > /etc/systemd/system/mc-backup.timer <<'TMR'
[Unit]
Description=Daily Manticore BACKUP at 02:30
[Timer]
OnCalendar=*-*-* 02:30:00
Persistent=true
RandomizedDelaySec=10min
[Install]
WantedBy=timers.target
TMR
mkdir -p /root/.config/rclone
cat > /root/.config/rclone/rclone.conf <<EOF
[wasabi]
type = s3
provider = Wasabi
access_key_id = ${S3_ACCESS_KEY}
secret_access_key = ${S3_SECRET_KEY}
endpoint = ${S3_ENDPOINT}
acl = private
EOF
chmod 600 /root/.config/rclone/rclone.conf
systemctl daemon-reload
systemctl enable --now mc-backup.timer
echo
echo "========================================"
echo "DONE — ${NODE_NAME}"
echo "========================================"
echo
echo "Listeners:"
ss -lntp | grep -E ':(9306|9308|9312)\b' || true
echo
echo "Manticore version + status:"
mysql -h "${NODE_IP}" -P 9306 -e "SHOW STATUS LIKE 'version'; SHOW STATUS LIKE 'uptime';" || true
echo
echo "==> NEXT STEPS (run by hand once all 3 nodes are up):"
echo
echo " On ${PEER_NAMES[0]} (${PEER_IPS[0]}):"
echo " mysql -h ${PEER_IPS[0]} -P 9306 -e \"CREATE CLUSTER ${CLUSTER_NAME}\""
echo
echo " On ${PEER_NAMES[1]} (${PEER_IPS[1]}):"
echo " mysql -h ${PEER_IPS[1]} -P 9306 -e \"JOIN CLUSTER ${CLUSTER_NAME} AT '${PEER_IPS[0]}:9312'\""
echo
echo " On ${PEER_NAMES[2]} (${PEER_IPS[2]}):"
echo " mysql -h ${PEER_IPS[2]} -P 9306 -e \"JOIN CLUSTER ${CLUSTER_NAME} AT '${PEER_IPS[0]}:9312'\""
echo
echo " Then on any node — create a real-time table inside the cluster:"
echo " mysql -h ${PEER_IPS[0]} -P 9306 -e \"CREATE TABLE products (id BIGINT, title TEXT, sku STRING, price FLOAT) rt_mem_limit='256M'\""
echo " mysql -h ${PEER_IPS[0]} -P 9306 -e \"ALTER CLUSTER ${CLUSTER_NAME} ADD products\""
echo
echo " Distributed read-facing index (run on each node, idx_dist points at all peers):"
echo " mysql -h ${NODE_IP} -P 9306 -e \"CREATE TABLE idx_dist type='distributed' agent='${PEER_IPS[0]}:9312:products' agent='${PEER_IPS[1]}:9312:products' agent='${PEER_IPS[2]}:9312:products' ha_strategy='roundrobin'\""
echo
Quand les trois nœuds sont en place et que les commandes SQL post-installation ont été passées, faites un test d’écriture contre n’importe quel nœud et confirmez qu’il se réplique :
mysql -h 10.10.0.61 -P 9306 -e "INSERT INTO products(id,title,sku,price) VALUES (1,'Test row','SKU-001',9.99)"
mysql -h 10.10.0.62 -P 9306 -e "SELECT * FROM products WHERE id=1"
mysql -h 10.10.0.63 -P 9306 -e "SELECT * FROM products WHERE id=1"
La ligne doit apparaître sur les trois. Tuez le process searchd sur le nœud 1 avec systemctl stop manticore et confirmez que SHOW STATUS LIKE 'cluster_size' depuis les survivants annonce 2 ; les écritures doivent continuer, le statut de la grappe ne passe à non-Primary que si vous perdez deux nœuds sur trois. Remontez le nœud 1 et il rejoint automatiquement.
L’histoire de sauvegarde a deux couches — le BACKUP INDEX quotidien vers S3 couvre le chemin lent de récupération, le binlog couvre le replay point-in-time entre deux sauvegardes. Testez la restauration sur une grappe bac à sable chaque mois ; une sauvegarde jamais restaurée est une hypothèse.
Pour Manticore sur de la compute infogérée, avec supervision du groupe de réplication et exercices d’intégrité de sauvegarde, notre équipe exploite la grappe sous Environnements infogérés sur Cloud Compute. Planifiez un appel de cadrage.