# Deploying CrateDB on balena.io

**URL:** <https://community.cratedb.com/t/deploying-cratedb-on-balena-io/1067>\
**Category:** Tutorials\
**Tags:** integration, architecture\
**Created:** [March 29, 2022, 9:07am UTC](https://community.cratedb.com/t/deploying-cratedb-on-balena-io/1067 "2022-03-29T09:07:49Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Marija](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/marija/32/428_2.png) [@Marija](https://community.cratedb.com/u/Marija)\
**Post date:** [March 29, 2022, 9:07am UTC](https://community.cratedb.com/t/deploying-cratedb-on-balena-io/1067/1 "2022-03-29T09:07:50Z")

</div>

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](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](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:

- BalenaCloud account: please sign up [here](https://dashboard.balena-cloud.com/)
- [BalenaEtcher](https://www.balena.io/etcher/)

## Deploy the code

There are two ways to deploy the code to a balenaCloud application: via [Balena Deploy](https://www.balena.io/docs/learn/deploy/deploy-with-balena-button/) and via [Balena CLI](https://www.balena.io/docs/reference/balena-cli/).

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

[![deploy-with-balena](https://us1.discourse-cdn.com/flex020/uploads/crate/original/1X/aea351a7522cd74ffa5739b602868f77eadb77c3.png)](https://dashboard.balena-cloud.com/deploy?repoUrl=https://github.com/mpous/crate-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](http://balena.io).

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

1. Click → `Create Fleet`

2. Open Fleet and Click → `Add device`

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](https://github.com/mpous/crate-balena) 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!

 ![balenaCloud](https://us1.discourse-cdn.com/flex020/uploads/crate/original/1X/8093d77b578e5847bc6927e33f277426dee90941.png "balenaCloud")

## 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:

 ![6bafe805-d24b-4da3-b138-b7d85a67fea7](https://us1.discourse-cdn.com/flex020/uploads/crate/original/1X/a1707d53a3dc2858b9aa5ffc3023786c3d48ee1a.png)

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](https://crate.io/docs/crate/crash/en/0.27/getting-started.html). 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:

 ![Screenshot 2022-03-29 at 11.05.37](https://us1.discourse-cdn.com/flex020/uploads/crate/original/1X/08b793f31ed21a49509dc3182cc1795e8b190474.jpeg)

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

---

<div class="post-metadata">

**Author:** ![mpous](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/mpous/32/548_2.png) [@mpous](https://community.cratedb.com/u/mpous)\
**Post date:** [March 29, 2022, 10:08am UTC](https://community.cratedb.com/t/deploying-cratedb-on-balena-io/1067/4 "2022-03-29T10:08:16Z")

</div>

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

[![deploy-with-balena](https://us1.discourse-cdn.com/flex020/uploads/crate/original/1X/aea351a7522cd74ffa5739b602868f77eadb77c3.png)](https://dashboard.balena-cloud.com/deploy?repoUrl=https://github.com/mpous/crate-balena)

or this link: [balena dashboard](https://dashboard.balena-cloud.com/deploy?repoUrl=https://github.com/mpous/crate-balena)

---

<div class="post-metadata">

**Author:** ![Marija](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/marija/32/428_2.png) [@Marija](https://community.cratedb.com/u/Marija)\
**Post date:** [March 29, 2022, 10:49am UTC](https://community.cratedb.com/t/deploying-cratedb-on-balena-io/1067/6 "2022-03-29T10:49:45Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![netliteIT](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/netliteit/32/723_2.png) [@netliteIT](https://community.cratedb.com/u/netliteIT)\
**Post date:** [November 6, 2022, 3:48pm UTC](https://community.cratedb.com/t/deploying-cratedb-on-balena-io/1067/12 "2022-11-06T15:48:04Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![proddata](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/proddata/32/1379_2.png) [@proddata](https://community.cratedb.com/u/proddata)\
**Post date:** [November 7, 2022, 12:43pm UTC](https://community.cratedb.com/t/deploying-cratedb-on-balena-io/1067/13 "2022-11-07T12:43:16Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![netliteIT](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/netliteit/32/723_2.png) [@netliteIT](https://community.cratedb.com/u/netliteIT)\
**Post date:** [November 7, 2022, 1:25pm UTC](https://community.cratedb.com/t/deploying-cratedb-on-balena-io/1067/14 "2022-11-07T13:25:00Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Marija](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/marija/32/428_2.png) [@Marija](https://community.cratedb.com/u/Marija)\
**Post date:** [November 8, 2022, 3:26pm UTC](https://community.cratedb.com/t/deploying-cratedb-on-balena-io/1067/15 "2022-11-08T15:26:37Z")

</div>

Hello,

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

Marija

---

<div class="post-metadata">

**Author:** ![hernanc](https://sea2.discourse-cdn.com/flex020/user_avatar/community.cratedb.com/hernanc/32/676_2.png) [@hernanc](https://community.cratedb.com/u/hernanc)\
**Post date:** [November 25, 2022, 2:20pm UTC](https://community.cratedb.com/t/deploying-cratedb-on-balena-io/1067/16 "2022-11-25T14:20:54Z")

</div>

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.
