Redis 3种安装部署方式

redis安装部署

系统 CentOS 7.6

yum 安装

# yum install redis

## 修改监听端口
# vim /etc/redis.conf
···
bind 0.0.0.0
···
# systemctl start redis
# systemctl enable redis

## 测试redis
# redis-cli
127.0.0.1:6379> set name evescn
127.0.0.1:6379> get name
"evescn"

tar包安装

## 获取二进制包
# cd /opt
# wget http://download.redis.io/releases/redis-5.0.8.tar.gz

## 安装编译过程中需要的软件
# yum instal gcc tcl

## 编译安装包
# tar -zxvf redis-5.0.8.tar.gz
# cd redis-5.0.8
# make
# make test
# make install

- 直接启动(服务运行在非后台)
# redis-server

- 后台服务运行
## 修改当前目录下生成的配置文件
# vim ./redis.conf

bind 0.0.0.0 # 监听IP地址
port 6379 # 端口
daemonize yes # 守护进程模式启动
pidfile /var/run/redis_6379.pid # 进程pid目录
logfile "/var/log/redis.log" # 日志路径
dir ./ # 数据目录

# redis-server /opt/redis-5.0.8/redis.conf

安装过程中报错解决方案

参考文档

https://blog.csdn.net/qq_28039297/article/details/76616963

https://redis.io/download

docker运行

  • 安装docker环境
# cd /etc/yum.repos.d/
# wget https://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo

# yum install docker-ce-18.06.2.ce
# docker -v
# systemctl start docker
# systemctl enable docker
# systemctl status docker
  • 安装redis
## 拉去redis镜像
# docker pull redis

## 创建目录,并手动生成配置文件
#  mkdir -p /opt/data/redis
# cp /opt/redis-5.0.8/redis.conf /opt/data/redis/redis.conf

## 修改配置文件信息
# vim /opt/data/redis/redis.conf

daemonize no # 非守护进程模式启动,必须设置为no,否则容器无法正常运行

# docker run --name myredis -p 6379:6379 --restart=always --log-driver json-file --log-opt max-size=100m --log-opt max-file=2 -v /opt/data/redis/redis.conf:/etc/redis/redis.conf -v /opt/data/redis:/data -d redis redis-server /etc/redis/redis.conf --appendonly yes --requirepass "123456"

参考文档

https://www.cnblogs.com/linjiqin/p/10472023.html
原文地址:https://www.cnblogs.com/evescn/p/12762511.html