Ali server linux installation and start redis 6

The following operations are done under center os 7 of your own Alibaba Cloud server

installation

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:

Insert picture description here


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

Insert picture description here


No error indicates that the installation was successful.

start up

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

Insert picture description here

Seeing that there is a process indicates a successful start.

shut down

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 进程号
Insert picture description here

to sum up

  1. Download the package via http://redis.io/download
  2. Put the package in the opt directory as tar -zvxf decompress
  3. After decompression, there is no c environment. Install the environment through yum install gcc
  4. 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.
  5. Finally, the installation directory local will be generated under /usr
  6. 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.
  7. 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.
  8. 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.