A Raspberry Pi 4 with Elasticsearch

For the purposes of this post I’m going to be installing ElasticSearch 7.17.3 on a Raspberry Pi 4 with 4GB RAM running Ubuntu Server. Based on Lucene, Elasticsearch has become a common and successful document/search indexing platform. A number of applications have been built around ElasticSearch like Kibana. I’ve used Elastic on large high-end clusters for deployments and its heftiness made me wonder if it’d work in any way on a test Raspberry Pi instance. Installing on an x86 architecture, where the performance of the machine is good, is not a real challenge. Elastic did however advise in a blog that they’ve now included ARM builds, but not support for Elastic 7.x.

Raspberry Pi 4

To start I’m assuming you’re running Ubuntu Server 20.04+. Installing via Docker is possible and that is an alternative. In this case I’m installing the ElasticSearch binaries. I use the ubuntu (sudo) user to install Java JRE and create several directories for the elastic data and the elastic binary to live in.

# install java JRE
> sudo apt-get install default-jre

# create directories (optional)
> mkdir -p ~/data/elastic
> mkdir ~/elastic
> cd ~/elastic

# download the elasticsearch 7 binary
> wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-7.17.3-linux-x86_64.tar.gz
# decompress
> tar -xvf elasticsearch-7.17.3-linux-x86_64.tar.gz

We can now start to configure Elasticsearch. As this is a development server I’m running on the Pi I’m going to disable the usage of XPack ML and I’ve not enabled Security.

# we need to increase the vm.max_map_count
> sudo vi /etc/sysctl.conf
# add the line
# save and refresh the sysctl
> sudo sysctl -p

Lets check where our Java Runtimes are, they should be in /usr/lib/jvm:

ubuntu@raspberrypi:~$ ls -1 /usr/lib/jvm

We need to note this location. In this case I use: /usr/lib/jvm/java-17-openjdk-arm64 but you can use default-java. We need to set the global system variable for ES_JAVA_HOME so that it uses the Java ARM build.


We can setup the ES_JAVA_HOME by creating a profile.d file: e.g. /etc/profile.d/elastic.sh

# place this within it

To refresh the changes we need to source the profile with the command:

> source /etc/profile

The next stage is the actually configure the ElasticSearch node via the /config/elasticsearch.yml. These are my own configurations, however you may want to have further configuration. We need to disable the ml plugin due to memory requirements.

cluster.name: pi_cluster
node.name: my_node_name
path.data: /home/ubuntu/data/elastic
path.logs: /home/ubuntu/logs/elastic
# network host depends on usage either internally or externally exposing - in the below I use a loopback for all interfaces to have access
discovery.seed_hosts: ["my_node_name"]
xpack.ml.enabled: false

You should now be reading to run your instance – note that I’ve not added any other Pis to the cluster (of one).

# execute or run elasticsearch
> ./bin/elasticsearch

Once ElasticSearch has initialised you can visit your cluster via your browser to determine if the service is running and available for use. You should see something like this:

  "name": "my_node_name",
  "cluster_name": "pi_cluster",
  "cluster_uuid": "p54_DFHjdsad8726jU",
  "version": {
    "number": "7.17.3",
    "build_flavor": "default",
    "build_type": "tar",
    "build_hash": "5ad023604c8d7416c9eb6c0eadb62b14e766caff",
    "build_date": "2022-04-19T08:11:19.070913226Z",
    "build_snapshot": false,
    "lucene_version": "8.11.1",
    "minimum_wire_compatibility_version": "6.8.0",
    "minimum_index_compatibility_version": "6.0.0-beta1"
  "tagline": "You Know, for Search"

Congratulations! You’ve now got an ElasticSearch server running on a Pi. Happy coding. If you’re using Python, I can highly recommend the ElasticSearch client library for interacting with your Elastic instance. The next stage would be to add multiple Pis to your cluster if so inclined.