GNU/Linux >> Linux Esercitazione >  >> Ubuntu

Come installare e configurare Sphinx su Ubuntu 16.04, 14.04

Sphinx è un server di ricerca full-text semplice, pertinente e open source. È scritto nel linguaggio di programmazione C++ e funziona con Linux e altri sistemi operativi popolari. Questo tutorial ti aiuterà a installare e configurare il server di ricerca full-text Sphinx sui sistemi operativi Ubuntu 16.04, 14.04 LTS.

Prerequisiti

Prima di iniziare questa guida, devi disporre di quanto segue.

  • Server Ubuntu con accesso sudo
  • Server MySQL preinstallato

Passaggio 1:installa Sfinge

Installare Sphinx su Ubuntu è facile perché si trova nel repository del pacchetto nativo. Installalo usando il gestore di pacchetti apt-get sul tuo sistema Ubuntu.

sudo add-apt-repository ppa:builds/sphinxsearch-rel22
sudo apt-get update
sudo apt-get install sphinxsearch

Fase 2:importa il database MySQL

Importiamo il file SQL di esempio nel database. Innanzitutto, crea un database denominato test nel tuo server MySQL, dopodiché ripristina il database fornito dal pacchetto di ricerca sphinx.

sudo mysqladmin -u root -p create test
sudo mysql -u root -p test < /usr/share/doc/sphinxsearch/example-conf/example.sql

Fase 3 – Configura Sfinge

Modifica la configurazione della sfinge come di seguito e modifica la configurazione della connessione MySQL come mostrato di seguito.

sudo vi /etc/sphinxsearch/sphinx.conf
source src1
{
	# data source type. mandatory, no default value
	# known types are mysql, pgsql, mssql, xmlpipe, xmlpipe2, odbc
	type                    = mysql

	#####################################################################
	## SQL settings (for 'mysql' and 'pgsql' types)
	#####################################################################

	# some straightforward parameters for SQL source types
	sql_host                = localhost
	sql_user                = root
	sql_pass                = secret
	sql_db                  = test
	sql_port                = 3306  # optional, default is 3306

Fase 4 – Esecuzione dell'indicizzatore

Esegui l'indicizzatore per creare l'indice full-text dai tuoi dati. L'indicizzatore è il primo dei due strumenti principali come parte di Sphinx. Funziona per raccogliere i dati che saranno ricercabili. Vedrai i risultati come di seguito.

sudo indexer --all 

Sphinx 2.2.11-id64-release (95ae9a6)
Copyright (c) 2001-2016, Andrew Aksyonoff
Copyright (c) 2008-2016, Sphinx Technologies Inc (http://sphinxsearch.com)

using config file '/etc/sphinxsearch/sphinx.conf'...
indexing index 'test1'...
collected 4 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 4 docs, 193 bytes
total 0.006 sec, 30791 bytes/sec, 638.16 docs/sec
indexing index 'test1stemmed'...
collected 4 docs, 0.0 MB
sorted 0.0 Mhits, 100.0% done
total 4 docs, 193 bytes
total 0.001 sec, 99382 bytes/sec, 2059.73 docs/sec
skipping non-plain index 'dist1'...
skipping non-plain index 'rt'...
total 8 reads, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg
total 24 writes, 0.000 sec, 0.1 kb/call avg, 0.0 msec/call avg

Fase 5:Sfinge iniziale

Inoltre, configura il tuo server Sphinx per l'avvio automatico all'avvio del sistema. Usa il comando seguente per impostare START su sì.

sudo sed -i 's/START=no/START=yes/g' /etc/default/sphinxsearch

Ora avvia anche il servizio per la prima volta e verifica lo stato.

service sphinxsearch start
service sphinxsearch status

Puoi anche configurare l'indicizzatore nel tuo crontab per eseguirlo a intervalli regolari. Il crontab sottostante verrà eseguito ogni ora.

0 * * * * /usr/bin/indexer --rotate --all

Fase 6 – Lavorare con Sfinge

Eseguiamo alcune query sul tuo server Sphinx. Prima di tutto connettiti al server MySQL di Sphinx usando il comando seguente.

mysql -h0 -P9306

Ora esegui uno per uno il comando di seguito e guarda le modifiche. Questo è solo per il tuo apprendimento.

mysql> SELECT * FROM test1 WHERE MATCH('document');
mysql> INSERT INTO rt VALUES (1, 'adding', 'sample text here', 11);
mysql> INSERT INTO rt VALUES (2, 'adding some more', 'sample text here', 22);
mysql> SELECT gid/11 FROM rt WHERE MATCH('sample') GROUP BY gid;
mysql> SELECT * FROM rt ORDER BY gid DESC;
mysql> SELECT *, WEIGHT() FROM test1 WHERE MATCH('"document one"/1');
mysql> SHOW META;
mysql> SET profiling=1;
mysql> SELECT * FROM test1 WHERE id IN (1,2,4);
mysql> SHOW PROFILE;
mysql> SELECT id, id%3 idd FROM test1 WHERE MATCH('this is | nothing') GROUP BY idd;
mysql> SHOW PROFILE;
mysql> SELECT id FROM test1 WHERE MATCH('is this a good plan?');
mysql> SHOW PLAN;
mysql> SELECT COUNT(*) FROM test1;
mysql> CALL KEYWORDS ('one two three', 'test1');
mysql> CALL KEYWORDS ('one two three', 'test1', 1);
mysql> SHOW TABLES;

Ubuntu
  1. Come installare e configurare Redis su Ubuntu 18.04

  2. Come installare e configurare Redmine su Ubuntu 18.04

  3. Come installare e configurare Samba su Ubuntu 18.04

  4. Come installare e configurare Redis su Ubuntu 20.04

  5. Come installare e configurare Jenkins su Ubuntu 20.04

Come installare e configurare Neo4j su Ubuntu 20.04

Come installare e configurare Ubuntu SDK in Ubuntu 16.04 e 14.04

Come installare e configurare PostgreSQL su Ubuntu

Come installare e configurare Hadoop su Ubuntu 20.04

Come installare e configurare Jenkins su Ubuntu

Come installare e configurare Jenkins in Ubuntu 20.04