【Redis】Redis 安装

Redis 安装

1、Docker

docker-compose

# docker-compose.yml
version : '3'
services:
  redis:
    image: redis:6.2
    container_name: redis
    restart: always
    command: redis-server /etc/redis/conf/redis.conf
    ports:
      - "6379:6379"
    volumes:
      # 使用自定义的 redis 配置
      - "./redis/conf/redis.conf:/etc/redis/conf/redis.conf"
      # 结合 redis 的配置文件来设置数据的挂载目录,对应 redis 的 dir 配置
      - "./redis/db:/data"
      - "/etc/localtime:/etc/localtime:ro"
    networks:
      - node-network
networks:
  node-network:

redis.conf

根据 redis 版本获取对应的配置,redis.conf

2、源码编译

2.1、下载解压

# 官方下载地址:https://redis.io/download
wget http://download.redis.io/releases/redis-6.2.14.tar.gz
tar -zxvf redis-6.2.14.tar.gz -C /usr/local/

2.2、编译

# 编译之前,要确保已经安装了gcc编译器
yum install -y make cmake gcc gcc-c++ 

# 进入redis的家目录:
cd /usr/local/redis-6.2.14/

# 编译
make && make install

2.3、启动

# 启动 redis 并加载指定配置
/usr/local/redis-6.2.14/bin/redis-server /usr/local/redis-6.2.14/redis.conf &

3、可执行文件

针对 Windows 环境,可以下载可执行文件:Redis 桌面版。执行 redis-server.exe。

Redis 配置

# 注释 bind
bind 127.0.0.1 -::1

# 密码
requirepass xxxxxxxx

# 端口
port 9736

# 取消保护模式
protected-mode no
创作不易,转载请注明出处: 【Redis】Redis 安装
上一篇