Install Redis on Windows system

Redis Reference Documentation: Redis Command Reference

Install Redis on Windows system:

The best of course is to install Redis on an independent Linux computer, but if it is just for testing and learning, on a Windows computer, first use VMware or Docker to create a Linux system (I like to use Ubuntu server), and then install Redis Server is a better choice.

Option 1, directly install Win version of Redis, not recommended, because it is a ported version and has not been updated for a long time.

Option 4, running the Redis image directly in Docker is not recommended, because it is troublesome to restore the redis.conf configuration file.

I personally recommend Docker-Ubuntu-Redis (option 3), because creating a virtual machine with VMware (option 2) feels time-consuming.

Xshell is recommended by others. If there are many Linux computers, it feels very convenient. You can remotely operate all other computers (or virtual machines) on one computer.


Option 1: Direct installation (not recommended, the project is not maintained)

  • Download: Redis does not officially support Windows systems, and can only use the version transplanted by Microsoft's open source department: GitHub
  • Installation: Click Next all the way
  • Run: Enter the path where Redis is installed, and then execute redis-server.exe redis.windows.conf
  • Connection: Redis, like MySQL and MongoDB, provides clients to connect. Enter the command redis-cli (provided that the Redis installation path has been added to the environment variable), and you can connect to the Redis server. (For details, please refer to: Using Redis on Win )

Option 2: Use VMware to install Redis in ubuntu (server version)

(It takes a long time to download and install Ubuntu)

  • Environment: Install VMware, download and create ubuntu-server virtual machine ( Ubuntu Releases )
  • Installation: sudo apt-get install redis-server (default self-start after installation)
  • 卸载:sudo apt-get purge --auto-remove redis-server
  • View status: ps aux|grep redis
  • Start: sudo service redis-server start
  • Stop: sudo service redis-server stop
  • Update software source information: apt update
  • Install vim and Redis: apt install vim redis-server
  • View the local IP: ifconfig
  • Modify the Redis configuration to allow remote access to the local Redis: vim /etc/redis/redis.config
  • (Add the local IP in the bind item)
  • Client connection: redis-cli -h [IP address] -p [port number] (default port number: 6379)

  Optional: operate the system on Xshell

  • Install the SSH server: apt install -y openssh-server (the -y parameter means that in the command line interaction, directly enter yes)
  • Modify the SSH configuration to allow remote root login: vim /etc/ssh/sshd_config (change the value of PermitRootLogin from prohibit-password to yes, and uncomment)
  • Start the SSH service: service start ssh
  • Close the SSH service: service stop ssh
  • Check the SSH startup status: service ssh status
  • Set boot self-starting SSH: systemctl enable ssh
  • Disable SSH at boot: systemctl disable ssh
  • Set the cover to not sleep (notebook): vim /etc/systemd/logind.conf (change to HandleLidSwitch: ignore, restart)
  • Set account password: passwd
  • Install and open the new session window of Xshell, fill in the information on the two pages of "Connection" and "User Authentication" (the host is the previous local IP address, the port number is 22 by default, the user name is root, and the password is the one set above specified account password)
  • Click to connect

Option 3: Use Docker to install Redis in ubuntu (mirror version)

(Personally the most recommended way)

  • Install Docker and download the ubuntu image: docker pull ubuntu
  • Create a container: docker run -itd --name myUbuntu -p 50001:22 redis:latest
  • (While creating the container, bind port 50001 of Dokcer to port 22 of the container; the container will start by default after creation)
  • Start the container: docker start myUbuntu
  • Enter the container and start the shell: docker exec -it myUbuntu /bin/bash
  • Update software source information: apt update
  • Install the vim editing tool: apt install redis-server vim
  • Modify the Redis configuration to allow remote access to the local Redis: vim /etc/redis/redis.config
  • (Add the local IP in the bind item)
  • Client connection: redis-cli -h [IP address] -p [port number]

Optional: operate this system on Xshell (slightly different from option 2)

  • Install the SSH server: apt install -y openssh-server (the -y parameter means that in the command line interaction, directly enter yes)
  • Modify the SSH configuration to allow remote root login: vim /etc/ssh/sshd_config (change the value of PermitRootLogin from prohibit-password to yes, and uncomment)
  • Start the SSH service: service start ssh
  • Close the SSH service: service stop ssh
  • Check the SSH startup status: service ssh status
  • Set boot self-starting SSH: systemctl enable ssh
  • Disable SSH at boot: systemctl disable ssh
  • Set account password: passwd
  • Check the IP information in the command line under the Windows system: ipconfig (record the IPv4 address here)
  • Install and open the new session window of Xshell, fill in the information on the two pages of "Connection" and "User Authentication" (the host is the previous IPv4 address, the default port number is 50001, the user name is root, and the password is set before account password)
  • Click the link, there is a WARNING in the login information (others are normal login information)
  • In the properties, remove the check mark of X11 transfer.
  • If you connect again, there will be no WARNING (if there are other error prompts, they should be minor problems, just click Baidu)

Option 4: Install the Redis image directly in the Docker container

(The main thing is to restore the Redis configuration file, which is a bit troublesome)

  • Install Docker and download the Redis image: docker pull redis
  • Create a container: docker run -itd --name myRedis -p 50001:22 redis:latest
  • (While creating the container, bind port 50001 of Dokcer to port 22 of the container; the container will start by default after creation)
  • Start the container: docker start myRedis
  • Enter the container and start the shell: docker exec -it myRedis /bin/bash
  • Update software source information: apt update
  • Install the vim editing tool: apt install vim
  • The container made by Redis image does not have redis.config (Redis configuration file) by default. See: Restoring the Redis configuration file
  • Modify the Redis configuration to allow remote access to the local Redis: vim /etc/redis/redis.config
  • (Add the local IP in the bind item)
  • Client connection: redis-cli -h [IP address] -p [port number]

Optional: operate the system on Xshell (same as option 3)


Add some Docker execution parameter analysis:

-i: run the container in interactive mode (usually used with -t);

-t: Reassign a pseudo-input to the container (usually used with -i);

-d: Run the container in the background and return the container ID;

-p: port mapping, the format is: host port: container port

--ip: Specify a fixed IP for the container

--net: Specify the network mode for the container

--name: specify a name for the container

--privileged=true: The root in the container has real root privileges

--appendonly yes: enable data persistence


<end>

Guess you like

Origin blog.csdn.net/weixin_58695100/article/details/122989350