文章目录

  • ​​官网下载压缩包​​
  • ​​自行上传服务器​​
  • ​​解压​​
  • ​​准备gcc​​
  • ​​`yum`安装​​
  • ​​检查`gcc`版本​​
  • ​​切换到安装目录执行编译​​
  • ​​`redis`默认安装目录​​
  • ​​准备配置文件(非必须)​​
  • ​​修改配置文件为后台启动​​
  • ​​`bind`配置(此服务可以接受方访问的`ip`)​​
  • ​​关闭保护模式​​
  • ​​开启数据持久化​​
  • ​​已修改的配置文件启动​​
  • ​​测试​​
  • ​​检查`redis`进程​​
  • ​​` redis-benchmark`性能测试​​
  • ​​参数​​
  • ​​案例​​
  • ​​退出客户端​​
  • ​​关闭服务​​

官网下载压缩包

​https://redis.io/​

自行上传服务器


Redis源码包安装_redis

解压

tar -zxvf redis-6.2.4.tar.gz

准备gcc

redis 是基于​​c++​​​编写的必须要有​​gcc c++​​的环境才可以运行.

​yum​​安装

yum install gcc-c++

检查​​gcc​​版本

gcc -v

Redis源码包安装_redis_02

切换到安装目录执行编译

Redis源码包安装_redis_03

make 

make install

​redis​​默认安装目录

cd /usr/local/bin/

ll

Redis源码包安装_redis_04

准备配置文件(非必须)

[root@dw bin]# mkdir redis-conf
[root@dw bin]# cd redis-conf/
[root@dw redis-conf]# ll
total 0
[root@dw redis-conf]# cp /home/dw/soft/redis-6.2.4/redis.conf .
[root@dw redis-conf]# ll
total 92
-rw-r--r--. 1 root root 93724 Jun 6 13:35 redis.conf

修改配置文件为后台启动

daemonize yes

​bind​​​配置(此服务可以接受方访问的​​ip​​)

# 表示所有IP都可以访问
bind 0.0.0.0

关闭保护模式

protected-mode no

开启数据持久化

appendonly yes

已修改的配置文件启动

redis-server redis-conf/redis.conf

测试

[root@dw bin]# redis-server redis-conf/redis.conf 
[root@dw bin]# redis-cli
127.0.0.1:6379> ping
PONG
127.0.0.1:6379>

检查​​redis​​进程

ps -ef | grep redis

Redis源码包安装_配置文件_05

​redis-benchmark​​性能测试

参数

序号

选项

描述

默认值

1

-h

指定服务器主机名

127.0.0.1

2

-p

指定服务器端口

6379

3

-s

指定服务器 socket

4

-c

指定并发连接数

50

5

-n

指定请求数

10000

6

-d

以字节的形式指定 SET/GET 值的数据大小

2

7

-k

1=keep alive 0=reconnect

1

8

-r

SET/GET/INCR 使用随机 key, SADD 使用随机值

9

-P

通过管道传输 请求

1

10

-q

强制退出 redis。仅显示 query/sec 值

11

–csv

以 CSV 格式输出

12

*-l*(L 的小写字母)

生成循环,永久执行测试

13

-t

仅运行以逗号分隔的测试命令列表。

14

*-I*(i 的大写字母)

Idle 模式。仅打开 N 个 idle 连接并等待。

案例

# 测试:100个并发连接 100000请求
redis-benchmark -h localhost -p 6379 -c 100 -n 100000

Redis源码包安装_配置文件_06

退出客户端

[root@dw bin]# redis-cli 
127.0.0.1:6379> exit
[root@dw bin]#

关闭服务

[root@dw bin]# 
[root@dw bin]# redis-cli
127.0.0.1:6379> shutdown
not connected>
not connected>
not connected>
[root@dw bin]#
[root@dw bin]# ps -ef | grep redis
root 73766 8673 0 13:55 pts/1 00:00:00 grep --color=auto redis
[root@dw bin]#