Redis installation steps
1. Download the installation package from the official website
First, we go to the official website of redis: https://redis.io/download/ to download the installation package
2. Use Xftp to transfer the installation package to the Linux opt directory
Open the Xftp tool, connect to the Linux host, and then transfer the redis installation package to the opt directory of Linux
3. Use Xshell to connect to the Linux host to install redis
After transferring the installation package, use the Xshell tool to connect to the Linx host, and then switch to the opt directory to decompress the redis installation package. (To be on the safe side, first check whether the gcc tool exists)
cd /opt/ # 切换到opt目录
ls # 查看opt的子文件
gcc --version # 查看gcc编译器是否安装
tar -vzxf redisXXX.tar.gz # 解压redis的安装包 xxx为版本号
Then enter the directory where the redis installation package is decompressed, and use the make command to compile
cd redis-XXX/ # xxx为版本号
make
The successfully compiled interface is similar to the following figure
Then use the make install command to download and install. After installation, its default installation directory is /user/local/bin .
make install
Installation directory description
- redis-benchmark : performance testing tool
- redis-check-aof : Fix problematic AOF files
- redis-check-dump : fix buggy dump.rdb files
- redis-sentinel : used by redis cluster
- redis-server : redis server startup command
- redis-cli : client, operation entry
4. Two ways to start the redis service
4.1 Foreground startup
Switch to the redis installation directory /usr/local/bin directory, and then enter the command redis-server to start the redis service in the foreground
cd /usr/local/bin
ls
redis-server
After the redis service starts, the interface is as follows:
4.2 Background start
To start in the background, you need to modify the configuration, that is, to modify the redis.conf configuration file, and change the daemonize no to yes (generally, copy a copy of redis.conf to the etc directory, and then modify it).
First enter the redis installation package directory, and then find the redis.conf configuration file.
cd /opt/redis-xxxx/ # xxx为版本号
ls
Copy the redis.conf configuration file to the etc directory
cp redis.conf /etc/redis.conf
Use vim to modify the redis.conf configuration file, and use to /关键字
quickly find the daemonize configuration item.
vim redis.conf
After modification, press ESC to enter command mode, enter :wq
to save and exit the redis configuration file.
Now, the redis service can be started through the background
cd /usr/local/bin/ # 切换目录
ls
redis-server /etc/redis.conf #通过后台启动redis服务
Enter ps -ef | grep redis
to view the service process
Use the redis-cli client to connect to the port number, and then use the ping command to test whether it is connected.
redis-cli # 连接端口号
ping #测试是否连通
The service is stopped, and the service can be stopped through the kill or shutdown command
shutdown