redis offline installation

This year, the country has attached great importance to network security, and the result is a lot of old and new projects. The previous project also needs to be migrated from centos/windows to a domestic server, and the assigned server system is kylin10, so make a simple record.

1. Obtain online

1. Install compilation tools and library files

Installed can be ignored, basically not all minimal installations.

yum -y install make zlib zlib-devel gcc-c++ libtool openssl openssl-devel

2. Download redis

  • Method 1: wget http://download.redis.io/releases/redis-4.0.8.tar.gz
  • Method 2: Obtain the installation file: http://download.redis.io/releases

Two, install redis

1. Compile and install

#文件上传后解压缩
tar xzvf redis-4.0.8.tar.gz

#进入redis目录
cd redis-4.0.8

#编译
make

#检查磁盘资源
df -h

#发现数据盘挂载到/data路径下,选此为安装路径
#安装,/data/module表示安装路径   ,PREFIX参数指定redis的安装目录。
make install PREFIX=/data/module/redis 

2. Start redis

#进入bin目录下
cd /data/module/redis/bin

#直接启动redis
./redis-server

After success, the following picture is obtained:

3. Modify the configuration

  • Get the redis.conf configuration file :
    • Unzip the installation package to get redis.conf directly
    • Find configuration files online
  • Copy redis.conf to /data/module/redis/bin
  • Edit the redis.conf file, and modify the items as follows:
#设置后台运行redis
daemonize yes

#注释bind 127.0.0.1
#bind 127.0.0.1

#protected-mode yes 改成 protected-mode no
protected-mode no

#修改端口号
port 30002
  • Start redis:**./redis-server redis.conf**
  • Check if it is started**ps aux|grep redis**

3. Start up automatically

1. Create a new system service file

vim /etc/systemd/system/redis.service

document content:

[Unit]
Description=redis-server
After=network.target

[Service]
Type=forking
ExecStart=/data/module/redis/bin/redis-server /data/module/redis/bin/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target

2. Start the system service

#重载系统服务
systemctl daemon-reload

# 启动
systemctl start redis
# 停止
systemctl stop redis
# 重启
systemctl restart redis
# 查看状态
systemctl status redis

#设置开机自启动
systemctl enable redis

4. Test

image.png

Guess you like

Origin blog.csdn.net/qq_16253859/article/details/131429315