issue #0001933 : Use table to know when we start indexing
This commit is contained in:
parent
a666ab3720
commit
418318bd01
@ -8,41 +8,36 @@ MYSQL_PASS=indexer
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === INDEXATION DIR" >> $PATH_LOG/indexer.log
|
||||
|
||||
# Nombre de lignes dans la table actuelle
|
||||
output=$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS jo < $PATH_SQL/count-dir.sql)
|
||||
# Is consolidated ?
|
||||
output=$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS sdv1 < $PATH_SQL/consolidate-dir.sql)
|
||||
idx='';
|
||||
for line in "$output"; do
|
||||
nbC="$line"
|
||||
idx="$line";
|
||||
done
|
||||
# Suppression fin de ligne
|
||||
nbC=$(echo $nbC|sed -e "s/^[nbC ]*//g"||sed -e "s/[ ]*$//g")
|
||||
idx=$(echo $idx|sed -e "s/^[idx ]*//g"||sed -e "s/[ ]*$//g")
|
||||
|
||||
# Nombre de lignes dans la table nouvelle
|
||||
output=$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS jo < $PATH_SQL/count-dirtmp.sql)
|
||||
for line in "$output"; do
|
||||
nbT="$line"
|
||||
done
|
||||
# Suppression fin de ligne
|
||||
nbT=$(echo $nbT|sed -e "s/^[nbT ]*//g"||sed -e "s/[ ]*$//g")
|
||||
# Lancement de l'indexation si la consolidation a eu lieu
|
||||
if [ -n "$idx" ]; then
|
||||
if [[ "$idx" > 0 ]]; then
|
||||
|
||||
# Comparaison du nombre de lignes entre nbC (ancien) et nbT (nouveau)
|
||||
if [ -z "$nbC" ]; then
|
||||
echo "etab = null"
|
||||
elif [ -z "$nbT" ]; then
|
||||
echo "etab_tmp = null"
|
||||
elif [ $nbT -gt $nbC ]; then
|
||||
# Enregistrement Debut Indexation
|
||||
mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS sdv1 -e "UPDATE sphinx_idx SET indexingBegin=NOW() WHERE id=$idx" >> $PATH_LOG/indexer.log
|
||||
|
||||
echo "Il y a $nbT lignes dans la nouvelle table dirigeants ($nbC lignes dans l'ancienne)" >> $PATH_LOG/indexer.log
|
||||
# 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
|
||||
|
||||
# Rotation des tables MySQL
|
||||
mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS jo < $PATH_SQL/rotate-dir.sql >> $PATH_LOG/indexer.log
|
||||
# Enregistrement Fin Indexation
|
||||
mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS sdv1 -e "UPDATE sphinx_idx SET indexingEnd=NOW() WHERE id=$idx" >> $PATH_LOG/indexer.log
|
||||
|
||||
else
|
||||
# Il y a plus de lignes dans l'ancienne table dirigeants ==> On ne fait rien
|
||||
echo "Il n'y a pas assez de lignes dans la nouvelle table dirigeants ($nbT / $nbC) !" >> $PATH_LOG/indexer.log
|
||||
# Rotation des tables MySQL
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Rotation Table - Debut" >> $PATH_LOG/indexer.log
|
||||
mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS jo < $PATH_SQL/rotate-dir.sql >> $PATH_LOG/indexer.log
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Rotation Table - Fin" >> $PATH_LOG/indexer.log
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === FIN INDEXATION DIR" >> $PATH_LOG/indexer.log
|
||||
|
43
indexer/indexer-ent.sh
Executable file
43
indexer/indexer-ent.sh
Executable file
@ -0,0 +1,43 @@
|
||||
#!/bin/bash
|
||||
PATH_BIN=/usr/local/sphinx/bin
|
||||
PATH_LOG=/dbs/sphinxlog
|
||||
PATH_SQL=/home/scripts/indexer/sql
|
||||
MYSQL_HOST=192.168.3.30
|
||||
MYSQL_USER=sphinx
|
||||
MYSQL_PASS=indexer
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === INDEXATION ENT" >> $PATH_LOG/indexer.log
|
||||
|
||||
# Is consolidated ?
|
||||
output=$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS sdv1 < $PATH_SQL/consolidate-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 si la consolidation a eu lieu
|
||||
if [ -n "$idx" ]; then
|
||||
if [[ "$idx" > 0 ]]; then
|
||||
|
||||
# Enregistrement Debut Indexation
|
||||
mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS sdv1 -e "UPDATE sphinx_idx SET indexingBegin=NOW() WHERE id=$idx" >> $PATH_LOG/indexer.log
|
||||
|
||||
# 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
|
||||
|
||||
# Enregistrement Fin Indexation
|
||||
mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS sdv1 -e "UPDATE sphinx_idx SET indexingEnd=NOW() WHERE id=$idx" >> $PATH_LOG/indexer.log
|
||||
|
||||
# Rotation des tables MySQL
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Rotation Table - Debut" >> $PATH_LOG/indexer.log
|
||||
mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS jo < $PATH_SQL/rotate-ent.sql >> $PATH_LOG/indexer.log
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') - Rotation Table - Fin" >> $PATH_LOG/indexer.log
|
||||
|
||||
fi
|
||||
fi
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === FIN INDEXATION ENT" >> $PATH_LOG/indexer.log
|
@ -1,49 +0,0 @@
|
||||
#!/bin/bash
|
||||
PATH_BIN=/usr/local/sphinx/bin
|
||||
PATH_LOG=/dbs/sphinxlog
|
||||
PATH_SQL=/home/scripts/indexer/sql
|
||||
MYSQL_HOST=192.168.3.30
|
||||
MYSQL_USER=sphinx
|
||||
MYSQL_PASS=indexer
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === INDEXATION ENT" >> $PATH_LOG/indexer.log
|
||||
|
||||
# Nombre de lignes dans la table actuelle
|
||||
output=$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS jo < $PATH_SQL/count-ent.sql)
|
||||
for line in "$output"; do
|
||||
nbC="$line"
|
||||
done
|
||||
# Suppression fin de ligne
|
||||
nbC=$(echo $nbC|sed -e "s/^[nbC ]*//g"||sed -e "s/[ ]*$//g")
|
||||
|
||||
# Nombre de lignes dans la table nouvelle
|
||||
output=$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS jo < $PATH_SQL/count-enttmp.sql)
|
||||
for line in "$output"; do
|
||||
nbT="$line"
|
||||
done
|
||||
# Suppression fin de ligne
|
||||
nbT=$(echo $nbT|sed -e "s/^[nbT ]*//g"||sed -e "s/[ ]*$//g")
|
||||
|
||||
# Comparaison du nombre de lignes entre etab (ancien) et etab_tmp (nouveau)
|
||||
if [ -z "$nbC" ]; then
|
||||
echo "nbC = null"
|
||||
elif [ -z "$nbT" ]; then
|
||||
echo "nbT = null"
|
||||
elif [ $nbT -gt $nbC ]; then
|
||||
|
||||
echo "Il y a $nbT lignes dans la nouvelle table etablissement ($nbC lignes dans l'ancienne)" >> $PATH_LOG/indexer.log
|
||||
|
||||
# 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
|
||||
|
||||
# Rotation des tables MySQL
|
||||
mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS jo < $PATH_SQL/rotate-ent.sql >> $PATH_LOG/indexer.log
|
||||
|
||||
else
|
||||
# Il y a plus de lignes dans l'ancienne table etablissements ==> On ne fait rien
|
||||
echo "Il n'y a pas assez de lignes dans la nouvelle table etablissement ($nbT / $nbC) !" >> $PATH_LOG/indexer.log
|
||||
fi
|
||||
|
||||
echo "$(date '+%Y-%m-%d %H:%M:%S') === FIN INDEXATION ENT" >> $PATH_LOG/indexer.log
|
6
indexer/sql/consolidate-dir.sql
Normal file
6
indexer/sql/consolidate-dir.sql
Normal file
@ -0,0 +1,6 @@
|
||||
SELECT id FROM sphinx_idx
|
||||
WHERE createEnd BETWEEN (NOW() - INTERVAL 1 HOUR) AND NOW()
|
||||
AND nom = 'jo.dirigeants'
|
||||
AND indexingBegin IS NULL
|
||||
AND indexingEnd IS NULL
|
||||
ORDER BY createEnd DESC LIMIT 1;
|
6
indexer/sql/consolidate-ent.sql
Normal file
6
indexer/sql/consolidate-ent.sql
Normal file
@ -0,0 +1,6 @@
|
||||
SELECT id FROM sphinx_idx
|
||||
WHERE createEnd BETWEEN (NOW() - INTERVAL 1 HOUR) AND NOW()
|
||||
AND nom = 'jo.etablissements'
|
||||
AND indexingBegin IS NULL
|
||||
AND indexingEnd IS NULL
|
||||
ORDER BY createEnd DESC LIMIT 1;
|
Loading…
Reference in New Issue
Block a user