zoukankan      html  css  js  c++  java
  • redis安装及性能测试

    Redis是一个开源的使用ANSI C语言编写、遵守BSD协议、支持网络、可基于内存亦可持久化的日志型、Key-Value数据库。通常被称为数据结构服务器,因为值(value)可以是 字符串(String), 哈希(Hash), 列表(list), 集合(sets) 和 有序集合(sorted sets)等类型。

    Linux安装

    1、选择下载资源的文件目录(如:/opt),获取redis资源

    wget http://download.redis.io/releases/redis-4.0.8.tar.gz

     2、解压

    tar xzvf redis-4.0.8.tar.gz

    3、安装

    cd redis-2.8.17

    make

    cd src

    make install PREFIX=/usr/local/redis (该处遇到失败时,查询了You need tcl 8.5 or newer in order to run the Redis test)

     解决方案:

    安装tcl-8.5.13-8.el7.x86_64.rpm

    1>wget http://mirror.centos.org/centos/7/os/x86_64/Packages/tcl-8.5.13-8.el7.x86_64.rpm

    2>rpm -ivh tcl-8.5.13-8.el7.x86_64.rpm

    4.移动配置文件到安装目录下

      cd ../

      mkdir /usr/local/redis/etc

      mv redis.conf /usr/local/redis/etc

     5.配置redis为后台启动

      vi /usr/local/redis/etc/redis.conf //将daemonize no 改成daemonize yes

    6.将redis加入到开机启动

      vi /etc/rc.local //在里面添加内容:/usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf (意思就是开机调用这段开启redis的命令)

    7.开启redis

      /usr/local/redis/bin/redis-server /usr/local/redis/etc/redis.conf 

    常用命令  

      redis-server /usr/local/redis/etc/redis.conf //启动redis

      pkill redis  //停止redis

      卸载redis:

        rm -rf /usr/local/redis //删除安装目录

        rm -rf /usr/bin/redis-* //删除所有redis相关命令脚本

        rm -rf /root/download/redis-4.0.4 //删除redis解压文件夹

    redis性能测试

     Redis 自带了一个叫 redis-benchmark 的工具来模拟 N 个客户端同时发出 M 个请求。 (类似于 Apache ab 程序)。你可以使用 redis-benchmark -h 来查看基准参数

    以下参数被支持:
    
    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 2)
     -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).
     -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.


    参考博客1:https://www.cnblogs.com/lauhp/p/8487029.html

    参考博客2:https://blog.csdn.net/zhangchaoyang/article/details/104456978

    参考博客3:https://www.cnblogs.com/happywish/p/10944253.html

    redis官方文档:http://www.redis.cn/topics/benchmarks.html

  • 相关阅读:
    Centos7:mariadb替换mysql
    CentOS5 部署 戴尔OMSA
    《Zero MQ》
    可扩展的Web架构和分布式系统
    队列实现
    超级好用的正则表达式网站
    <转>undefined与null的区别
    JS事件
    sublime text 3 快捷键
    设置className的方式(不使用setAttribute)
  • 原文地址:https://www.cnblogs.com/guobaozhu/p/13363336.html
Copyright © 2011-2022 走看看