## 实验环境


此次实验的环境如下

- Redhat 7.4
- sysbench版本:sysbench 1.1.0 

推荐不要在安装有MySQL服务的机器上安装,而是在单独的机器上安装

## 1. 安装依赖包



```
yum -y install make automake libtool pkgconfig libaio-devel
# For MySQL support, replace with mysql-devel on RHEL/CentOS 5
yum -y install mariadb-devel openssl-devel
rpm -ql mariadb-devel
# For PostgreSQL support
yum -y install postgresql-devel
```

## 2. 下载源码包

```
https://github.com/akopytov/sysbench
```

或者通过下面百度云下载

链接: https://pan.baidu.com/s/1W3lysCQdZDooU9ltXuoAdg 提取码: m73e 

## 3. 开始安装
```
root用户
unzip sysbench-master.zip
cd sysbench-master/
./autogen.sh
./configure  --prefix=/usr/sysbench/ --with-mysql-includes=/usr/include/mysql/  --with-mysql-libs=/usr/lib64/mysql/  -with-pgsql
make -j
make install
```


[image:923 size:orig]


[image:924 size:orig]


这里我们通过-with-mysql-includes 和--with-mysql-libs指定mysql相关文件位置

可通过rpm -ql mariadb-devel命令查看

-with-pgsql代表添加postgresql的支持,注意需要先安装pg相关的包

--prefix 代表sysbench安装的位置


最后将命令加入到环境变量中

```
PATH=$PATH:$HOME/bin:/usr/sysbench/bin
```

## 4.验证安装

```
sysbench --help
```
[image:925 size:orig]


## 5. sysbench目录结构

我们可以在/usr/sysbench目录下看到两个目录

- bin
- share

bin目录下为sysbench的二进制命令

share目录下为自带的一些测试脚本

[image:926 size:orig]



## 6. 参考资料

[https://github.com/akopytov/sysbench](https://github.com/akopytov/sysbench)