1、Redis的下载地址
https://download.redis.io/releases/
2、Redis的安装
-
(1)将下载下来的文件上传到指定的linux文件夹下;
-
(2)将文件夹进行解压
tar -zxvf redis-5.0.9.tar.gz
-
(3)安装gcc
yum install gcc # 查看gcc版本 gcc --version
-
(4)进入解压文件redis-5.09,执行编译
make install
-
(5)安装完成,在/usr/local/bin 目录下会多一些命令
redis-benchmark:测试电脑性能的 redis-check-aof -> redis-server:检查修复aof文件的,本质是执行了redis-server文件 redis-check-rdb -> redis-server:检查修复rdb文件的,本质是执行了redis-server文件 redis-cli:redis自带的客户端,可以使用它来连接redis服务端。(这个自带的通常不会使用) redis-sentinel:redis哨兵,用于监控redis集群中Master状态的工具。 redis-server:启动服务
3、redis的启动
-
(1)复制redis.conf文件到自己的指定的目录下
[root@master redis-danji]# mkdir conf [root@master redis-danji]# ls conf redis-5.0.9 redis-5.0.9.tar.gz [root@master redis-danji]# cd conf/ [root@master conf]# cp ../redis-5.0.9/redis.conf redis.conf [root@master conf]# ls redis.conf
-
(2)修改reids.conf文件中指定属性
daemonize yes #后台启动 protected‐mode no #关闭保护模式,开启的话,只有本机才可以访问redis # 需要注释掉bind #bind 127.0.0.1(bind绑定的是自己机器网卡的ip,如果有多块网卡可以配多个ip,代表允许客户 #端通过机器的哪些网卡ip去访问,内网一般可以不配置bind,注释掉即可)
-
(3)启动redis
[root@master conf]# redis-server ./redis.conf 106949:C 03 Jun 2024 21:24:05.343 # oO0OoO0OoO0Oo Redis is starting oO0OoO0OoO0Oo 106949:C 03 Jun 2024 21:24:05.343 # Redis version=5.0.9, bits=64, commit=00000000, modified=0, pid=106949, just started 106949:C 03 Jun 2024 21:24:05.343 # Configuration loaded [root@master conf]# ps -ef | grep redis root 106950 1 1 21:24 ? 00:00:00 redis-server *:6379 root 107222 22904 0 21:24 pts/0 00:00:00 grep --color=auto redis
-
(4)检查redis的性能
## 检查redis中get命令的性能 redis-benchmark get ====== get ====== 100000 requests completed in 7.64 seconds 50 parallel clients 3 bytes payload keep alive: 1 0.01% <= 1 milliseconds 67.65% <= 2 milliseconds 96.62% <= 3 milliseconds 98.04% <= 4 milliseconds 98.77% <= 5 milliseconds 99.20% <= 6 milliseconds 99.56% <= 7 milliseconds 99.71% <= 8 milliseconds 99.80% <= 9 milliseconds 99.82% <= 10 milliseconds 99.83% <= 11 milliseconds 99.86% <= 12 milliseconds 99.88% <= 13 milliseconds 99.88% <= 14 milliseconds 99.89% <= 15 milliseconds 99.91% <= 16 milliseconds 99.94% <= 17 milliseconds 99.95% <= 18 milliseconds 99.97% <= 20 milliseconds 99.97% <= 21 milliseconds 100.00% <= 21 milliseconds 13080.44 requests per second
-
(5)连接reids
[root@master conf]# redis-cli 127.0.0.1:6379> set key1 hello OK 127.0.0.1:6379> get key1 "hello" 127.0.0.1:6379> quit [root@master conf]#
4、redis的关闭
pkill redis‐server
kill 进程号
src/redis‐cli shutdown