Deploying CrateDB on balena.io

Balena is a complete set of tools for building, deploying and managing fleets of connected IoT devices. Balena provides infrastructure for fleet owners so they can focus on developing their applications and growing their fleets with as little friction as possible.

The tools are designed to work well together as a platform, but the user can also pick and choose the components you need for your project, and adapt them to your particular use case. In this short tutorial, we will show how you can integrate CrateDB as a component to http://balena.io and run it on an ARM device such as Raspberry Pi 4 or x86 generic 64 bits device.

Requirements

To deploy CrateDB on http://balena.io and run it on IoT device you would need the following:

Hardware:

  • Raspberry Pi 4 or other ARM/x86 device
  • SD card
  • Power supply and WiFi

Software:

Deploy the code

There are two ways to deploy the code to a balenaCloud application: via Balena Deploy and via Balena CLI.

To use Balena Deploy just click on the deploy button below:

deploy-with-balena

In this tutorial, we will show how to deploy CrateDB with Balena CLI. If you want to learn more please check the balena website http://balena.io.

Follow the next steps to create a new application and add a device:

  1. Click β†’ Create Fleet

    • Put any name for your application
    • Set Device type β†’ Raspberry Pi 4
    • Set Application type β†’ Starter
    • Click β†’ Create new fleet
  2. Open Fleet and Click β†’ Add device

    • Set Device type β†’ Raspberry Pi 4
    • Select the recommended version
    • Set edition β†’ Development (recommended for first time users)
    • Set Network Connection: Wifi+Ethernet
      • Set your Wifi SSID
      • Set your Wifi Password

Now, you can deploy the code to your device with the following steps:

  1. Login to balenaCloud account via CLI command: balena login

  2. Clone this GitHub repository to your local workspace

  3. Deploy the code to your device with: balena push <application-name>

Now your device is getting updated on balenaCloud and you are set up to run CrateDB on your Raspberry Pi!

Running CrateDB on Raspberry Pi

In balenaCloud click on your device, open HostOS Terminal and type:

sysctl -w vm.max_map_count=212144

This command increments max_map_count which is the maximum number of memory map areas a process may have of your container. It’s by default 65536 as most of the applications need less than a thousand maps.

At this point, on the balenaCloud Logs component running CrateDB starts correctly. To start using CrateDB, in the Terminal window choose cratedb and then > Start terminal session:

At this point, we recommend installing Crash CLI to start working with CrateDB. The installation instructions on how to install Crash can be found here. To start Crash, use the following command:

./crash

Add --verbose in case you want to know more, or you get a connection error.

Access to the Admin UI

Alternatively, you might want to access CrateDB Admin UI. Typing "http://localhost:4200" in your browser opens the Admin UI:

Now, you are ready to explore CrateDB! Check our other tutorials for a successful start :slight_smile:

3 Likes

@Marija to deploy crate on balena just click on the deploy with balena button from below:

deploy-with-balena

or this link: balena dashboard

2 Likes

Thank you Marc, the tutorial is updated to also include balena deploy button :slight_smile:

1 Like

Hi Maria.
I would like to make reboot consistent.
How to set sysctl -w vm.max_map_count=212144 automatically?

This must be updated in the /etc/sysctl.conf to set it permanently. To verify you can run sysctl vm.max_map_count after the reboot.

In a standard environment that’s the way.
Unfortunately in Balena OS sysctl.conf and sysctl.d/ are readonly and I wasn’t able to set vm.max_map_count from container even tuning docker-compose.

Hello,

I would suggest you raise the question on https://forums.balena.io/. A similar tutorial has been published at Running crate database on balena - Show and Tell - balenaForums.

Marija

Hi,
in situations where you cannot configure vm.max_map_count you have the option of editing the Docker Compose YAML file adding -Cnode.store.allow_mmap=false , to disable memory mapping but please note this could have a performance impact.