From fb3596f696b948b323caa6b48805aa59aa14885b Mon Sep 17 00:00:00 2001 From: Michael RICOIS Date: Fri, 6 Nov 2015 08:21:44 +0000 Subject: [PATCH] Correction --- README | 4 ++++ env.sh | 2 +- indexer/indexer-dir.sh | 24 ++++++++++++------------ indexer/indexer-ent.sh | 18 ++++++++---------- indexer/manual-ent.sh | 2 +- indexer/sql/count-ent.sql | 2 +- indexer/sql/count-enttmp.sql | 2 +- 7 files changed, 28 insertions(+), 26 deletions(-) diff --git a/README b/README index cc294ee..3e58024 100644 --- a/README +++ b/README @@ -24,6 +24,10 @@ Sphinx Engine configuration sed -i -e 's/ENV_MYSQLHOST/VALUE/g' indexer/*.sh sed -i -e 's/ENV_MYSQLUSER/VALUE/g' indexer/*.sh sed -i -e 's/ENV_MYSQLPASS/VALUE/g' indexer/*.sh + + - Crontab + - Logrotate + Indexing -------- indexer-*.sh : Index on master database with rotation diff --git a/env.sh b/env.sh index 5d6566c..2cd9609 100644 --- a/env.sh +++ b/env.sh @@ -9,4 +9,4 @@ sed -i -e s/ENV_MYSQLUSER/"$ENV_MYSQLUSER"/g sphinx.*.conf sed -i -e s/ENV_MYSQLPASS/"$ENV_MYSQLPASS"/g sphinx.*.conf sed -i -e s/ENV_MYSQLHOST/"$ENV_MYSQLHOST"/g indexer/*.sh sed -i -e s/ENV_MYSQLUSER/"$ENV_MYSQLUSER"/g indexer/*.sh -sed -i -e s/ENV_MYSQLPASS/"$ENV_MYSQLPASS"/g indexer/*.sh \ No newline at end of file +sed -i -e s/ENV_MYSQLPASS/"$ENV_MYSQLPASS"/g indexer/*.sh diff --git a/indexer/indexer-dir.sh b/indexer/indexer-dir.sh index 8960b2a..0847019 100755 --- a/indexer/indexer-dir.sh +++ b/indexer/indexer-dir.sh @@ -24,9 +24,9 @@ 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 - - echo "$(date '+%Y-%m-%d %H:%M:%S') === INDEXATION DIR" >> $PATH_LOG/indexer.log - + + echo "$(date '+%Y-%m-%d %H:%M:%S') === INDEXATION DIR" >> $PATH_LOG/indexer.log + # Nombre de lignes dans la table etablissements output=$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS jo < $PATH_SQL/count-dir.sql) nbC=''; @@ -45,9 +45,11 @@ if [ -n "$idx" ]; then done # Suppression fin de ligne nbT=$(echo $nbT|sed -e "s/^[nbT ]*//g"||sed -e "s/[ ]*$//g") - + if [ -z "$nbC" ]; then + echo $nbC elif [ -z "$nbT" ]; then + echo $nbT elif [ "$nbT" -gt "$nbC" ]; then # Create file to indicate indexing @@ -59,21 +61,19 @@ if [ -n "$idx" ]; then # 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 + $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 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 + 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 # 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 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 fi diff --git a/indexer/indexer-ent.sh b/indexer/indexer-ent.sh index e13e169..5b1279b 100755 --- a/indexer/indexer-ent.sh +++ b/indexer/indexer-ent.sh @@ -25,7 +25,7 @@ idx=$(echo $idx|sed -e "s/^[idx ]*//g"||sed -e "s/[ ]*$//g") if [ -n "$idx" ]; then if [[ "$idx" > 0 ]]; then - echo "$(date '+%Y-%m-%d %H:%M:%S') === INDEXATION ENT" >> $PATH_LOG/indexer.log + echo "$(date '+%Y-%m-%d %H:%M:%S') === INDEXATION ENT" >> $PATH_LOG/indexer.log # Nombre de lignes dans la table etablissements output=$(mysql -h$MYSQL_HOST -u$MYSQL_USER -p$MYSQL_PASS jo < $PATH_SQL/count-ent.sql) @@ -47,21 +47,22 @@ if [ -n "$idx" ]; then nbT=$(echo $nbT|sed -e "s/^[nbT ]*//g"||sed -e "s/[ ]*$//g") if [ -z "$nbC" ]; then + echo $nbC elif [ -z "$nbT" ]; then - elif [ "$nbT" -gt "$nbC" ]; then - + echo $nbT + elif [ "$nbT" -gt "$nbC" ]; then # Create file to indicate indexing rm -f $PATH_LOG/ent-*.idx echo "START $(date '+%Y-%m-%d %H:%M:%S')" >> $FILEINDEX # 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 - + # 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 @@ -69,12 +70,9 @@ if [ -n "$idx" ]; then # 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 - - 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 + 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 fi diff --git a/indexer/manual-ent.sh b/indexer/manual-ent.sh index c6b5cfb..2d4f647 100644 --- a/indexer/manual-ent.sh +++ b/indexer/manual-ent.sh @@ -3,7 +3,7 @@ PATH_LOG=/var/lib/sphinxsearch/log PATH_BIN=/usr/bin echo "$(date '+%Y-%m-%d %H:%M:%S') === REPRISE INDEXATION ENT" >> $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.reprise.conf --rotate ent ent_phx >> $PATH_LOG/indexer.log diff --git a/indexer/sql/count-ent.sql b/indexer/sql/count-ent.sql index e1aa32b..464c086 100644 --- a/indexer/sql/count-ent.sql +++ b/indexer/sql/count-ent.sql @@ -1 +1 @@ -SELECT count(*) AS etab from etablissements; +SELECT count(*) AS nb from etablissements; diff --git a/indexer/sql/count-enttmp.sql b/indexer/sql/count-enttmp.sql index cb3ce37..4b349d9 100644 --- a/indexer/sql/count-enttmp.sql +++ b/indexer/sql/count-enttmp.sql @@ -1 +1 @@ -SELECT count(*) AS etab_tmp from etablissements_tmp; +SELECT count(*) AS nb from etablissements_tmp;