下载

需要以下内容

  • redis
  • make
  • build-essential
  • pkg-config
  • libdpkg-perl

安装

tar -zxvf redis-7.2.2.tar.gz
cd redis-7.2.2
make test && make
# Command 'make' not found, but can be installed with:
# sudo apt install make        # version 4.3-4.1build1, or
# sudo apt install make-guile  # version 4.3-4.1build1

# 因此需要为离线环境安装 make
sudo apt-get download make
# 这里能下下来 make 所需的 deb 包, 到时候迁移到离线环境
sudo dpkg -i make_4.3-4.1build1_amd64.deb 

# 然后再回到 redis 进行测试
sudo make test && make
# /bin/sh: 1: cc: not found
# make[1]: *** [Makefile:436: adlist.o] Error 127
# make[1]: Leaving directory '/home/xxx/environments/redis-7.2.4/src'
# make: *** [Makefile:6: test] Error 2

# 需要安装 pkg-config 
sudo apt-get download pkg-config
sudo dpkg -i pkg-config_0.29.2-1ubuntu3_amd64.deb
# 报错
# dpkg: dependency problems prevent configuration of pkg-config:
#  pkg-config depends on libdpkg-perl; however:
#   Package libdpkg-perl is not installed.

# 因此
sudo apt-get download libdpkg-perl
sudo dpkg -i libdpkg-perl_1.21.1ubuntu2.2_all.deb

# 重试安装 pkg-config 
sudo dpkg -i pkg-config_0.29.2-1ubuntu3_amd64.deb
# 成功装上

# cc 还需要 gcc 编译器
# build-essential
# 用下面这个命令就可以把 build-essential 和相关依赖包装到一个目录下了
sudo apt-get -o Dir::Cache::archives="/home/xxx/environments/tes" --download-only install build-essential

# 然后迁移后手动安装
sudo dpkg -i *.deb

# 进入 redis/src 下
make distclean && make test

# 完成后
sudo make && sudo make install 

# 测试
redis-cli --version
# redis-cli 7.2.4

配置

sudo cp /home/xxx/environments/redis-7.2.4/redis.conf /etc/redis.conf
sudo vim /etc/redis.conf

配置文件

# 配置个密码先
requirepass 123456

# 守护进程, 就是开了之后在后台运行
daemonize yes

# 日志文件
# 实际上还没配
logfile "redis.log"

# 其他以后用到了再附上来

开机自启动,这个还没测试, 先放着

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

[Service]
Type=forking
ExecStart=/usr/local/bin/redis-server /etc/redis.conf
PrivateTmp=true

[Install]
WantedBy=multi-user.target

Windows启动

redis-server redis.windows.conf