ArangoDB 3.12 Product Release Announcement! Read the blog for details. Read Blog

Vector-5

ArangoDB on Raspberry PI

Estimated reading time: 3 minutes

During the ArangoDB Hackathon weekend, we tried to compile ArangoDB on a Raspberry PI using Raspbian as operating system.

ArangoDB needs some external libraries in order to compile

  • libev
  • ICU
  • V8
  • zlib

Libev, ICU and zlib compiled without problems. Raspbian comes with a precompiled version of V8 – but it’s too old for ArangoDB. So, we had to compile V8 ourself. A single make run takes hours and hours to complete. Using the default parameters it complains about wrong flags for the hard-float ABI. After some googling and endless hours of waiting for the compile to complete, we found a set of flags that finally worked.

  • you need to pass the options -march=armv6 to the compiler and linker
  • you need to disable CAN_USE_VFP3_INSTRUCTIONS
  • use -O2 instead of -O3 (I’m not sure if this is necessary or not)

If you downloaded ArangoDB 1.3, use the following diff to patch the Google V8 Makesystem

index 3a59639..7bb9cab 100644
--- a/3rdParty/V8/build/common.gypi
+++ b/3rdParty/V8/build/common.gypi
@@ -146,6 +146,14 @@
               'CAN_USE_ARMV7_INSTRUCTIONS=1',
             ],
           }],
+          ['armv7==0', {
+            'target_conditions': [
+              ['_toolset=="target"', {
+                'cflags': ['-march=armv6',],
+                'ldflags': ['-march=armv6',],
+              }],
+            ],
+          }],
           [ 'v8_can_use_unaligned_accesses=="true"', {
             'defines': [
               'CAN_USE_UNALIGNED_ACCESSES=1',
@@ -167,7 +175,7 @@
           [ 'v8_can_use_vfp3_instructions=="true" or arm_neon==1 or \
              arm_fpu=="vfpv3" or arm_fpu=="vfpv3-d16"', {
             'defines': [
-              'CAN_USE_VFP3_INSTRUCTIONS',
+              # 'CAN_USE_VFP3_INSTRUCTIONS',
             ],
           }],
           [ 'v8_use_arm_eabi_hardfloat=="true"', {
@@ -414,13 +422,13 @@
           ['OS=="linux" or OS=="freebsd" or OS=="openbsd" or OS=="netbsd" \
             or OS=="android"', {
             'cflags!': [
-              '-O2',
+              '-O3',
               '-Os',
             ],
             'cflags': [
               '-fdata-sections',
               '-ffunction-sections',
-              '-O3',
+              '-O2',
             ],
             'conditions': [
               [ 'gcc_version==44 and clang==0', {

Switch into the 3rdParty/V8 directory and execute

GYP_DEFINES="armv7=0" make library=static strictaliasing=off snapshot=off werror=no hardfp=on arm.release

This will produce the libraries and the shell example. Try the shell to verify that everything worked

pi@raspberrypi ~/ArangoDB/3rdParty/V8 $ ./out/arm.release/shell 
V8 version 3.16.14.1 [sample shell]
>

The ArangoDB Makefile does not know about ARM, so we need to fake it. Go into the out directory and execute

pi@raspberrypi ~/ArangoDB/3rdParty/V8 $ cd out
pi@raspberrypi ~/ArangoDB/3rdParty/V8/out $ ln -s arm.release ia32.release

There is one open problem in some versions: atomic compare and swap. It is currently not used in the production code of 1.3 AFAIK, so I’ve commented it out. Here’s the patch to do this (UPDATE: if you are using latest 1.3, 1.4, or devel branches, there is no need to apply this patch).

https://gist.github.com/jsteemann/6403543.

Now we are ready to compile:

pi@raspberrypi ~/ArangoDB $ touch .v8-build-32 
pi@raspberrypi ~/ArangoDB $ ./configure --enable-all-in-one-icu --enable-all-in-one-v8 CPPFLAGS="-DUSE_EABI_HARDFLOAT -march=armv6 -mfloat-abi=hard"
pi@raspberrypi ~/ArangoDB $ make

This produced executables. Start the server

pi@raspberrypi ~/ArangoDB $ mkdir /tmp/testbase
pi@raspberrypi ~/ArangoDB $ ./bin/arangod -c etc/relative/arangod.conf /tmp/testbase
2013-07-29T09:41:42Z [28103] INFO ArangoDB 1.3.1 -- ICU 49.1.2, V8 version 3.16.14.1, SSL engine OpenSSL 1.0.1e 11 Feb 2013
2013-07-29T09:41:42Z [28103] INFO using default language 'en'
2013-07-29T09:41:42Z [28103] INFO using endpoint 'tcp://localhost:8529' for http non-encrypted requests
2013-07-29T09:41:42Z [28103] INFO JavaScript using startup './js', modules './js/server/modules;./js/common/modules;./js/node', packages './js/npm', actions './js/actions', application './js/apps'
2013-07-29T09:41:53Z [28103] INFO Authentication is turned off
2013-07-29T09:41:54Z [28103] INFO ArangoDB (version 1.3.1) is ready for business. Have fun!

Next start the shell

pi@raspberrypi ~/ArangoDB $ ./bin/arangosh -c etc/relative/arangosh.conf 
Please specify a password: 

                                       _     
  __ _ _ __ __ _ _ __   __ _  ___  ___| |__  
 / _` | '__/ _` | '_ \ / _` |/ _ \/ __| '_ \ 
| (_| | | | (_| | | | | (_| | (_) \__ \ | | |
 \__,_|_|  \__,_|_| |_|\__, |\___/|___/_| |_|
                       |___/                 

Welcome to arangosh 1.3.1. Copyright (c) triAGENS GmbH
Using Google V8 3.16.14 JavaScript engine, READLINE 6.2, ICU 49.1.2

Connected to ArangoDB 'tcp://127.0.0.1:8529' version 1.3.1

------------------------------------- Help -------------------------------------
Predefined objects:                                                 
  arango:                                ArangoConnection           
  db:                                    ArangoDatabase             
Example:                                                            
 > db._collections();                    list all collections       
 > db.<coll_name>.all().toArray();       list all documents         
 > id = db.<coll_name>.save({ ... });    save a document            
 > db.<coll_name>.remove(<_id>);         delete a document          
 > db.<coll_name>.document(<_id>);       get a document             
 > db.<coll_name>.replace(<_id>, {...}); overwrite a document       
 > db.<coll_name>.update(<_id>, {...});  partially update a document
 > help                                  show help pages            
 > exit                                                             
Note: collection names may be cached in arangosh. To refresh them, issue: 
 > db._collections();

And enjoy! I’ve not done many tests, actually only one: save and restore documents. So, I’ve no idea how stable it is.

Picture of Frank Celler
September 01, 2013 ,

Frank is both entrepreneur and backend developer, developing mostly memory databases for two decades. He is the CTO and co-founder of ArangoDB. Try to challenge Frank asking him questions on C, C++ and MRuby. Besides Frank organizes Cologne’s NoSQL group & is an active member of NoSQL community.

Leave a Comment