文档首页/ MapReduce服务 MRS/ 开发指南(LTS版)/ ClickHouse开发指南(安全模式)/ 调测ClickHouse应用/ 在本地Windows环境中调测ClickHouse应用(MRS 3.3.0及之后版本)
更新时间:2024-06-12 GMT+08:00
分享

在本地Windows环境中调测ClickHouse应用(MRS 3.3.0及之后版本)

编译并运行程序

在程序代码完成开发后,您可以在Windows环境中运行应用。本地和集群业务平面网络互通时,您可以直接在本地进行调测。

操作步骤

  1. 单击IDEA右边Maven窗口的“Reload All Maven Projects”,进行maven项目依赖import。

    图1 reload projects

  2. 在IDEA界面复制clickhouse-example.properties路径。右键clickhouse-example.properties文件,单击“Copy Path/Reference > Absolute Path”。

    事务样例工程无需执行此步骤。

    图2 复制配置文件绝对路径

  3. 使用clickhouse-example.properties路径替换Demo.java中getProperties()方法中proPath的路径。

    图3 Demo.java路径替换

  4. 使用clickhouse-example.properties路径替换ClickhouseJDBCHaDemo.java中initConnection()方法中proPath的路径。

    事务样例工程无需执行此步骤。

    图4 ClickhouseJDBCHaDemo.java路径替换

  5. 编译程序。

    • 选择“Maven > clickhouse-examples > Lifecycle > clean”,双击“clean”运行maven的clean命令。
    • 选择“Maven > clickhouse-examples > Lifecycle > compile”,双击“compile”运行maven的compile命令。
    图5 Maven的clean和compile

  6. 单击“Run 'Demo.main()'”运行应用程序工程。

    图6 运行程序

查看调测结果

ClickHouse应用程序运行完成后,可通过以下方式查看程序运行情况:

  • 通过运行结果查看程序运行情况。
  • 通过ClickHouse日志获取应用运行情况,即“logs”目录下的日志文件:clickhouse-example.log

运行clickhouse-examples的完整样例后,控制台显示部分运行结果如下:

2023-09-19 16:20:48,344 | INFO  | main | loadBalancerIPList is 192.168.5.132, loadBalancerHttpPort is 21422, user is ck_user, clusterName is default_cluster, isSec is true, password is Admin12!. | com.huawei.clickhouse.examples.Demo.main(Demo.java:42)
2023-09-19 16:20:48,350 | INFO  | main | ckLbServerList current member is 0, ClickhouseBalancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Demo.getCkLbServerList(Demo.java:110)
2023-09-19 16:20:48,436 | INFO  | main | Current load balancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:68)
2023-09-19 16:20:50,781 | INFO  | main | Execute query:drop table if exists testdb.testtb on cluster default_cluster no delay | com.huawei.clickhouse.examples.Util.exeSql(Util.java:73)
2023-09-19 16:20:51,504 | INFO  | main | Execute time is 723 ms | com.huawei.clickhouse.examples.Util.exeSql(Util.java:77)
2023-09-19 16:20:51,511 | INFO  | main | Current load balancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:68)
2023-09-19 16:20:51,897 | INFO  | main | Execute query:drop table if exists testdb.testtb_all on cluster default_cluster no delay | com.huawei.clickhouse.examples.Util.exeSql(Util.java:73)
2023-09-19 16:20:52,421 | INFO  | main | Execute time is 524 ms | com.huawei.clickhouse.examples.Util.exeSql(Util.java:77)
2023-09-19 16:20:52,422 | INFO  | main | Current load balancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:68)
2023-09-19 16:20:52,946 | INFO  | main | Execute query:create database if not exists testdb on cluster default_cluster | com.huawei.clickhouse.examples.Util.exeSql(Util.java:73)
2023-09-19 16:20:53,405 | INFO  | main | Execute time is 458 ms | com.huawei.clickhouse.examples.Util.exeSql(Util.java:77)
2023-09-19 16:20:53,406 | INFO  | main | Current load balancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:68)
2023-09-19 16:20:53,757 | INFO  | main | Execute query:create table testdb.testtb on cluster default_cluster (name String, age UInt8, date Date)engine=ReplicatedMergeTree('/clickhouse/tables/{shard}/testdb.testtb','{replica}') partition by toYYYYMM(date) order by age | com.huawei.clickhouse.examples.Util.exeSql(Util.java:73)
2023-09-19 16:20:54,243 | INFO  | main | Execute time is 485 ms | com.huawei.clickhouse.examples.Util.exeSql(Util.java:77)
2023-09-19 16:20:54,244 | INFO  | main | Current load balancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:68)
2023-09-19 16:20:54,640 | INFO  | main | Execute query:create table testdb.testtb_all on cluster default_cluster as testdb.testtb ENGINE = Distributed(default_cluster,testdb,testtb, rand()); | com.huawei.clickhouse.examples.Util.exeSql(Util.java:73)
2023-09-19 16:20:55,175 | INFO  | main | Execute time is 535 ms | com.huawei.clickhouse.examples.Util.exeSql(Util.java:77)
2023-09-19 16:20:55,175 | INFO  | main | Current load balancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Util.insertData(Util.java:143)
2023-09-19 16:20:58,868 | INFO  | main | Insert batch time is 503 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:160)
2023-09-19 16:21:01,015 | INFO  | main | Insert batch time is 631 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:160)
2023-09-19 16:21:02,521 | INFO  | main | Inert all batch time is 4163 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:164)
2023-09-19 16:21:02,522 | INFO  | main | Current load balancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:68)
2023-09-19 16:21:03,051 | INFO  | main | Execute query:select * from testdb.testtb_all order by age limit 10 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:73)
2023-09-19 16:21:03,430 | INFO  | main | Execute time is 379 ms | com.huawei.clickhouse.examples.Util.exeSql(Util.java:77)
2023-09-19 16:21:03,433 | INFO  | main | Current load balancer is 192.168.5.132:21422 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:68)
2023-09-19 16:21:03,760 | INFO  | main | Execute query:select toYYYYMM(date),count(1) from testdb.testtb_all group by toYYYYMM(date) order by count(1) DESC limit 10 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:73)
2023-09-19 16:21:04,361 | INFO  | main | Execute time is 600 ms | com.huawei.clickhouse.examples.Util.exeSql(Util.java:77)
2023-09-19 16:21:04,362 | INFO  | main | name	age	date	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,362 | INFO  | main | huawei_9	12	2021-04-20	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,362 | INFO  | main | huawei_17	15	2021-05-23	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO  | main | huawei_5	24	2021-04-15	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO  | main | huawei_13	39	2020-07-04	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO  | main | huawei_3	49	2021-06-27	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO  | main | huawei_15	50	2020-06-26	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO  | main | huawei_11	53	2020-08-14	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO  | main | huawei_12	56	2021-12-19	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO  | main | huawei_19	57	2021-10-31	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO  | main | huawei_0	57	2020-03-01	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,363 | INFO  | main | toYYYYMM(date)	count()	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO  | main | 202105	3	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO  | main | 202110	2	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO  | main | 202104	2	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO  | main | 202008	2	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO  | main | 202007	2	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO  | main | 202106	2	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO  | main | 202012	1	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO  | main | 202109	1	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,364 | INFO  | main | 202003	1	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:04,365 | INFO  | main | 202011	1	 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:158)
2023-09-19 16:21:05,044 | INFO  | main | Name is: huawei_9, age is: 12 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,044 | INFO  | main | Name is: huawei_17, age is: 15 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,045 | INFO  | main | Name is: huawei_5, age is: 24 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,045 | INFO  | main | Name is: huawei_13, age is: 39 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,045 | INFO  | main | Name is: huawei_3, age is: 49 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,045 | INFO  | main | Name is: huawei_15, age is: 50 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,045 | INFO  | main | Name is: huawei_11, age is: 53 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,045 | INFO  | main | Name is: huawei_12, age is: 56 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,045 | INFO  | main | Name is: huawei_19, age is: 57 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)
2023-09-19 16:21:05,046 | INFO  | main | Name is: huawei_0, age is: 57 | com.huawei.clickhouse.examples.ClickhouseJDBCHaDemo.queryData(ClickhouseJDBCHaDemo.java:78)

Process finished with exit code 0

相关文档