Elasticsearch: Difference between revisions
No edit summary |
|||
| Line 1: | Line 1: | ||
=Server Configuration= | |||
Edit /etc/elasticsearch/elasticsearch.yml to listen to the outside address | |||
network.host: <outside IP address> | |||
For automatic start/stop I created /etc/init.d/elasticsearch like | |||
<syntaxhighlight lang=bash> | |||
#!/bin/sh | |||
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing. | |||
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then | |||
set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script | |||
fi | |||
### BEGIN INIT INFO | |||
# Provides: elasticsearch | |||
# Required-Start: $remote_fs $syslog | |||
# Required-Stop: $remote_fs $syslog | |||
# Default-Start: 2 3 4 5 | |||
# Default-Stop: 0 1 6 | |||
# Short-Description: Start ElastichSearch deamon | |||
# Description: Start ElastichSearch deamon | |||
# This script starts a | |||
# single forking daemon capable of writing a pid | |||
# file. | |||
### END INIT INFO | |||
# Author: Hans de Ridder <hans@deridder.it> | |||
# | |||
if [ `id -nu` != 'elasticsearch' ] | |||
then | |||
su elasticsearch $0 $* | |||
exit | |||
fi | |||
DESC="ElasticSearch engine" | |||
DAEMON="/opt/elasticsearch/bin/elasticsearch" | |||
DAEMON_ARGS="-d" | |||
</syntaxhighlight> | |||
Now you can start by <code>service elasticsearch start</code>. Stopping is not implemented in this script. | |||
In /etc/rc5.d do <code>ln -s ../init.d/elasticsearch S02elasticsearch</code> | |||
=Troubleshooting= | |||
;curl <nowiki>http://localhost:9200/_aliases?pretty=true</nowiki> | |||
:List the indexes in elasticsearch | |||
;curl -XDELETE <nowiki>http://localhost:9200/<indexname>*/</nowiki> | |||
:Remove all indexes where name starts with <indexname> | |||
==Some endpoints on http://<server>:9200== | |||
;/ | |||
:Version information | |||
;/_alliases | |||
:All available indices | |||
;/<indexname> | |||
=Problem= | =Problem= | ||
I needed a newer version of Elasticsearch [https://www.elastic.co/] after an upgrade to mediawiki 1.43 and bluntly followed the instructions for that. It appeared I upgraded the software from version 6.8. to 8.17 and that is not supported. Consequently it refused to start. In the logs it report: | I needed a newer version of Elasticsearch [https://www.elastic.co/] after an upgrade to mediawiki 1.43 and bluntly followed the instructions for that. It appeared I upgraded the software from version 6.8. to 8.17 and that is not supported. Consequently it refused to start. In the logs it report: | ||
| Line 41: | Line 99: | ||
Now elasticsearch start with a number of error messages, the search continues. | Now elasticsearch start with a number of error messages, the search continues. | ||
Revision as of 14:53, 2 June 2025
Server Configuration
Edit /etc/elasticsearch/elasticsearch.yml to listen to the outside address
network.host: <outside IP address>
For automatic start/stop I created /etc/init.d/elasticsearch like
#!/bin/sh
# kFreeBSD do not accept scripts as interpreters, using #!/bin/sh and sourcing.
if [ true != "$INIT_D_SCRIPT_SOURCED" ] ; then
set "$0" "$@"; INIT_D_SCRIPT_SOURCED=true . /lib/init/init-d-script
fi
### BEGIN INIT INFO
# Provides: elasticsearch
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Start ElastichSearch deamon
# Description: Start ElastichSearch deamon
# This script starts a
# single forking daemon capable of writing a pid
# file.
### END INIT INFO
# Author: Hans de Ridder <hans@deridder.it>
#
if [ `id -nu` != 'elasticsearch' ]
then
su elasticsearch $0 $*
exit
fi
DESC="ElasticSearch engine"
DAEMON="/opt/elasticsearch/bin/elasticsearch"
DAEMON_ARGS="-d"
Now you can start by service elasticsearch start. Stopping is not implemented in this script.
In /etc/rc5.d do ln -s ../init.d/elasticsearch S02elasticsearch
Troubleshooting
- curl http://localhost:9200/_aliases?pretty=true
- List the indexes in elasticsearch
- curl -XDELETE http://localhost:9200/<indexname>*/
- Remove all indexes where name starts with <indexname>
Some endpoints on http://<server>:9200
- /
- Version information
- /_alliases
- All available indices
- /<indexname>
Problem
I needed a newer version of Elasticsearch [1] after an upgrade to mediawiki 1.43 and bluntly followed the instructions for that. It appeared I upgraded the software from version 6.8. to 8.17 and that is not supported. Consequently it refused to start. In the logs it report:
Caused by: org.elasticsearch.gateway.CorruptStateException: Format version is not supported. Upgrading to \[8.17.1\] is only supported from version \[7.17.0\].
Results from duckduckgo[2] told me downgrading is not possible. That may be true from a running version, mine has never run on v8, I managed to downgrade to v7 like this.
Configure apt to have the 7.x repository
cd /etc/apt/sources.list.d echo deb [signed-by=/usr/share/keyrings/elasticsearch-keyring.gpg] https://artifacts.elastic.co/packages/7.x/apt stable main > elastic-7.x.list apt install elasticsearch=7.17.26
This puts the software back, starting is not possible due to configuration issues. Restore /etc/elasticsearch from a backup.
Still no luck the logfile has:
[ERROR][o.e.b.Bootstrap ] [elast] node validation exception [1] bootstrap checks failed. You must address the points described in the following [1] lines before starting Elasticsearch. bootstrap check failure [1] of [1]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
In /etc/elasticsearch/elasticsearch.yml I added
cluster.initial_master_nodes: ["IP of my node"]
Note that I run a single elasticsearch server only I guess this would work for other configuration too but did not test that
Now it starts.
Make sure to have the v8 repository in /etc/apt/sources.list.d and an upgrade to that is possible:
apt update apt full-upgrade
Unfortunately now it again does not start as:
java.lang.IllegalStateException: Cannot start this node because it holds metadata for indices with version [6.8.23] with which this node of version [8.17.1] is incompatible. Revert this node to version [7.17.27] and delete any indices with versions earlier than [7.0.0] before upgrading to version [8.17.1]. If all such indices have already been deleted, revert this node to version [7.17.27] and wait for it to join the cluster to clean up any older indices from its metadata.
As mediawiki Cirrussearch[3] is working I decided to stay on v7 for now.
Fixing it
Trying to clear the entire database for a fresh start after the upgrade to version 8
- Remove everytrhing under /var/lib/elasticsearch
- In /etc/elasticsearch/elasticsearch.yml add
_aliases?pretty=true
Now elasticsearch start with a number of error messages, the search continues.