Здравствуйте, у меня возникла проблема с Sphinx. При попытке запустить sphinx с помощью команды:
sudo service sphinxsearch restart
Выдавало ошибку:
Job for sphinxsearch.service failed because the control process exited with error code. See "systemctl status sphinxsearch.service" and "journalctl -xe" for details.
sphinx.config###########
# Sources #
###########
# Шаблон источника, что бы не прописывать постоянные параметры (сфинкс поддерживает наследование в параметрах)
source parent {
type = mysql
sql_host = localhost
sql_user = root
sql_pass = root
sql_db = xenosdb
sql_port = 3306
sql_query_pre = SET NAMES utf8
sql_query_pre = SET CHARACTER SET utf8
sql_attr_uint = model_name # По этому параметру будем определять таблицу
}
# Таблица резюме
source resume:parent {
sql_query = SELECT id, title, salary, experience, description, working_experience FROM resume
}
# Таблица вакансий
source vacancy:parent {
sql_query = SELECT id, title, salary, responsibilities, offer, experience, description FROM vacancy
}
###########
# Indexes #
###########
# Индекс резюме и заодно шаблон настройки других индексов
index resume_index {
source = resume
path = /var/lib/sphinxsearch/data/resume_index
docinfo = extern
morphology = stem_enru # Использование английского и русского стемминга
min_word_len = 2 # Минимальная длина индексируемого слова
# charset_type = utf-8 # Установка используемой кодировки
charset_table = 0..9, A..Z->a..z, _, a..z, \
U+410..U+42F->U+430..U+44F, U+430..U+44F
min_infix_len = 2 # Минимальная длина инфикса (префикс в том числе)
# enable_star = 1 # Использовать оператор усечения "*" (http://www.sphinxsearch.com/docs/manual-0.9.8.html#conf-enable-star)
}
# Индекс вакансий
index vacancy_index:resume_index {
source = vacancy
path = /var/lib/sphinxsearch/data/vacancy_index
}
Далее логи:
journalctl -xe
Nov 19 13:39:31 machine1 sudo[25399]: pam_unix(sudo:session): session opened for user roo
Nov 19 13:39:31 machine1 systemd[1]: Starting LSB: Fast standalone full-text SQL search e
-- Subject: Unit sphinxsearch.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit sphinxsearch.service has begun starting up.
Nov 19 13:39:31 machine1 sphinxsearch[25430]: Starting sphinxsearch: [Mon Nov 19 13:39:31
Nov 19 13:39:31 machine1 sphinxsearch[25430]: [Mon Nov 19 13:39:31.583 2018] [25433] FATA
Nov 19 13:39:31 machine1 sphinxsearch[25430]: Sphinx 2.2.9-id64-release (rel22-r5006)
Nov 19 13:39:31 machine1 sphinxsearch[25430]: Copyright (c) 2001-2015, Andrew Aksyonoff
Nov 19 13:39:31 machine1 sphinxsearch[25430]: Copyright (c) 2008-2015, Sphinx Technologie
Nov 19 13:39:31 machine1 systemd[1]: sphinxsearch.service: Control process exited, code=e
Nov 19 13:39:31 machine1 sudo[25399]: pam_unix(sudo:session): session closed for user roo
Nov 19 13:39:31 machine1 systemd[1]: Failed to start LSB: Fast standalone full-text SQL s
-- Subject: Unit sphinxsearch.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit sphinxsearch.service has failed.
--
-- The result is failed.
Nov 19 13:39:31 machine1 systemd[1]: sphinxsearch.service: Unit entered failed state.
Nov 19 13:39:31 machine1 systemd[1]: sphinxsearch.service: Failed with result 'exit-code'
lines 2523-2546/2546 (END)
Nov 19 13:39:31 machine1 sudo[25399]: pam_unix(sudo:session): session opened for user root by vagra
Nov 19 13:39:31 machine1 systemd[1]: Starting LSB: Fast standalone full-text SQL search engine...
-- Subject: Unit sphinxsearch.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit sphinxsearch.service has begun starting up.
Nov 19 13:39:31 machine1 sphinxsearch[25430]: Starting sphinxsearch: [Mon Nov 19 13:39:31.583 2018]
Nov 19 13:39:31 machine1 sphinxsearch[25430]: [Mon Nov 19 13:39:31.583 2018] [25433] FATAL: 'search
Nov 19 13:39:31 machine1 sphinxsearch[25430]: Sphinx 2.2.9-id64-release (rel22-r5006)
Nov 19 13:39:31 machine1 sphinxsearch[25430]: Copyright (c) 2001-2015, Andrew Aksyonoff
Nov 19 13:39:31 machine1 sphinxsearch[25430]: Copyright (c) 2008-2015, Sphinx Technologies Inc (htt
Nov 19 13:39:31 machine1 systemd[1]: sphinxsearch.service: Control process exited, code=exited stat
Nov 19 13:39:31 machine1 sudo[25399]: pam_unix(sudo:session): session closed for user root
Nov 19 13:39:31 machine1 systemd[1]: Failed to start LSB: Fast standalone full-text SQL search engi
-- Subject: Unit sphinxsearch.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit sphinxsearch.service has failed.
--
-- The result is failed.
Nov 19 13:39:31 machine1 systemd[1]: sphinxsearch.service: Unit entered failed state.
Nov 19 13:39:31 machine1 systemd[1]: sphinxsearch.service: Failed with result 'exit-code'.
~
~
lines 2523-2546/2546 (END)
Nov 19 13:39:31 machine1 sudo[25399]: pam_unix(sudo:session): session opened for user root by vagrant(ui
Nov 19 13:39:31 machine1 systemd[1]: Starting LSB: Fast standalone full-text SQL search engine...
-- Subject: Unit sphinxsearch.service has begun start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit sphinxsearch.service has begun starting up.
Nov 19 13:39:31 machine1 sphinxsearch[25430]: Starting sphinxsearch: [Mon Nov 19 13:39:31.583 2018] [254
Nov 19 13:39:31 machine1 sphinxsearch[25430]: [Mon Nov 19 13:39:31.583 2018] [25433] FATAL: 'searchd' co
Nov 19 13:39:31 machine1 sphinxsearch[25430]: Sphinx 2.2.9-id64-release (rel22-r5006)
Nov 19 13:39:31 machine1 sphinxsearch[25430]: Copyright (c) 2001-2015, Andrew Aksyonoff
Nov 19 13:39:31 machine1 sphinxsearch[25430]: Copyright (c) 2008-2015, Sphinx Technologies Inc (http://s
Nov 19 13:39:31 machine1 systemd[1]: sphinxsearch.service: Control process exited, code=exited status=1
Nov 19 13:39:31 machine1 sudo[25399]: pam_unix(sudo:session): session closed for user root
Nov 19 13:39:31 machine1 systemd[1]: Failed to start LSB: Fast standalone full-text SQL search engine.
-- Subject: Unit sphinxsearch.service has failed
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
--
-- Unit sphinxsearch.service has failed.
--
-- The result is failed.
Nov 19 13:39:31 machine1 systemd[1]: sphinxsearch.service: Unit entered failed state.
Nov 19 13:39:31 machine1 systemd[1]: sphinxsearch.service: Failed with result 'exit-code'.
systemctl status sphinxsearch.service
sphinxsearch.service - LSB: Fast standalone full-text SQL search engine
Loaded: loaded (/etc/init.d/sphinxsearch; bad; vendor preset: enabled)
Active: failed (Result: exit-code) since Mon 2018-11-19 13:42:04 UTC; 4min 13s ago
Docs: man:systemd-sysv-generator(8)
Process: 25388 ExecStop=/etc/init.d/sphinxsearch stop (code=exited, status=0/SUCCESS)
Process: 25735 ExecStart=/etc/init.d/sphinxsearch start (code=exited, status=1/FAILURE)
Nov 19 13:42:04 machine1 systemd[1]: Starting LSB: Fast standalone full-text SQL search engine...
Nov 19 13:42:04 machine1 sphinxsearch[25735]: Starting sphinxsearch: [Mon Nov 19 13:42:04.969 2018] [25738] using config file '/etc/sphinxsearch/sphinx.conf'...
Nov 19 13:42:04 machine1 sphinxsearch[25735]: [Mon Nov 19 13:42:04.970 2018] [25738] FATAL: 'searchd' config section not found in '/etc/sphinxsearch/sphinx.conf'
Nov 19 13:42:04 machine1 sphinxsearch[25735]: Sphinx 2.2.9-id64-release (rel22-r5006)
Nov 19 13:42:04 machine1 sphinxsearch[25735]: Copyright (c) 2001-2015, Andrew Aksyonoff
Nov 19 13:42:04 machine1 sphinxsearch[25735]: Copyright (c) 2008-2015, Sphinx Technologies Inc (http://sphinxsearch.com)
Nov 19 13:42:04 machine1 systemd[1]: sphinxsearch.service: Control process exited, code=exited status=1
Nov 19 13:42:04 machine1 systemd[1]: Failed to start LSB: Fast standalone full-text SQL search engine.
Nov 19 13:42:04 machine1 systemd[1]: sphinxsearch.service: Unit entered failed state.
Nov 19 13:42:04 machine1 systemd[1]: sphinxsearch.service: Failed with result 'exit-code'.
Также код, который взаимодействовал со Sphinx(на Yii2)config/main.php'sphinx' => [
'class' => 'yii\sphinx\Connection',
'dsn' => 'mysql:host=127.0.0.1;port=9306;dbname=yii2advanced',
'username' => '%username%',
'password' => '%password%',
],
Непосредственно, сам метод, отвечающий за выдачу данных через Sphinxpublic function advancedSearch($keyword)
{
$sql = "SELECT * FROM resume_index WHERE MATCH('$keyword')";
$data = Yii::$app->sphinx->createCommand($sql)->queryAll();
echo '<pre>';
print_r($data);
echo '</pre>';die;
}