Install Redis on WSL

Raymond Raymond event 2021-02-01 visibility 7,906
more_vert

Redis (Remote Dictionary Server) is one of the most popular key-value in-memory NoSQL databases. It is also commonly used in containers.

Prerequisites

Before installing Redis server on WSL, please ensure you have WSL enabled on your Windows 10 system. 

Follow Install Windows Subsystem for Linux on a Non-System Drive to install WSL on a non-C drive. 

This tutorial provides steps to install Redis on WSL Debian distro. You can follow similar steps to install it in other Linux distros. 

Step by step guide

  1. Open Debian distro through WSL command:
    wsl -d Debian
  2. Update Debian packages:
    sudo apt update

    You need to type user password.

  3. Install Redis using the following command:
    sudo apt install redis-server

    Type Y to continue when asked.

  4. Wait until the installation is completed. 
  5. Verify SQLite version:
    $ redis-server --version
    Redis server v=3.2.6 sha=00000000:0 malloc=jemalloc-3.6.0 bits=64 build=a2cab475abc2115e

Test Redis server

  1. Start redis server using the following command:
    sudo service redis-server start
    # or
    sudo /etc/init.d/redis-server start
  2. Check the status of the server
    sudo service redis-server status
    # or
    sudo /etc/init.d/redis-server status
    The command prints out the following text:
    [....] redis-server is running
  3. Alternatively, we can use redis-cli to ping:
    redis-cli ping
    PONG

    The command prints out PONG when the service is running.

  4. Use redis-cli:
    $ redis-cli
    127.0.0.1:6379> set mykey somevalue
    OK
    127.0.0.1:6379> get mykey
    "somevalue"
    127.0.0.1:6379>

    The above commands set a key named mykey with value as somevalue; and then the value is retrieved via get command.

  5. Type quit to quite redis CLI.
  6. Run the following command to stop Redis server:
    sudo /etc/init.d/redis-server stop
    # or
    sudo service redis-server stop
More from Kontext
comment Comments
No comments yet.

Please log in or register to comment.

account_circle Log in person_add Register

Log in with external accounts