Redis Installation

Raspberry Pi (Raspbian)

Raspberry Pi

Installation

We demonstrate how to install Redis on Raspbian, a Debian-based distribution running on the Raspberry Pi. These steps will be generally applicable for any Debian-based Linux distribution. Here are the steps:

  1. Install Raspbian on a Raspberry Pi (RPi). Follow my Beginner's Guide to Installing Node.js on a Raspberry Pi if you don't already have a working RPi. The guide will help you build a solid, maintainable RPi platform while saving you time, regardless of whether you complete the final step and install Node.js.

  2. Log into the RPi through Remote Desktop or other means.

  3. Update the local RPi APT package repository to get the latest list of available packages from the central Debian repositories.

     $ sudo apt update
    
  4. Install the latest updates for packages already on your machine.

     $ sudo apt full-upgrade
    
  5. Install Redis from the Debian APT repository. (The current version in Raspbian was 3.2.6 at time of this writing)

     $ sudo apt install redis-server
    

    Note

    The redis-server package also installs the redis-tools package as a dependency which includes the redis-cli program that we will use extensively in the next steps.

    That's it!

    if you want a version of Redis that is more recent than the version stored in the Debian repositories, you can build from source as described in the Redis documentation here or review the detailed Raspberry Pi notes here. I recommend that you save yourself potential headaches and simply install using apt as described above unless you absolutely need the very latest bits.

Testing the Installation

  1. Launch the redis-cli (command-line interface) so we can issue some tests. We'll start with the PING command.

     $ redis-cli ping
    

    You should receive a PONG in return:

     $ redis-cli ping
     PONG
     $
    
  2. Verify that we can create key/value pairs using the SET command:

     $ redis-cli set key1 hello
    

    This creates a key called key1 and sets it to a value of "hello".

  3. Retrieve the key just created using the GET command:

     $ redis-cli get key1
     "hello"
     $
    

    You should see a value of "hello" as shown above.

  4. Reboot the server to see Redis persistence in action (optional).

    To convince yourself that Redis data persists to disk and not just in RAM, you could reboot your system and then run the following command again to verify that key1 still holds a value of "hello":

     $ redis-cli get key1
     "hello"
     $
    

    Sure enough, Redis values persist through reboot!

See also

results matching ""

    No results matching ""