Skip to main content

How to Install Elasticsearch on CentOS 8

Ready for faster more powerful WordPress search?

sudo dnf install java-11-openjdk-devel
java -version
openjdk version "11.0.5" 2019-10-15 LTS
OpenJDK Runtime Environment 18.9 (build 11.0.5+10-LTS)
OpenJDK 64-Bit Server VM 18.9 (build 11.0.5+10-LTS, mixed mode, sharing)
sudo rpm --import https://artifacts.elastic.co/GPG-KEY-elasticsearch
sudo nano /etc/yum.repos.d/elasticsearch.repo
[elasticsearch]
name=Elasticsearch repository for 7.x packages
baseurl=https://artifacts.elastic.co/packages/7.x/yum
gpgcheck=1
gpgkey=https://artifacts.elastic.co/GPG-KEY-elasticsearch
enabled=0
autorefresh=1
type=rpm-md

(optional) enable=1

sudo dnf install --enablerepo=elasticsearch elasticsearch
dnf update
systemctl daemon-reload
sudo systemctl start elasticsearch.service

If elasticsearch service does not start, check the logs at /var/log/elasticsearch/elasticsearch.log.
Also see Troubleshooting section below. Otherwise reboot your webserver.

sudo systemctl enable elasticsearch.service

Memory Usage Settings

/etc/elasticsearch/jvm.options

https://www.elastic.co/guide/en/elasticsearch/reference/7.11/important-settings.html#heap-size-settings

Troubleshoot

If elasticsearch service does not start, check the logs at /var/log/elasticsearch/elasticsearch.log.

When using No Exec /tmp dir:

Error like this or access denied:

unable to load JNA native support library, native methods will be disabled
  1. Go to /etc/sysconfig/elasticsearch
  2. Add ES_JAVA_OPTS="-Djna.tmpdir=/var/lib/elasticsearch/tmp".(For newer Elasticsearch, use Djava.io.tmpdir instead of Djna.tmpdir)
  3. Start Elasticsearch using systemctl start elasticsearch or service start elasticsearch.
  4. You can see now tmp folder created inside /var/lib/elasticsearch/.
  5. This folder should have execute permission for elasticsearch user
  6. Check the permission with name i -l /var/lib/elasticsearch

If you had an old ElasticSearch sitting around:

Error:

Failed to obtain node lock, is the following location writable

If you had an old ElasticSearch sitting around like I did, you can start by either trying to delete a specific node.lock file or go nuclear and rm -rf the nodes folder.

ElasticPress plugin for WordPress

Elasticsearch Host URL: http://127.0.0.1:9200

Geef een reactie

Je e-mailadres wordt niet gepubliceerd. Vereiste velden zijn gemarkeerd met *