Tech Blog

Running Redis on Windows 10 – Part I of III

Redis on Windows 10

Windows Subsystem for Linux (WSL)

Ever since Jessica Deen explained how WSL works at my SVDevOps Meetup, I’ve recommended Windows 10 users run Redis on their own dev machines. Yes, you heard right. Starting with Windows 10 (v1709 – 2017-09, Fall Creators Update), you can run at least a half-dozen flavors of Linux on the Windows Subsystem for Linux (WSL), and you can run Redis on top of them. No VM required. No Docker. No joke!

How do I know if I have Windows 10 with WSL?

To answer the question “Which version of Windows is my PC is running?” press your Windows logo key + R, type “winver,” then select OK. Starting with version 10, you’ve got a command called “wslconfig.” It lists distros you have and controls which one starts by typing “bash.” Try it out!

How to set up WSL!

  1. To enable Windows Subsystem for Linux, follow the instructions on Microsoft Docs. The short version is: In Windows 10, Microsoft replaces Command Prompt with PowerShell as the default shell. Open PowerShell as Administrator and run this command to enable Windows Subsystem for Linux (WSL):
    Enable-WindowsOptionalFeature -Online -FeatureName Microsoft-Windows-Subsystem-Linux
  2. Reboot Windows after making the change—note that you only need to do this one time.
  3. Download and install one of the supported Linux distros from the Microsoft Store.

Install and Test Redis

  1. Launch the installed distro from your Windows Store and then install redis-server. The following example works with Ubuntu (you’ll need to wait for initialization and create a login upon first use):

    > sudo apt-get update
    > sudo apt-get upgrade
    > sudo apt-get install redis-server
    > redis-cli -v
    
  2. Restart the Redis server to make sure it is running:
    > sudo service redis-server restart
    
  3. Execute a simple Redis command to verify your Redis server is running and available:
    $ redis-cli 
    127.0.0.1:6379> set user:1 "Jane"
    127.0.0.1:6379> get user:1
    "Jane"
    
  4. To stop your Redis server:
    > sudo service redis-server stop

Further Information

  • How does Linux run within Windows 10? Instead of calling the Linux Kernel, the system calls (syscalls) that these unmodified Linux libraries use are redirected to Windows, which handles the call instead of Linux. For more information about WSL, visit the Windows Subsystem for Linux Documentation on MSDN.
  • How do I access files stored in the Linux environment? If you want to edit Windows files in Windows AND in Linux, then keep your files in /mnt/c/ so you can edit them with either OS. Don’t use Windows to “reach into the Linux file system.” As Scott Hanselman says on his WSL blog post, “There be dragons!” For further information about the WSL storage, visit Jack Hammon’s blog post on MSDN titled “WSL File System Support.”

 

Dave Nielsen

Dave Nielsen

As Head of Ecosystem Programs, Dave engages with emerging technologies and open source projects like Microservices, Serverless & Kubernetes to bring the magic of Redis to the broader developer community. Dave has extensive ecosystem experience from his years of engagement in the web, cloud and big data communities. Prior to Redis Labs, Dave led the relationship between Intel’s Deep Learning in Apache Spark project and public cloud providers; and at PayPal where he helped pioneer web api developer evangelism. Dave is also co-founder of CloudCamp and several Silicon Valley user groups.

More posts by Dave