1. Installation steps
1. Download the installation package
wget http://download.redis.io/releases/redis-7.0.9.tar.gz
2. Unzip
tar -zxvf redis-7.0.9.tar.gz
3. Copy the decompressed package to /usr/local/
sudo mv ./redis-7.0.9 /usr/local/
4. Compile
cd /usr/local/redis-7.0.9
sudo make
5. Test: the time will be relatively long, and the test depends on
sudo make test
6. Installation
sudo make install
#After the execution is complete, install the redis executable program in /usr/local/bin
7. Enter /usr/local/bin to check whether it is installed
cd /usr/local/bin
ls -all
redis-server redis server
redis-cli redis command line client
redis-benchmark redis performance testing tool
redis-check-aof AOF file repair tool
redis-check-rdb RDB file retrieval tool
8. Modify the configuration file
#Back up a
cd before modification /usr/local/redis-7.0.9
sudo cp redis.conf redis.conf.backup
sudo vi redis.conf
Core Configuration Items
1. Generally, you need to configure
bind 127.0.0.1 to bind the startup IP (default)
port 6379 to bind the startup port (default)
daemonize yes whether to run as a daemon process (running in the background) (default no)
requirepass set the password, you must first auth password to log in2. Depends on the situation configuration
#Data file: which file to write to for data persistence
dbfilename dump.rdb When the data is persisted, it is stored in this file, (default)
#Data file storage location: the lib/redis directory must be created first, otherwise it will Failure
dir /var/lib/redis #dump.rdb file creation location (default./)#Log file (default "") [log/redis directory must be created first]
logfile /var/log/redis/redis-server.log# Number of databases, default 16
database 16 [Number: 0-15]#Master-slave replication, similar to dual-machine backup
slaveof master IP master port [only required for master-slave configuration]
9. Configure boot self-start [to use the sudo service redis xx command must be configured]
cd /etc/systemd/system
sudo vi redis.service
#The content is as follows:[Unit]
Description=redis-server
After=network.target[Service]
Type=forking
ExecStart=/usr/local/bin/redis-server /usr/local/redis-7.0.9/redis.conf
PrivateTmp=true[Install]
WantedBy=multi-user.target
10. After restarting the computer, test whether redis starts automatically
ps -aux | grep redis
11. Use the built-in client for testing
#Start the client
cd /usr/local/bin
./redis-cli
#Log in
127.0.0.1:6379> password set by auth
#test
127.0.0.1:6379> ping
PONG
12. Redis service related commands
1. Start: sudo service redis start
2. Stop: sudo service redis stop
3. Restart: sudo service redis restart
4. Restart 2:
ps -aux | grep redis Query the process id of the redis service
sudo kill -9 redis pid kill redis process
sudo redis-server /usr/local/redis-7.0.9/redis.conf specifies the configuration file to start