Download and install
1. Download address
Linux version redis
Windows version redis
2. Upload the Linux version of redis to Linux
3. Unzip the installation packagetar -zxvf redis-4.0.0.0.tar.gz -C /usr/local
4. Secretly transfer the dependent environment gcc
, command:yum insall gcc-c++
5. Enter the redis-4.0.0 update directory and compile, command:make
6. Enter the src directory of redis and install it. Command:make install
Let me mention here the windows version of redis installation. We directly downloaded the green version, which can be used after decompression.
Start, stop, connect
1. Normal start, stop, connect
To start the redis service in Linux, you can use redis-server
the directory where it is located src/redis-server
;
to connect to redis redis-cli
, you can use the directory where it is located.src/redis-cli
Start command: ./redis-server
Default port 6379
Stop command: ctrl+c
Stop redis
service
Connect command: View data ./redis-cli
without password by defaultkeys *
Problem: Starting like this will occupy the screen.
2. Optimize screen dominance
1. Let it execute the redis service in the background, find the redis.conf file from the redis root directory
2. Execute vim redis.conf
and edit
3. Search daemonize no
and modify it to daemonize yes
, which means it starts running in the background
4. Similarly, we are also in the redis.conf file You can see the place where the port is configured. port:6379
5. Startup command: src/redis-server ./redis.conf
startup file startup configuration
set password
1. Find the redis.conf file from the redis root directory
2. Execute vim redis.conf
to edit
3. Find requirepass foobaredxxxxx
and release its comment, change the password
4. Restart the service command: src/redis-server ./redis.conf
startup file startup configuration
remote connection
1. Local connection
command description: cli command [-h domain name] [-p port] [-a authentication auth]
execution command:src/redis-cli -h localhost -p 6379 -a foobaredxxxxx
The connection is successful and you can pass keys *
the check
2. Remote connection
Linux rejects remote connections by default, and the following error is reported
Could not connect to Redis at 192.168.2.128:6379: 由于连接方在一段时间后没有正确答复或连接的主机没有反应,连接尝试失败。
We still need to modify redis.conf
the file
- Execute
vim redis.conf
edit searchbind 127.0.0.1
- What this sentence means is that currently redis can only have 127 local connections. Let’s comment out this sentence.
- Kill the process
kill -9 6379
and restart the servicesrc/redis-server ./redis.conf
Note: We also need to release 6379
the port in the firewall.
Execute: firewall-cmd --zone=public --add-port = 6379/tcp --permanent
Release the port.
Execute: firewall-cmd --reload
Restart the firewall.
Then there is the root directory of redis-cli in the remote local reids (here is a windows connection as an example)
Excuting an order:./redis-cli.exe -h 192.168.x.x -p 6379 -a foobaredxxxxx