因为想用 wrk 做一些测试验证,所以就安装了一波,然后发现居然要编译安装,这确实很不人性化,所以我就自己编译了一个 RPM,以后直接一条命令用 RPM 安装就可以了,所以这里我就记录一下这两种安装方式,分别是源码安装和 RPM 安装:

源码安装

下面是编译安装过程,其实很简单:

  1. [root@liqiang.io]# yum groupinstall 'Development Tools'
  2. [root@liqiang.io]# yum install -y openssl-devel git
  3. [root@liqiang.io]# git clone https://github.com/wg/wrk.git wrk
  4. [root@liqiang.io]# cd wrk
  5. [root@liqiang.io]# make
  6. [root@liqiang.io]# cp wrk /usr/local/bin/

这样就可以了,使用 wrk 查看一下是否安装正常:

  1. [root@liqiang.io]# wrk -v
  2. wrk 4.1.0 [epoll] Copyright (C) 2012 Will Glozer
  3. Usage: wrk <options> <url>
  4. Options:
  5. -c, --connections <N> Connections to keep open
  6. -d, --duration <T> Duration of test
  7. -t, --threads <N> Number of threads to use
  8. -s, --script <S> Load Lua script file
  9. -H, --header <H> Add header to request
  10. --latency Print latency statistics
  11. --timeout <T> Socket/request timeout
  12. -v, --version Print version details
  13. Numeric arguments may include a SI unit (1k, 1M, 1G)
  14. Time arguments may include a time unit (2s, 2m, 2h)

这样就表示没问题了。既然安装过程还挺麻烦的,所以我就自己建了一个 RPM 的 release,可以参考:wrk-rpm,通过我的这个 repo,你可以快速得安装了。

RPM 安装

  1. [root@liqiang.io]# yum install -y https://github.com/scutse/wrk-rpm/releases/download/4.1.0/wrk-4.1.0-1.el7.centos.x86_64.rpm

这样就安装好了,同样的,查看一下版本:

  1. [root@liqiang.io]# wrk -v
  2. wrk 4.1.0 [epoll] Copyright (C) 2012 Will Glozer
  3. Usage: wrk <options> <url>
  4. Options:
  5. -c, --connections <N> Connections to keep open
  6. -d, --duration <T> Duration of test
  7. -t, --threads <N> Number of threads to use
  8. -s, --script <S> Load Lua script file
  9. -H, --header <H> Add header to request
  10. --latency Print latency statistics
  11. --timeout <T> Socket/request timeout
  12. -v, --version Print version details
  13. Numeric arguments may include a SI unit (1k, 1M, 1G)
  14. Time arguments may include a time unit (2s, 2m, 2h)