Maison > base de données > tutoriel mysql > le corps du texte

【实战】sphinx索引合并的脚本

WBOY
Libérer: 2016-06-07 16:10:56
original
1637 Les gens l'ont consulté

mkdir /usr/local/sphinx/scripts----0.全部主索引新建#!/bin/bash#ocpyang@126.com#main_index_update.sh/usr/local/sphinx/bin/indexer src2 -c /usr/local/sphinx/etc/sphinx.conf --rotate /dev/null 21/usr/local/sphinx/bin/indexer src3 -c /usr/loca

mkdir /usr/local/sphinx/scripts


----0.全部主索引新建

#!/bin/bash
#ocpyang@126.com
#main_index_update.sh
/usr/local/sphinx/bin/indexer src2  -c /usr/local/sphinx/etc/sphinx.conf  --rotate > /dev/null 2>&1
/usr/local/sphinx/bin/indexer src3  -c /usr/local/sphinx/etc/sphinx.conf  --rotate > /dev/null 2>&1
/usr/local/sphinx/bin/indexer src4  -c /usr/local/sphinx/etc/sphinx.conf  --rotate > /dev/null 2>&1
/usr/local/sphinx/bin/indexer src5  -c /usr/local/sphinx/etc/sphinx.conf  --rotate > /dev/null 2>&1



----1.增量索引
#!/bin/bash
#ocpyang@126.com
#delta_index_update.sh
/usr/local/sphinx/bin/indexer src2_delta  -c /usr/local/sphinx/etc/sphinx.conf  --rotate > /dev/null 2>&1
/usr/local/sphinx/bin/indexer src3_delta  -c /usr/local/sphinx/etc/sphinx.conf  --rotate > /dev/null 2>&1
/usr/local/sphinx/bin/indexer src4_delta  -c /usr/local/sphinx/etc/sphinx.conf  --rotate > /dev/null 2>&1
/usr/local/sphinx/bin/indexer src5_delta  -c /usr/local/sphinx/etc/sphinx.conf  --rotate > /dev/null 2>&1


---2.合并索引

#!/bin/bash
#ocpyang@126.com
#merge_daily_index.sh
# merge "main + delta" indexes

##1. index abount tblpnr
/usr/local/sphinx/bin/indexer --merge src2 src2_delta -c /usr/local/sphinx/etc/sphinx.conf --rotate >> /usr/local/sphinx/var/log/index_merge.log 2>&1

if [ "$?" -eq 0 ]; then
			/usr/local/mysql/bin/mysql -h127.0.0.1 -uroot -ppassword  -e "REPLACE INTO jinri.sph_counter SELECT 2, MAX(id),max(update_time) FROM jinripnr.tblpnr"
fi


##2. index abount tblticketno
/usr/local/sphinx/bin/indexer --merge src3 src3_delta -c /usr/local/sphinx/etc/sphinx.conf --rotate >> /usr/local/sphinx/var/log/index_merge.log 2>&1

if [ "$?" -eq 0 ]; then
        /usr/local/mysql/bin/mysql -h127.0.0.1 -uroot -ppassword -e "REPLACE INTO jinri.sph_counter SELECT 3, MAX(id),max(update_time) FROM jinritickno.tblticketno"
fi


##3. index abount tblpassengername
/usr/local/sphinx/bin/indexer --merge src4 src4_delta -c /usr/local/sphinx/etc/sphinx.conf --rotate >> /usr/local/sphinx/var/log/index_merge.log 2>&1

if [ "$?" -eq 0 ]; then
        /usr/local/mysql/bin/mysql -h127.0.0.1 -uroot -ppassword -e "REPLACE INTO jinri.sph_counter SELECT 4, MAX(id),max(update_time) FROM jinripname.tblpassengername"
fi



##4. index abount tblorderno
/usr/local/sphinx/bin/indexer --merge src5 src5_delta -c /usr/local/sphinx/etc/sphinx.conf --rotate  >> /usr/local/sphinx/var/log/index_merge.log 2>&1

if [ "$?" -eq 0 ]; then
        /usr/local/mysql/bin/mysql -h127.0.0.1 -uroot -ppassword -e "REPLACE INTO jinri.sph_counter SELECT 5, MAX(id),max(update_time) FROM jinriorderno.tblorderno"
fi

####再次新建增量索引
#delta_index_update.sh
/usr/local/sphinx/bin/indexer src2_delta  -c /usr/local/sphinx/etc/sphinx.conf  --rotate > /dev/null 2>&1
/usr/local/sphinx/bin/indexer src3_delta  -c /usr/local/sphinx/etc/sphinx.conf  --rotate > /dev/null 2>&1
/usr/local/sphinx/bin/indexer src4_delta  -c /usr/local/sphinx/etc/sphinx.conf  --rotate > /dev/null 2>&1
/usr/local/sphinx/bin/indexer src5_delta  -c /usr/local/sphinx/etc/sphinx.conf  --rotate > /dev/null 2>&1



 


# crontab -l

# crontab -e

*/5 * * * *  /usr/local/mysql/scripts/delta_index_update.sh
0 2 * * *    /usr/local/mysql/scripts/merge_daily_index.sh


---合并语法
/usr/local/sphinx/bin/indexer --merge src3 src3_delta -c /usr/local/sphinx/etc/sphinx.conf \
--rotate --merge-dst-range deleted 0 0  --merge-killlists


--查看job执行日志
tail -f /var/log/cron
Copier après la connexion

Étiquettes associées:
source:php.cn
Déclaration de ce site Web
Le contenu de cet article est volontairement contribué par les internautes et les droits d'auteur appartiennent à l'auteur original. Ce site n'assume aucune responsabilité légale correspondante. Si vous trouvez un contenu suspecté de plagiat ou de contrefaçon, veuillez contacter admin@php.cn
Tutoriels populaires
Plus>
Derniers téléchargements
Plus>
effets Web
Code source du site Web
Matériel du site Web
Modèle frontal
À propos de nous Clause de non-responsabilité Sitemap
Site Web PHP chinois:Formation PHP en ligne sur le bien-être public,Aidez les apprenants PHP à grandir rapidement!