1. Description
Most enterprises deploy projects based on Linux servers, and Redis does not officially provide a Windows version of the installation package. Therefore, in the course, we will install Redis based on the Linux system.
The Linux version selected here is CentOS 7.
Redis official website address: http://download.redis.io/releases
Two, download
mkdir redis
cd redis
wget http://download.redis.io/releases/redis-6.2.9.tar.gz
3. Installation
tar -zxvf redis-6.2.9.tar.gz
cd redis-6.2.9/
yum -y install gcc
gcc -v
make
make install
4. Start
redis-server
or
redis-server &
Note: If it is installed on the server, you must remember to open port 6379 in the security group.
At this time, check the redis process, as shown below, indicating that it has started successfully:
ps -ef|grep redis
If the remote connection is wrong, then:
first enter the redis.conf file under the conf directory under redis on the server;
the first step is to edit the redis.conf file in vim mode and set the value of protected-mode to no;
the second step is to find Bind 127.0.0.1 item, add # in front of it to comment out, if there is no # in front of bind, you don’t need to worry about it.
If it still doesn’t work after the above steps, you can try to turn off the firewall on your virtual machine or server
5. Close
Violent shutdown, easy to lose data
ps -ef|grep redis查看pid
kill -9 pid
normal shutdown
redis-cli shutdown
client remote login
redis-cli -h 192.168.220.100 -p 6379 -a "redis"
6. Use of redis client
redis-cli: It is the redis built-in client, and the redis client program can be started by using the command redis-cli.
redis-cli: connect to the redis service on port 6379 of 127.0.0.1 (local machine) by default.
redis-cli -p port number: connect to the redis service on the specified port of 127.0.0.1 (this machine).
redis-cli -h ip address -p port: connect to the redis service on the specified port on the specified ip host.
redis-cli
exit client
exit
or
quit
7. Graphical desktop client
Official website download: https://redisdesktop.com/download
github address: https://github.com/uglide/RedisDesktopManager/releases
Baidu Netdisk: http://pan.baidu.com/s/1kU8sY3P
File name: redis-desktop-manager-0.8.8.384.exe
auth Fill in the redis password
8. If the connection fails
vi redis.conf
Comment out the binding ip
# bind 127.0.0.1
Redis does not run as a daemon by default. It can be modified through this configuration item. Use yes to enable the daemon and set it to no
daemonize no
Protected mode, close the protected mode, otherwise the external ip cannot connect
protected-mode no
After the above settings are completed, enter the redis/bin directory, restart redis, command
redis-server
Start the springboot project, still report an error, and still can't connect using Redis Desktop Manager.
After searching, I found that although redis.conf was set, it did not restart.
So need real and profile start need:
redis-server redis.conf
Connect to redis again, success, start the project, success.
Nine, other
Check if the redis process exists
ps -ef |grep redis
Check if port 6379 is listening
netstat -lntp | grep 6379
To stop redis, use the shortcut key of control+c or use the client redis-cli shutdown