此处主要在Redis软件安装涉及的文件目录做标准化规划以及如何快速进行Redis单实例的部署。
#创建配置所有相关目录
mkdir -p /opt/redis/{logs,conf,data,tmp}
#官方下载二进制包并安装
wget https://download.redis.io/releases/redis-7.0.4.tar.gz -P /tmp
tar -zxvf /tmp/redis-7.0.4.tar.gz -C /opt
cd /opt/redis-7.0.4/
make && make install PREFIX=/opt/redis/
#从安装包中,复制文件到redis配置中,作为节点的配置文件
cp redis.conf /opt/redis/conf/
修改节点配置文件内容:
# 允许访问Redis的源地址
bind 0.0.0.0
# 默认进程运行在后台
daemonize yes
pidfile /opt/redis/tmp/redis_6379.pid
# 配置日志文件路径
logfile "/opt/redis/logs/redis.log"
# 配置持久化文件存放路径
dir /opt/redis/data/
# 配置auth安全认证
requirepass 123456
启动redis
/opt/redis/bin/redis-server /opt/redis/conf/redis.conf
连接redis
[root@dba opt]# /opt/redis/bin/redis-cli
127.0.0.1:6379> auth 123456
OK
127.0.0.1:6379> info replication
# Replication
role:master
connected_slaves:0
master_failover_state:no-failover
master_replid:1499f004648b6b93ed60505a994881943f3cd6e5
master_replid2:0000000000000000000000000000000000000000
master_repl_offset:0
second_repl_offset:-1
repl_backlog_active:0
repl_backlog_size:1048576
repl_backlog_first_byte_offset:0
repl_backlog_histlen:0
127.0.0.1:6379>