Jan 5, 2018, 4:19:53 PM1/5/18
to MIT App Inventor Forum

This howto is written to help those who may wish to run their own local redis server to run
cloudDB operations on AI2. This may assist with any privacy or data protection concerns
surrounding use of MIT based redis servers, or simplify matters if running an app
which only needs the local network.

You will need a Linux Server for this, the example uses Debian (Windows binaries are available)

This setup is for a local server, therefore SSL is not required
and the default ports are used, 6379 / 16379 these are blocked
on the router firewall

The Linux server has sudo running and my user has sudo access
in order to be able to run all commands requiring root permissions

Login into your server

$: sudo apt-get update
: sudo apt-get upgrade

You may need to install the gcc compiler:

$: sudo apt-get install build-essential

$: wget http://download.redis.io/redis-stable.tar.gz
: tar xvzf redis-stable.tar.gz
: cd redis-stable
: make

Check build has been successful

$: make test
(This will take some time, so coffee break unless you want to see all the "OK's" go by....

Copy the executable to your PATH

$: sudo cp src/redis-server /usr/local/bin/
: sudo cp src/redis-cli /usr/local/bin/

or instead use

$: sudo make install

You should now be able to test the redis server:

$: redis-server

CTRL+C to close that instance

Now we need to setup redis properly:
(note the use of the port number in filenames)

Create the following three directories:

$: sudo mkdir /etc/redis
: sudo mkdir /var/redis
: sudo mkdir /var/redis/6379

Copy the init script from install folder:

$:sudo cp redis-stable/utils/redis_init_script /etc/init.d/redis_6379

Copy the conf file from the install folder:

$:sudo cp /redis-stable/redis.conf /etc/redis/6379.conf

Now set configuration options:

$: sudo nano /etc/redis/6379.conf

It is quite a long file and can be difficult to find things.
read through the file to get an idea of what might be needed.
I used the following settings:

#bind                    # << !important to comment out allow other devices access
protected-mode no                  # << we are using a password
6379                          # << default
0                          # << default
daemonize yes                      
# << means redis will start up with server in background
no                      # << default
/var/run/redis_6379.pid    # << default
loglevel notice                    
# << default
/var/log/redis_6379.log    # << the usual place for logs
120 1                         # << persistence settings
90 10                         # << will save after 90 secs if up to 10 keys have changed
60 100
/var/redis/6379                # << !important
requirepass mydifficultpassword    
# << added security

Save the conf file and open the init script:

$: sudo nano /etc/init.d/redis_6379

If you are not using the default port of 6379 you need to change the
value of $REDISPORT

Also, to make life a bit easier find the line:


and add "-a mydifficultpassword" so it looks like this

$CLIEXEC -p $REDISPORT -a mydifficultpassword shutdown

(This allows you to stop the script at the server, having set a password)

Save the init script. Now:

$: sudo update-rc.d redis_6379 defaults

ready to start:

$: sudo /etc/init.d/redis_6379 start

You should be back at a prompt with redis server running. Now for some testing.
We can use the built in redis-cli tool for this. Start this up as follows:

$: redis-cli -a mydifficultpassword

This should give you a new prompt:>


You should get back: PONG

Now add and retrieve a key value:

set mykey somevalue

get mykey


Find all the keys:

keys "*"

1) "mykey"

If you do this after setting some data with appinventor the response will be (for example):

1) "test:mykey"

AI2 uses the ProjectID and the tag name together

Finally delete the key you created:

del mykey


You should be back at the normal command prompt. Now to setup appInventor!
Let us assume you have a project open and that you have added a cloudDB component
Selecting the cloudDB component on the right should show you the default settings.
You need to change these to match your redis-server.

Project ID
This can be whatever you want, it is used to form part of any key or tag you create.
Or just leave as "test"

RedisPort << use which ever port number you set, if not the default

RedisServer  << the computer/server name recognised on the network or the IP address
myserver  or

Token   << use the password you used for requirepass in redis_6379.conf

Setup some components and blocks to test the connectivity.

Away you go :)

Plenty of help and support at the Redis Website

Abraham Getzler

Jan 6, 2018, 9:15:26 PM1/6/18
to MIT App Inventor Forum
Reply all
Reply to author
0 new messages