Saturday, 21 February 2015

Elasticsearch on Raspberry Pi

Raspberry PI is obviously a great little machine for hardware hacking and leaning about computing. But I'm increasingly finding that its versatility makes it really useful for serious development.

Being able to quickly rebuild from scratch when it comes to testing configuration options for enterprise architectures like elasticsearch clusters is particularly powerful.

Elasticsearch runs surprisingly well on Raspberry Pis. Obviously you don't get lightning performance (at least not from B/B+s, I haven't yet tried with Pi 2s) but for testing index mappings, with small amounts of data the lack of speed doesn't matter.

Here is my method for setting up an elasticsearch node on a Pi. To make a cluster, just add more Pis.

1. Download the latest Minibian image and burn it to an SD card. You'll need a big card, ideally 32GB.

2. Boot the Pi, login and modify the disk partitioning.
fdisk /dev/mmcblk0
delete partition 2, then make a new one approx 2GB (4000000 sectors). Reboot.

3. Resize the new partition:
rsize2fs /dev/mmcblk0p2
4. Now create a partition using the remianing free space on the SD card for the elasticsearch data:
fdisk /dev/mmcblk0
5. Reboot so that new partition is available, then create an exxt4 filesystem
mkfs.ext4 /dev/mmcblk0p3
6. Create a directory to use as a mount point, and then add working directories inside it:
mkdir /elasticsearch
mkdir /elasticsearch/work
mkdir /elasticsearch/data
mkdir /elasticsearch/plugins
mkdir /elasticsearc/logs
7. Edit the /etc/fstab file so that the new partition is mounted automatically. Reboot again and check that the disk layout is what you'd expect.
df -h
8. Now do a software and firmware update:
apt-get update
apt-get install rpi-update
rpi-update
apt-get upgrade
9. One final reboot!

10. Download and install the latest version of elasticsearch
wget http://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-1.4.4.deb
dpkg -i elasticsearch-1.4.4.deb
11. Now edit the elasticsearch config (/etc/elasticsearch.yml)  file to add a node name and make sure the paths for the work, data, plugins and logs reflect the /elasticsearch directories your cerated in step 6.

12. Now start elasticsearch
/usr/share/elasticsearch/bin/elasticsearch --config=/etc/elasticsearch.yml


3 comments:

  1. weeeeeeeeeeell, you have to edit the VM size.
    That's in /etc/elasticsearch/jvm.options. I have it 512m

    ReplyDelete
  2. Is it possible to run elastic with
    512mb RAM on Raspbean Jessie???

    ReplyDelete