Running Redis on Windows 10
Running Redis on Windows 10
Let's take a look at how to run Redis on Windows 10 and how to set up WSL and install and test Redis.
Join the DZone community and get the full member experience.Join For Free
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 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
- 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
- Reboot Windows after making the change-note that you only need to do this one time.
- Download and install one of the supported Linux distros from the Microsoft Store.
Install and Test Redis
- 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
- Restart the Redis server to make sure it is running:
> sudo service redis-server restart
- 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"
- To stop your Redis server:
> sudo service redis-server stop
- 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."
Published at DZone with permission of Dave Nielsen , DZone MVB. See the original article here.
Opinions expressed by DZone contributors are their own.