Add slave indexing script
This commit is contained in:
parent
ac29ef9023
commit
20d0b73ca2
@ -1,3 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
/usr/bin/indexer act dir dir_phx ent ent_phx ciblage
|
46
indexer/slave-ciblage.sh
Normal file
46
indexer/slave-ciblage.sh
Normal file
@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
PATH_BIN=/usr/bin
|
||||
PATH_LOG=/var/lib/sphinx/log
|
||||
PATH_SQL=/home/indexer/sql
|
||||
MYSQL_HOST=192.168.3.30
|
||||
MYSQL_USER=sphinx
|
||||
MYSQL_PASS=indexer
|
||||
|
||||
# Indexation déjà lancé
|
||||
FILEINDEX=$PATH_LOG/ciblage-$(date '+%Y%m%d').idx
|
||||
if [ -f "$FILEINDEX" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Indexation sur le master ?
|
||||
output=$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS sdv1 < $PATH_SQL/slave-ciblage.sql)
|
||||
idx='';
|
||||
for line in "$output"; do
|
||||
idx="$line";
|
||||
done
|
||||
# Suppression fin de ligne
|
||||
idx=$(echo $idx|sed -e "s/^[idx ]*//g"||sed -e "s/[ ]*$//g")
|
||||
|
||||
# Lancement de l'indexation
|
||||
if [ -n "$idx" ]; then
|
||||
if [[ "$idx" > 0 ]]; then
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === INDEXATION CIBLAGE" >> $PATH_LOG/indexer.log
|
||||
|
||||
# Create file to indicate indexing on slave
|
||||
rm -v $PATH_LOG/ciblage-*.idx
|
||||
echo "START $(date '+%Y-%m-%d %H:%M:%S')" >> $FILEINDEX
|
||||
|
||||
# Sphinx rotate
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Sphinx - Debut" >> $PATH_LOG/indexer.log
|
||||
$PATH_BIN/indexer --config /etc/sphinxsearch/sphinx.conf --rotate ciblage >> $PATH_LOG/indexer.log
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Sphinx - Fin" >> $PATH_LOG/indexer.log
|
||||
|
||||
echo "FIN $(date '+%Y-%m-%d %H:%M:%S')" >> $FILEINDEX
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === FIN INDEXATION CIBLAGE" >> $PATH_LOG/indexer.log
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
|
46
indexer/slave-dir.sh
Normal file
46
indexer/slave-dir.sh
Normal file
@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
PATH_BIN=/usr/bin
|
||||
PATH_LOG=/var/lib/sphinx/log
|
||||
PATH_SQL=/home/indexer/sql
|
||||
MYSQL_HOST=192.168.3.30
|
||||
MYSQL_USER=sphinx
|
||||
MYSQL_PASS=indexer
|
||||
|
||||
# Indexation déjà lancé
|
||||
FILEINDEX=$PATH_LOG/dir-$(date '+%Y%m%d').idx
|
||||
if [ -f "$FILEINDEX" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Indexation sur le master ?
|
||||
output=$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS sdv1 < $PATH_SQL/slave-dir.sql)
|
||||
idx='';
|
||||
for line in "$output"; do
|
||||
idx="$line";
|
||||
done
|
||||
# Suppression fin de ligne
|
||||
idx=$(echo $idx|sed -e "s/^[idx ]*//g"||sed -e "s/[ ]*$//g")
|
||||
|
||||
# Lancement de l'indexation
|
||||
if [ -n "$idx" ]; then
|
||||
if [[ "$idx" > 0 ]]; then
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === INDEXATION DIR" >> $PATH_LOG/indexer.log
|
||||
|
||||
# Create file to indicate indexing on slave
|
||||
rm -v $PATH_LOG/dir-*.idx
|
||||
echo "START $(date '+%Y-%m-%d %H:%M:%S')" >> $FILEINDEX
|
||||
|
||||
# Sphinx rotate
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Sphinx - Debut" >> $PATH_LOG/indexer.log
|
||||
$PATH_BIN/indexer --config /etc/sphinxsearch/sphinx.conf --rotate dir dir_phx >> $PATH_LOG/indexer.log
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Sphinx - Fin" >> $PATH_LOG/indexer.log
|
||||
|
||||
echo "FIN $(date '+%Y-%m-%d %H:%M:%S')" >> $FILEINDEX
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === FIN INDEXATION DIR" >> $PATH_LOG/indexer.log
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
|
46
indexer/slave-ent.sh
Normal file
46
indexer/slave-ent.sh
Normal file
@ -0,0 +1,46 @@
|
||||
#!/bin/bash
|
||||
PATH_BIN=/usr/bin
|
||||
PATH_LOG=/var/lib/sphinx/log
|
||||
PATH_SQL=/home/indexer/sql
|
||||
MYSQL_HOST=192.168.3.30
|
||||
MYSQL_USER=sphinx
|
||||
MYSQL_PASS=indexer
|
||||
|
||||
# Indexation déjà lancé
|
||||
FILEINDEX=$PATH_LOG/ent-$(date '+%Y%m%d').idx
|
||||
if [ -f "$FILEINDEX" ]; then
|
||||
exit 0
|
||||
fi
|
||||
|
||||
# Indexation sur le master ?
|
||||
output=$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS sdv1 < $PATH_SQL/slave-ent.sql)
|
||||
idx='';
|
||||
for line in "$output"; do
|
||||
idx="$line";
|
||||
done
|
||||
# Suppression fin de ligne
|
||||
idx=$(echo $idx|sed -e "s/^[idx ]*//g"||sed -e "s/[ ]*$//g")
|
||||
|
||||
# Lancement de l'indexation
|
||||
if [ -n "$idx" ]; then
|
||||
if [[ "$idx" > 0 ]]; then
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === INDEXATION ENT" >> $PATH_LOG/indexer.log
|
||||
|
||||
# Create file to indicate indexing on slave
|
||||
rm -v $PATH_LOG/ent-*.idx
|
||||
echo "START $(date '+%Y-%m-%d %H:%M:%S')" >> $FILEINDEX
|
||||
|
||||
# Sphinx rotate
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Sphinx - Debut" >> $PATH_LOG/indexer.log
|
||||
$PATH_BIN/indexer --config /etc/sphinxsearch/sphinx.conf --rotate ent ent_phx >> $PATH_LOG/indexer.log
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Sphinx - Fin" >> $PATH_LOG/indexer.log
|
||||
|
||||
echo "FIN $(date '+%Y-%m-%d %H:%M:%S')" >> $FILEINDEX
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === FIN INDEXATION ENT" >> $PATH_LOG/indexer.log
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
|
4
indexer/sql/slave-ciblage.sql
Normal file
4
indexer/sql/slave-ciblage.sql
Normal file
@ -0,0 +1,4 @@
|
||||
SELECT id FROM sphinx_idx
|
||||
WHERE indexingEnd BETWEEN (NOW() - INTERVAL 2 HOUR) AND NOW()
|
||||
AND nom = 'jo.etablissements_act'
|
||||
ORDER BY indexingEnd DESC LIMIT 1;
|
4
indexer/sql/slave-dir.sql
Normal file
4
indexer/sql/slave-dir.sql
Normal file
@ -0,0 +1,4 @@
|
||||
SELECT id FROM sphinx_idx
|
||||
WHERE indexingEnd BETWEEN (NOW() - INTERVAL 2 HOUR) AND NOW()
|
||||
AND nom = 'jo.dirigeants'
|
||||
ORDER BY indexingEnd DESC LIMIT 1;
|
4
indexer/sql/slave-ent.sql
Normal file
4
indexer/sql/slave-ent.sql
Normal file
@ -0,0 +1,4 @@
|
||||
SELECT id FROM sphinx_idx
|
||||
WHERE indexingEnd BETWEEN (NOW() - INTERVAL 2 HOUR) AND NOW()
|
||||
AND nom = 'jo.etablissements'
|
||||
ORDER BY indexingEnd DESC LIMIT 1;
|
Loading…
Reference in New Issue
Block a user