当前位置: 移动技术网 > IT编程>数据库>MongoDB > Redis 5.0.5 Install manual

Redis 5.0.5 Install manual

2019年06月24日  | 移动技术网IT编程  | 我要评论

redis 5.0.5 安装文档(install manual)

一、单实例安装

标题 内容
测试环境 centos 7
虚拟机 vbox
redis版本 redis 5.0.5

1.编译安装redis

#使用wget从官网现在redis数据库tar压缩包
$ wget http://download.redis.io/releases/redis-5.0.5.tar.gz
#使用tar解压tar压缩包
$ tar xzf redis-5.0.5.tar.gz
#进入redis解压后的目录
$ cd redis-5.0.5
#使用make编译安装redis数据库,直接make会报错,详细错误信息查看第5节错误分析内容
$ make malloc=libc

2.redis编译测试

#直接make test报错,需要安装相关依赖包,运行测试时候需要tcl-tool command language 包
$ yum install tcl
#执行make test 测试
$ make test

测试结果如下:
测试结果

3.运行redis数据库

运行完成编译后,在源码文件夹中的src文件夹中会生成redis相关的二进制文件。运行编译好的二进制文件启动redis数据库:
the binaries that are now compiled are available in the src directory. run redis with:

#运行redis-server 二进制执行文件,启动redis服务端程序。
$ src/redis-server

redis server启动如下图:
启动

可以使用redis-cli命令连接数据库与数据库服务端进行交互。
you can interact with redis using the built-in client:

#运行redis-cli启动数据库客户端,连接默认redis数据库
$ src/redis-cli
#测试redis数据库,插入一个foo bar 键值对
redis> set foo bar
#插入成功
ok
#获取foo key的值
redis> get foo
"bar"

4.redis性能测试

redis 数据库自带性能测试工具,工具名称:redis-benchmark,使用此工具对数据库进行性能测试。

redis-benchmark具体使用参数
invalid option "-help" or option argument missing

usage: redis-benchmark [-h <host>] [-p <port>] [-c <clients>] [-n <requests>] [-k <boolean>]

 -h <hostname>      server hostname (default 127.0.0.1)
 -p <port>          server port (default 6379)
 -s <socket>        server socket (overrides host and port)
 -a <password>      password for redis auth
 -c <clients>       number of parallel connections (default 50)
 -n <requests>      total number of requests (default 100000)
 -d <size>          data size of set/get value in bytes (default 3)
 --dbnum <db>       select the specified db number (default 0)
 -k <boolean>       1=keep alive 0=reconnect (default 1)
 -r <keyspacelen>   use random keys for set/get/incr, random values for sadd
  using this option the benchmark will expand the string __rand_int__
  inside an argument with a 12 digits number in the specified range
  from 0 to keyspacelen-1. the substitution changes every time a command
  is executed. default tests use this to hit random keys in the
  specified range.
 -p <numreq>        pipeline <numreq> requests. default 1 (no pipeline).
 -e                 if server replies with errors, show them on stdout.
                    (no more than 1 error per second is displayed)
 -q                 quiet. just show query/sec values
 --csv              output in csv format
 -l                 loop. run the tests forever
 -t <tests>         only run the comma separated list of tests. the test
                    names are the same as the ones produced as output.
 -i                 idle mode. just open n idle connections and wait.

examples:

 run the benchmark with the default configuration against 127.0.0.1:6379:
   $ redis-benchmark

 use 20 parallel clients, for a total of 100k requests, against 192.168.1.1:
   $ redis-benchmark -h 192.168.1.1 -p 6379 -n 100000 -c 20

 fill 127.0.0.1:6379 with about 1 million keys only using the set test:
   $ redis-benchmark -t set -n 1000000 -r 100000000

 benchmark 127.0.0.1:6379 for a few commands producing csv output:
   $ redis-benchmark -t ping,set,get -n 100000 --csv

 benchmark a specific command line:
   $ redis-benchmark -r 10000 -n 10000 eval 'return redis.call("ping")' 0

 fill a list with 10000 random elements:
   $ redis-benchmark -r 10000 -n 10000 lpush mylist __rand_int__

 on user specified command lines __rand_int__ is replaced with a random integer
 with a range of values selected by the -r option.

use redis-benchmark tools test redis performance .

使用redis-benchmark 测试redis性能
#实例同时执行 1000 个请求来检测性能
./redis-benchmark -n 1000 -q

#测试存取大小为100字节的数据包的性能
redis-benchmark -h 127.0.0.1 -p 6379 -q -d 100

#100个并发连接,100000个请求,检测host为localhost 端口为6379的redis服务器性能 
redis-benchmark -h 127.0.0.1 -p 6379 -c 100 -n 100000 

5.错误记录与分析

直接make报如下错误:
错误

原因是jemalloc重载了linux下的ansi c的malloc和free函数。解决办法:make时添加参数。

make malloc=libc

运行后编译成功。如下图:
编译成功

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网