更新时间:2024-08-03 GMT+08:00
在Linux环境中调测ClickHouse应用
ClickHouse应用程序也支持在Linux环境中运行。在程序代码完成开发后,您可以上传Jar包至准备好的Linux运行环境中运行。
前提条件
Linux环境已安装JDK,版本号需要和IntelliJ IDEA导出Jar包使用的JDK版本一致,并设置好Java环境变量。
编译并运行程序
- 导出jar包。
- 将“clickhouse-examples\out\artifacts\clickhouse_examples.jar”目录下的所有jar文件和“clickhouse-examples”目录下的“conf”文件夹复制到ClickHouse客户端安装目录下,例如“客户端安装目录/JDBC”目录下。
- 登录客户端节点,进入jar文件上传目录下,修改文件权限为700。
cd /opt/Bigdata/client
chmod 700 clickhouse-examples.jar
- 在“clickhouse_examples.jar”所在客户端目录下执行如下命令运行jar包:
source 客户端安装目录/bigdata_env
java -cp ./*:conf/clickhouse-example.properties com.huawei.clickhouse.examples.Demo
查看调测结果
ClickHouse应用程序运行完成后,可通过以下方式查看程序运行情况:
- 通过运行结果查看程序运行情况。
- 通过ClickHouse日志获取应用运行情况。
即查看当前jar文件所在目录的“logs/clickhouse-example.log”日志文件,例如“客户端安装目录/JDBC/logs/clickhouse-example.log”。
jar包运行结果如下:
2021-06-10 20:53:56,028 | INFO | main | Current load balancer is 10.112.17.150:21426 | com.huawei.clickhouse.examples.Util.insertData(Util.java:128) 2021-06-10 20:53:58,247 | INFO | main | Inert batch time is 1442 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:145) 2021-06-10 20:53:59,649 | INFO | main | Inert batch time is 1313 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:145) 2021-06-10 20:54:05,872 | INFO | main | Inert batch time is 6132 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:145) 2021-06-10 20:54:10,223 | INFO | main | Inert batch time is 4272 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:145) 2021-06-10 20:54:11,614 | INFO | main | Inert batch time is 1300 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:145) 2021-06-10 20:54:12,871 | INFO | main | Inert batch time is 1200 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:145) 2021-06-10 20:54:14,589 | INFO | main | Inert batch time is 1663 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:145) 2021-06-10 20:54:16,141 | INFO | main | Inert batch time is 1500 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:145) 2021-06-10 20:54:17,690 | INFO | main | Inert batch time is 1498 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:145) 2021-06-10 20:54:19,206 | INFO | main | Inert batch time is 1468 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:145) 2021-06-10 20:54:19,207 | INFO | main | Inert all batch time is 22626 ms | com.huawei.clickhouse.examples.Util.insertData(Util.java:148) 2021-06-10 20:54:19,208 | INFO | main | Current load balancer is 10.112.17.150:21426 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:58) 2021-06-10 20:54:20,231 | INFO | main | Execute query:select * from mutong1.testtb_all order by age limit 10 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:63) 2021-06-10 20:54:21,266 | INFO | main | Execute time is 1035 ms | com.huawei.clickhouse.examples.Util.exeSql(Util.java:67) 2021-06-10 20:54:21,267 | INFO | main | Current load balancer is 10.112.17.150:21426 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:58) 2021-06-10 20:54:21,815 | INFO | main | Execute query:select toYYYYMM(date),count(1) from mutong1.testtb_all group by toYYYYMM(date) order by count(1) DESC limit 10 | com.huawei.clickhouse.examples.Util.exeSql(Util.java:63) 2021-06-10 20:54:22,897 | INFO | main | Execute time is 1082 ms | com.huawei.clickhouse.examples.Util.exeSql(Util.java:67) 2021-06-10 20:54:22,898 | INFO | main | name age date | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,898 | INFO | main | huawei_266 0 2021-12-19 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,899 | INFO | main | huawei_2500 0 2021-12-29 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,899 | INFO | main | huawei_8980 0 2021-12-16 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,899 | INFO | main | huawei_671 0 2021-12-29 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,899 | INFO | main | huawei_2225 0 2021-12-12 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,899 | INFO | main | huawei_6040 0 2021-12-14 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,899 | INFO | main | huawei_7294 0 2021-12-10 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,899 | INFO | main | huawei_1133 0 2021-12-25 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,900 | INFO | main | huawei_3161 0 2021-12-21 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,900 | INFO | main | huawei_3992 0 2021-11-25 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,900 | INFO | main | toYYYYMM(date) count() | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,900 | INFO | main | 201910 2247 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,900 | INFO | main | 202105 2213 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,900 | INFO | main | 201801 2208 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,900 | INFO | main | 201803 2204 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,901 | INFO | main | 201810 2167 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,901 | INFO | main | 201805 2166 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,901 | INFO | main | 201901 2164 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,901 | INFO | main | 201908 2145 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,901 | INFO | main | 201912 2143 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144) 2021-06-10 20:54:22,901 | INFO | main | 202107 2137 | com.huawei.clickhouse.examples.Demo.queryData(Demo.java:144)
父主题: 调测ClickHouse应用