1. Linux安装redis-7.0.5

1.1 安装wget

1
yum install -y wget

1.2 下载redis

1
2
cd /opt/software
wget http://download.redis.io/releases/redis-7.0.5.tar.gz

1.3 解压

1
2
tar zxvf redis-7.0.5.tar.gz
mv redis-7.0.5 /opt/module/

1.4 安装gcc依赖

1
2
yum install gcc-c++ 
gcc -v

1.5 执行make命令

1
2
3
/opt/module/redis-7.0.5
make
make install # 确认是否执行成功

1.6 备份redis.conf

1
2
3
4
5
cd /usr/local/bin # 默认安装目录
mkdir redisconfig
cp /opt/module/redis-7.0.5/redis.conf redisconfig/
cd redisconfig/
cp redis.conf redis.conf.bak # 备份

1.7 服务端启动

1
2
3
4
5
cd /usr/local/bin

redis-server redisconfig/redis.conf

ps -ef |grep redis

1.8 使用redis-cli连接测试

1
2
3
redis-cli -p 6379
127.0.0.1:6379> ping
PONG

1.9 其他配置

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
1、在redis-cli命令行执行shutdown关闭redis
2、vi /etc/systemd/system/redis.service
[Unit]
Description=redis-server
After=network.target

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

[Install]
WantedBy=multi-user.target
3、systemctl daemon-reload
4、systemctl命令操作redis
# 启动
systemctl start redis
# 停止
systemctl stop redis
# 重启
systemctl restart redis
# 查看状态
systemctl status redis
5、开机自启
systemctl enable redis

image-20240520230036150

2. Docker安装redis


本站由 卡卡龙 使用 Stellar 1.27.0 主题创建

本站访问量 次. 本文阅读量 次.