如何使用IoTDB-benchmark测试GaussDB(for Influx)
在时序数据库领域,测试标准迟迟不能统一,各数据库厂商纷纷推出有利于自己的性能测试benchmark,如Timescale的TSBS,InfluxDB的influx_comparisons,IoTDB的IoTDB-benchmark,clickhouse的clickHouse-benchmark等。本文主要介绍IoTDB-benchmark如何测试华为云GuassDB(for influx) 时序数据库.
IOTDB-benchmark测试场景
IOTDB-benchmark中使用的场景主要是单时间线的精确查找、范围查找、聚合查询等,详细场景如下:
-
INGESTION(写入)
-
PRECISE_QUERY (精确查找)
eg. SELECT s_0 FROM group_2 WHERE ( device = 'd_8' ) AND time = 1535558405.
-
RANGE_QUERY (时间范围查询 )
eg. SELECT s_0 FROM group_2 WHERE ( device = 'd_8' ) AND time >= 1535558405 AND time <= 1535558905.
-
VALUE_RANGE_QUERY (值范围查询)
eg. SELECT s_3 FROM group_0 WHERE ( device = 'd_3' ) AND time >= 153555842 AND time <= 153555942 AND s_3 > -5.0
-
AGG_RANGE_QUERY (时间范围聚合查询)
eg. SELECT count(s_3) FROM group_4 WHERE ( device = 'd_16' ) AND time >= 1535558410 AND time <=8660000000
-
AGG_VALUE_QUERY (值范围聚合查询)
eg. SELECT count(s_3) FROM group_3 WHERE ( device = 'd_12' ) AND s_3 > -5.0.
-
AGG_RANGE_VALUE_QUERY (值和时间范围聚合查询)
eg. SELECT count(s_1) FROM group_2 WHERE ( device = 'd_8' ) AND time >= 1535558400000 AND time <= 650000000 AND s_1 > -5.0
-
GROUP_BY_QUERY (GroupBy 查询)
eg. SELECT count(s_3) FROM group_4 WHERE ( device = 'd_16' ) AND time >= 153555843000 AND time <=868000 GROUP BY time(20000ms).
-
LATEST_POINT_QUERY (last算子)
eg. SELECT last(s_2) FROM group_2 WHERE ( device = 'd_8' ).
-
RANGE_QUERY_ORDER_BY_TIME_DESC (范围查询 + Order BY)
-
VALUE_RANGE_QUERY_ORDER_BY_TIME_DESC (值和时间范围查询 + OrderBy)
IoTDB-benchmark支持GuassDB(for Influx)
GaussDB(for Influx)是华为云上的一款分布式时序数据库,接口完全兼容influxdb,IoTDB-benchmark支持InfluxDB,但是由于云上GuassDB(for Influx)当前默认使用的是https协议,因此需要针对IOTDB-benchmark的源码做一部分修改才可以正常连接使用。源码路径如下:
core/src/main/java/cn/edu/tsinghua/iotdb/benchmark/tsdb/influxdb/InfluxDB.java
修改步骤如下:
-
OkHttp改为支持https链接,证书校验默认通过,使用用户名密码连接GuassDB(for Influx)
public class InfluxDB implements IDatabase { public static SSLSocketFactory socketFactory() { SSLSocketFactory ssfFactory = null; try { SSLContext sc = SSLContext.getInstance("TLS"); sc.init(null, new TrustManager[]{new trustManager()}, new SecureRandom()); ssfFactory = sc.getSocketFactory(); } catch (Exception e) { } return ssfFactory; } public static class hostnameVerifier implements HostnameVerifier { @Override public boolean verify(String hostname, SSLSession session) { return true; } } public static class trustManager implements X509TrustManager, TrustManager { @Override public void checkServerTrusted(X509Certificate[] chain, String authType) throws CertificateException { } @Override public void checkClientTrusted(X509Certificate[] x509Certificates, String s) throws CertificateException { } @Override public X509Certificate[] getAcceptedIssuers() { return new X509Certificate[0]; } } #此处省略部分无关代码 private final String username = "rwuser"; private final String password = "******"; #密码为购买GaussDB(for Influx)实例时设置的rwuser用户的密码 #此处省略部分无关代码 @Override public void init() throws TsdbException { try { OkHttpClient.Builder client = new Builder().connectTimeout(5, TimeUnit.MINUTES). readTimeout(5, TimeUnit.MINUTES).writeTimeout(5, TimeUnit.MINUTES). retryOnConnectionFailure(true). connectionSpecs(Arrays.asList(ConnectionSpec.MODERN_TLS, ConnectionSpec.COMPATIBLE_TLS)). #修改处 sslSocketFactory(InfluxDB.socketFactory(),new InfluxDB.trustManager()). #修改处 hostnameVerifier(new InfluxDB.hostnameVerifier()); #修改处 influxDbInstance = org.influxdb.InfluxDBFactory.connect(influxUrl, username, password, client); #修改处 } catch (Exception e) { LOGGER.error("Initialize InfluxDB failed because ", e); throw new TsdbException(e); } } #此处省略部分无关代码 }
-
配置文件
修改配置文件config.properties,具体参数详情如下:
(1). DB_URL=https://rwuser:password@192.168.0.41:8635 ,配置时用真实密码替换password,如果密码中有特殊字符,比如@,用对应ASCII "%40"码代替,IP地址是GaussDB(for Influx)的SLB地址
(2). DB_SWITCH=InfluxDB
(3). DB_NAME=test ,设置数据库名
配置完成后如下图所示:
-
编译执行
修改完成后,重新编译源码mvn clean package -Dmaven.test.skip=true
执行
sh benchmark.sh
- 点赞
- 收藏
- 关注作者
评论(0)