一、编译安装环境配置
官方文档: http://intel.github.io/hyperscan/dev-reference/getting_started.html
1.1硬件配置
配置 | 参数 |
---|---|
CPU | Intel® Xeon® Gold 5218R CPU @ 2.10GHz |
CPU核数 | 8核 |
注:需要满足以下条件
1、X86架构
2、Supplemental Streaming SIMD Extensions 3 (SSSE3)
1.2软件配置
配置 | 需求版本 | 使用版本 |
---|---|---|
操作系统 | RedHat/CentOS 7 or newer | CentOS Linux release 8.4.2105 |
编译器 | GCC, v4.8.1 or higher | gcc (GCC) 8.4.1 |
1.3依赖配置
依赖 | 需求版本 | 使用版本 |
---|---|---|
cmake | >=2.8.11 | 3.20.2 |
ragel | 6.9 | 6.9 |
Python | 2.7 | 2.7.15 |
Boost | >=1.57 | 1.77.0 |
Pcap | >=0.8 | 1.10.1 |
二、编译安装
2.1、替换yum阿里云源(方便直接yum软件)
cd /etc/yum.repos.d/mv CentOS-Linux-Base.repo CentOS-Base.repo.bakwget -O /etc/yum.repos.d/CentOS-Base.repo http://mirrors.aliyun.com/repo/Centos-8.repo
修改CentOS-Linux-Base.repo
sed -i “%s/mirrors.cloud.aliyuncs.com/mirrors.aliyun.com/g”
sed -i “s/$releasever/$releasever-stream/g”
修改CentOS-Linux-AppStream.repo 、CentOS-Linux-Extras.repo
将原来的mirrorlist给注释掉,然后新增一行:
baseurl=https://mirrors.aliyun.com/centos/$releasever-stream/extras/$basearch/os/
清理缓存:
yum clean all
生成缓存:
yum makecache
2.2、安装cmake 、gcc 、gcc-c++ 、git
yum -y install cmake gcc gcc-c++ git
2.3、克隆源码
git clone https://github.com/intel/hyperscan.git
2.4、编译安装python-2.7.15(centos 8自带python3)
yum -y install make zlib-devel bzip2-devel openssl-devel ncurses-devel sqlite-devel
tar -zxf Python-2.7.15.tgz
cd Python-2.7.15
./configure --enable-optimizations --prefix=/usr/local/python2.7
make altinstall
ln -sf /usr/local/python2.7/bin/python2.7 /usr/bin/python
python -V
2.5、编译安装ragel
tar -zxf ragel-6.9.tar.gz
cd ragel-6.9
CXXFLAGS="-std=c++98" ./configure && make && make install
ragel --version
2.6、部署boost
tar -zxf boost_1_77_0.tar.gz
ln -sf /root/HyperscanTest/boost_1_77_0/boost /root/HyperscanTest/hyperscan/include/boost
2.7、编译安装libpcap
yum -y install flex bison
tar -zxf libpcap-1.10.1.tar.gz
cd libpcap-1.10.1
./configure && make && make install
2.8、编译安装hyperscan
2.8.1、修改权限
chmod -R 755 hyperscan
2.8.2、创建编译目录
#hyperscan 目录同级
mkdir build
2.8.3、编译
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=on /root/HyperscanTest/hyperscan
2.8.4、构建
cmake --build .
或者
make -j
make install
注:make -j 后可以传一个并行度参数,允许多个命令同时执行,如 make -j 16
2.9、检查(在build目录下)
2.9.1、查看是否生成so库
ll ./lib
2.9.2单元测试
./bin/unit-hyperscan