How to Install and Configure Sphinx on Ubuntu 16.04
To Install and Configure Sphinx on Ubuntu 16.04
Sphinx is a simple, relevance and open source full-text search server. It is written in C++ programming language and works with Linux and other popular operating systems. It is so simple to install and also configure Sphinx, and at the end of this tutorial, you will be accustomed to the method to install and configure Sphinx on Ubuntu 16.04.
Install Sphinx
First, make sure you install it by using the apt-get package manager on your Ubuntu system.
root@linuxhelp:~# add-apt-repository ppa:builds/sphinxsearch-rel22
Fast standalone full-text SQL search engine Sphinx is a standalone full text search engine, meant to provide fast, size-efficient and relevant fulltext search functions to other applications. Sphinx was specially designed to integrate well with SQL databases and scripting languages. Currently built-in data sources support fetching data either via direct connection to MySQL or PostgreSQL, or using XML pipe mechanism (a pipe to indexer in special XML-based format which Sphinx recognizes).
The ' rel22' repo contains the builds from current release branch (2.2.x), which updated only with bugfixes (minor number), or with major releases. It
.
.
gpg: keyring `/tmp/tmp8o6l_qpx/secring.gpg' created
gpg: keyring `/tmp/tmp8o6l_qpx/pubring.gpg' created
gpg: requesting key 16932B16 from hkp server keyserver.ubuntu.com
gpg: /tmp/tmp8o6l_qpx/trustdb.gpg: trustdb created
gpg: key 16932B16: public key " Launchpad PPA for Sphinxsearch builds team" imported
gpg: Total number processed: 1
gpg: imported: 1 (RSA: 1)
And once it is done, make sure you update the repositories by making use of the following command.
root@linuxhelp:~# apt-get update
Hit:1 http://security.ubuntu.com/ubuntu xenial-security InRelease
Hit:2 http://in.archive.ubuntu.com/ubuntu xenial InRelease
Hit:3 http://in.archive.ubuntu.com/ubuntu xenial-updates InRelease
Get:4 http://ppa.launchpad.net/builds/sphinxsearch-rel22/ubuntu xenial InRelease [17.6 kB]
Hit:5 http://in.archive.ubuntu.com/ubuntu xenial-backports InRelease
Get:6 http://ppa.launchpad.net/builds/sphinxsearch-rel22/ubuntu xenial/main amd64 Packages [792 B]
Get:7 http://ppa.launchpad.net/builds/sphinxsearch-rel22/ubuntu xenial/main i386 Packages [796 B]
Get:8 http://ppa.launchpad.net/builds/sphinxsearch-rel22/ubuntu xenial/main Translation-en [628 B]
Fetched 19.8 kB in 1s (10.0 kB/s)
Reading package lists... Done
Now, you shall proceed with the installation of Sphinxsearch by making use of the following command.
root@linuxhelp:~# apt-get install sphinxsearch
Reading package lists... Done
Building dependency tree
Reading state information... Done
The following additional packages will be installed:
libmysqlclient20 libodbc1 mysql-common
Suggested packages:
.
.
Do not forget to reindex all indexes by running: indexer --all
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...
Once it is done, make sure you install Mariadb Database by making use of the following command.
root@linuxhelp:~# apt install mariadb*
Reading package lists... Done
Building dependency tree
Reading state information... Done
Note, selecting ' mariadb-test' for glob ' mariadb*'
Note, selecting ' mariadb-test-data-10.0' for glob ' mariadb*'
Note, selecting ' mariadb-test-data' for glob ' mariadb*'
Note, selecting ' mariadb-test-5.5' for glob ' mariadb*'
Note, selecting ' mariadb-common' for glob ' mariadb*'
Note, selecting ' mariadb-plugin-connect' for glob ' mariadb*'
Note, selecting ' mariadb-server-core-5.5' for glob ' mariadb*'
Note, selecting ' mariadb-server-5.5' for glob ' mariadb*'
Note, selecting ' mariadb-tokudb-engine-5.5' for glob ' mariadb*'
.
.
Setting up mariadb-test (10.0.33-0ubuntu0.16.04.1) ...
Setting up odbcinst1debian2:amd64 (2.3.1-4.1) ...
Setting up unixodbc (2.3.1-4.1) ...
Setting up mariadb-plugin-connect (10.0.33-0ubuntu0.16.04.1) ...
Setting up odbcinst (2.3.1-4.1) ...
Processing triggers for libc-bin (2.23-0ubuntu3) ...
Processing triggers for ureadahead (0.100.0-19) ...
Processing triggers for systemd (229-4ubuntu4) ...
Let’ s import the sample SQL file into the database. First, create a database named test in your MySQL server, after that restore the database provided by the sphinx search package.
root@linuxhelp:~# mysqladmin -u root -p create test
Enter password:
mysql -u root -p test < /usr/share/doc/sphinxsearch/example-conf/example.sql
Enter password:
Configure Sphinx
We are through with the installation, so now we shall proceed with the sphinx configuration and edit for the MySQL connection configuration as shown below.
root@linuxhelp:~# nano /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
Once it is done, you need to run the indexer to create the full-text index from your data. You can execute this action by making use of the following command.
root@linuxhelp:~# 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' ...
ERROR: index ' test1' : sql_connect: Can' t connect to MySQL server on ' linuxhelp' (111) (DSN=mysql://root:***@linuxhelp:3306/test).
total 0 docs, 0 bytes
total 0.001 sec, 0 bytes/sec, 0.00 docs/sec
indexing index ' test1stemmed' ...
ERROR: index ' test1stemmed' : sql_connect: Can' t connect to MySQL server on ' linuxhelp' (111) (DSN=mysql://root:***@linuxhelp:3306/test).
total 0 docs, 0 bytes
total 0.000 sec, 0 bytes/sec, 0.00 docs/sec
skipping non-plain index ' dist1' ...
skipping non-plain index ' rt' ...
total 0 reads, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
total 0 writes, 0.000 sec, 0.0 kb/call avg, 0.0 msec/call avg
Once it is done, you need to configure your Sphinx server to autostart on system boot. So, run the following command to complete that action.
root@linuxhelp:~# sed -i ' s/START=no/START=yes/g' /etc/default/sphinxsearch
Now, you need to start service for the first time and check the status.
root@linuxhelp:~# service sphinxsearch start
root@linuxhelp:~# service sphinxsearch status
● sphinxsearch.service - SphinxSearch Search Engine
Loaded: loaded (/lib/systemd/system/sphinxsearch.service disabled vendor preset: enabled)
Active: active (running) since Fri 2018-02-09 17:39:23 IST 6s ago
Process: 13298 ExecStart=/usr/bin/searchd --config /etc/sphinxsearch/sphinx.conf (code=exited
Process: 13294 ExecStartPre=/bin/chown sphinxsearch.sphinxsearch /var/run/sphinxsearch (code=
Process: 13291 ExecStartPre=/bin/mkdir -p /var/run/sphinxsearch (code=exited, status=0/SUCCES
Main PID: 13302 (searchd)
Tasks: 8 (limit: 512)
CGroup: /system.slice/sphinxsearch.service
├─13301 /usr/bin/searchd --config /etc/sphinxsearch/sphinx.conf
└─13302 /usr/bin/searchd --config /etc/sphinxsearch/sphinx.conf
Once it is done you need to execute some queries on your Sphinx server.
root@linuxhelp:~# mysql -h0 -P9306
Welcome to the MariaDB monitor. Commands end with or g.
Your MySQL connection id is 1
Server version: 2.2.11-id64-release (95ae9a6)
Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.
With this, this tutorial on installing and configuring sphinx server on Ubuntu 16.04 comes to an end.
Comments ( 0 )
No comments available