1. Get redis resources
Enter the URL of redis official website ,
After the browser is downloaded, click to unzip, and then the terminal finds the file address and pushes it to the server using the scp command
scp -r redis-5.0.7/ [email protected]:/root
# 此条命令详解
-r 递归,因为推送的是一个文件夹 需要加 -r
redis-5.0.7/ 这是我们刚刚redis官网下载解压后的文件
[email protected] 服务器账户和IP地址
:/root 最后的/root 是推送到服务器文件存放的地址
2. Installation
cd redis-5.0.7
make
cd src
make install PREFIX=/usr/local/redis
(If there is an execution error, install gcc first. The installation command is: yum -y install gcc automake autoconf libtool make .
If [zmalloc.h:50:31: fatal error: jemalloc/jemalloc.h: no such file or directory] appears, run the command make MALLOC=libc)
3. Move the configuration file to the installation directory
cd ../
mkdir /usr/local/redis/etc
mv redis.conf /usr/local/redis/etc
4. Configure redis to start in the background
vim /usr/local/redis/etc/redis.conf // Change daemonize no to daemonize yes
5. Turn on redis
/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf
6. Use redis-cli globally
cp /usr/local/redis/bin/redis-cli /usr/bin/
7. Turn on remote access (can be skipped here)
8. Set password (according to personal needs)
Uncomment line 502 and change the password
9. Set redis to start automatically
First copy the redis_init_script script in the redis-5.0.7/utils directory to /etc/init.d and change the name to redis
Edit the redis file and add a comment at the head of the file
# chkconfig: 2345 90 10
# description: Redis is a persistent key-value database
To this we need to copy the redis.conf file to the /etc/redis directory
mkdir /etc/redis
cp /usr/local/redis/etc/redis.conf /etc/redis/6379.conf
The above part of modifying the file is basically over, and then just type a simple command to get it done
This is the end of all the simple configuration, let's test the redis startup and shutdown
Finally, the reboot test is complete