因为想用 wrk 做一些测试验证,所以就安装了一波,然后发现居然要编译安装,这确实很不人性化,所以我就自己编译了一个 RPM,以后直接一条命令用 RPM 安装就可以了,所以这里我就记录一下这两种安装方式,分别是源码安装和 RPM 安装:
源码安装
下面是编译安装过程,其实很简单:
[root@liqiang.io]# yum groupinstall 'Development Tools'
[root@liqiang.io]# yum install -y openssl-devel git
[root@liqiang.io]# git clone https://github.com/wg/wrk.git wrk
[root@liqiang.io]# cd wrk
[root@liqiang.io]# make
[root@liqiang.io]# cp wrk /usr/local/bin/
这样就可以了,使用 wrk 查看一下是否安装正常:
[root@liqiang.io]# wrk -v
wrk 4.1.0 [epoll] Copyright (C) 2012 Will Glozer
Usage: wrk <options> <url>
Options:
-c, --connections <N> Connections to keep open
-d, --duration <T> Duration of test
-t, --threads <N> Number of threads to use
-s, --script <S> Load Lua script file
-H, --header <H> Add header to request
--latency Print latency statistics
--timeout <T> Socket/request timeout
-v, --version Print version details
Numeric arguments may include a SI unit (1k, 1M, 1G)
Time arguments may include a time unit (2s, 2m, 2h)
这样就表示没问题了。既然安装过程还挺麻烦的,所以我就自己建了一个 RPM 的 release,可以参考:wrk-rpm,通过我的这个 repo,你可以快速得安装了。
RPM 安装
[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
这样就安装好了,同样的,查看一下版本:
[root@liqiang.io]# wrk -v
wrk 4.1.0 [epoll] Copyright (C) 2012 Will Glozer
Usage: wrk <options> <url>
Options:
-c, --connections <N> Connections to keep open
-d, --duration <T> Duration of test
-t, --threads <N> Number of threads to use
-s, --script <S> Load Lua script file
-H, --header <H> Add header to request
--latency Print latency statistics
--timeout <T> Socket/request timeout
-v, --version Print version details
Numeric arguments may include a SI unit (1k, 1M, 1G)
Time arguments may include a time unit (2s, 2m, 2h)