The following operations are done under center os 7 of your own Alibaba Cloud server
Download address: http://redis.io/download, download the latest stable version.
Place the downloaded file in the directory opt where the installation package is stored:
install the C language environment
yum install gcc
Then unzip, compile and install
# 解压文件 tar -xzvf redis-6.2.4.tar.gz # 进入redis-6.2.4 文件夹中编译 make # 安装 make install
No error indicates that the installation was successful.
After the installation is successful, a local directory will be generated under usr. This is the installation directory of redis.
**Foreground startup: **Simple, but redis will also be closed when the terminal is closed.
cd /usr/local/bin ls redis-server #启动redis
**Background startup: **The process is more complicated, but it will keep running in the background when the terminal is turned off.
# 进入解压redis的文件目录中将redis的配置文件复制到etc目录中 cd /opt/redis-6.2.4 cp redis.conf /etc/redis.conf # 在etc中编辑redis.conf将daemonize的值改为yes代码默认是启动的 vim /etc/redis.conf # 进入vim编辑器后找到daemonize将值改成yes # 快速查找定位 /daemonize # 改成yes后,保存退出 :wq # 再接下来就是启动了，还是进入安装目录/usr/local/bin中 cd /usr/local/bin # 和前台启动的命令不同在后面加上配置文件位置 redis-server /etc/redis.conf # 最后通过ps命令查看后台redis有没有启动 ps -aux | grep redis
Seeing that there is a process indicates a successful start.
Method 1: Enter redis-cli and execute the shutdown command.
Method 2: Find the process id of redis and kill the process
ps -aux redis kill 进程号
to sum up
- Download the package via http://redis.io/download
- Put the package in the opt directory as tar -zvxf decompress
- After decompression, there is no c environment. Install the environment through yum install gcc
- After installing the environment, enter cd /opt/redis-6.2.4 in the decompressed redis directory, execute the command make to compile, and execute the command make install to install after the compilation is complete.
- Finally, the installation directory local will be generated under /usr
- Execute the redis-server file in the bin in the local directory to start redis, but in this way, redis will also be closed after closing the terminal.
- In the background startup, copy the redis.conf configuration file in the decompressed folder to the etc folder, and modify the daemonize value to yes.
- To close the service, you can use the shutdown command in the redis terminal, or you can find the redis process number and then use the kill command to kill the process.