# Running crate database on balena

**URL:** <https://forums.balena.io/t/running-crate-database-on-balena/355360>\
**Category:** Show and Tell\
**Created:** [March 29, 2022, 11:15am UTC](https://forums.balena.io/t/running-crate-database-on-balena/355360 "2022-03-29T11:15:45Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mpous](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mpous/32/4742_2.png) [@mpous](https://forums.balena.io/u/mpous)\
**Post date:** [March 29, 2022, 11:15am UTC](https://forums.balena.io/t/running-crate-database-on-balena/355360/1 "2022-03-29T11:15:45Z")

</div>

On this message I would like to share that with Marija from Crate we built a Crate Database instance running on balena.

[CrateDB](https://crate.io) is an open-source database that makes storage and analysis of massive amounts of data simple and efficient. It can handle various data types, from time-series, geospatial, structured, and semi-structured data. Combining SQL and NoSQL features, CrateDB offers a high degree of scalability and availability, SQL compatible interface, and easy integration. Furthermore, CrateDB supports dynamic schemas, queryable objects, and real-time full-text search over millions of documents in just a few seconds. These capabilities make CrateDB a perfect choice for many data-intensive analytics applications.

`DISCLAIMER`: This is a test to demonstrate that CrateDB can run on balena. We are looking for developers from the community who would like to run applications on balena + crateDB.

## Getting started

### Hardware

- Raspberry Pi 4 (only tested on this device)
- SD card
- Power supply and Ethernet cable (if you don’t use WiFi)

### Software

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

### Deploy CrateDB on your fleet

The easiest way to deploy a CrateDB instance on a balena device is clicking on the button below 👇👇👇

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

Follow instructions, click Add a Device and flash an SD card with that OS image dowloaded from balenaCloud. Enjoy the magic 🌟Over-The-Air​:glowing\_star:!

Find here the [github repo](https://github.com/mpous/crate-balena) with the source code.

On balenaCloud click `Add Device` and follow the steps to download an image. Flash a SD card to flash the balenaOS image to your device and see how the crateDB service gets deployed on your device’s fleet.

### Run crateDB instance on the Raspberry Pi

#### Change the max\_map\_count

Once the CrateDB service is deployed on your device, you might see an error on the Logs and the service restarting. Open the `HostOS` ssh 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.

Once the instraction is submitted, the CrateDB service might start properly.

#### Access to the CrateDB UI

Copy your local IP address and paste it into your browser with the port 4200 and that might open the CrateDB UI.

#### Install crash CLI

If you need a CLI to interact with the Crate database instance you will need to install `crash`. To install crash open the `cratedb` Terminal and type:

`curl -o crash https://cdn.crate.io/downloads/releases/crash_standalone_latest`

`chmod +x crash`

`./crash`

### Questions? Comments?

Feel free to add your comments here. And if you build a new project using CrateDB and balena let us know 🙂

---

<div class="post-metadata">

**Author:** ![netliteIT](https://avatars.discourse-cdn.com/v4/letter/n/fbc32d/32.png) [@netliteIT](https://forums.balena.io/u/netliteIT)\
**Post date:** [November 6, 2022, 4:24pm UTC](https://forums.balena.io/t/running-crate-database-on-balena/355360/2 "2022-11-06T16:24:59Z")

</div>

Hi.  
What about make `sysctl -w vm.max_map_count=212144` call persistent to reboots?  
Andrea

---

<div class="post-metadata">

**Author:** ![mpous](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mpous/32/4742_2.png) [@mpous](https://forums.balena.io/u/mpous)\
**Post date:** [November 7, 2022, 9:37am UTC](https://forums.balena.io/t/running-crate-database-on-balena/355360/3 "2022-11-07T09:37:02Z")

</div>

@netliteIT welcome to the balena community!

Let me ask to the balenaOS team how to do the `vm.max_map_count` persistent to reboots.

Let me know if you have done any experiment and the results 🙂

---

<div class="post-metadata">

**Author:** ![netliteIT](https://avatars.discourse-cdn.com/v4/letter/n/fbc32d/32.png) [@netliteIT](https://forums.balena.io/u/netliteIT)\
**Post date:** [November 8, 2022, 3:51pm UTC](https://forums.balena.io/t/running-crate-database-on-balena/355360/4 "2022-11-08T15:51:28Z")

</div>

Yes I did tests using every documented container config voice with no result.  
Other sysctls are easily made writable, network for example.

---

<div class="post-metadata">

**Author:** ![mpous](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/mpous/32/4742_2.png) [@mpous](https://forums.balena.io/u/mpous)\
**Post date:** [November 8, 2022, 3:57pm UTC](https://forums.balena.io/t/running-crate-database-on-balena/355360/5 "2022-11-08T15:57:11Z")

</div>

@netliteIT did you try to uncomment these 2 lines? [crate-balena/docker-compose.yml at 3e1bf2ca0ad9e425ddd93d9f8df45c83f656f4c5 · mpous/crate-balena · GitHub](https://github.com/mpous/crate-balena/blob/3e1bf2ca0ad9e425ddd93d9f8df45c83f656f4c5/docker-compose.yml#L23) reading this documentation from docker, it might work → [Compose file version 2 reference | Docker Documentation](https://docs.docker.com/compose/compose-file/compose-file-v2/#sysctls)

---

<div class="post-metadata">

**Author:** ![netliteIT](https://avatars.discourse-cdn.com/v4/letter/n/fbc32d/32.png) [@netliteIT](https://forums.balena.io/u/netliteIT)\
**Post date:** [November 12, 2022, 8:51pm UTC](https://forums.balena.io/t/running-crate-database-on-balena/355360/6 "2022-11-12T20:51:07Z")

</div>

Yes tried.  
Doesn’t work.

---

<div class="post-metadata">

**Author:** ![specter456](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@specter456](https://forums.balena.io/u/specter456)\
**Post date:** [September 14, 2024, 8:00am UTC](https://forums.balena.io/t/running-crate-database-on-balena/355360/7 "2024-09-14T08:00:21Z")

</div>

Hello,  
any updates here?  
How to make te value change persistent to reboots?

---

<div class="post-metadata">

**Author:** ![phil-d-wilson](https://sea2.discourse-cdn.com/balena/user_avatar/forums.balena.io/phil-d-wilson/32/3730_2.png) [@phil-d-wilson](https://forums.balena.io/u/phil-d-wilson)\
**Post date:** [September 14, 2024, 8:37am UTC](https://forums.balena.io/t/running-crate-database-on-balena/355360/8 "2024-09-14T08:37:00Z")

</div>

Hey @specter456

You could replace the docker-compose to reference a dockerfile and in there bring in the crate image, run the sysctl command and then call crate itself.

---

<div class="post-metadata">

**Author:** ![specter456](https://avatars.discourse-cdn.com/v4/letter/s/a88e4f/32.png) [@specter456](https://forums.balena.io/u/specter456)\
**Post date:** [September 30, 2024, 7:47pm UTC](https://forums.balena.io/t/running-crate-database-on-balena/355360/9 "2024-09-30T19:47:27Z")

</div>

I was only referring to the problem mentioned with the sysctl -w vm.max\_map\_count=212144 command. For me, the error occurs with the docker image of sonarqube. What exactly do I have to do here to be able to solve the problem sustainably/persistently?
