clickhouse (9, metabase link and time zone configuration)

Install metabase

# 选用docker方式,下载镜像
docker pull metabase/metabase
# 创建插件目录
mkdir -p /data/docker/metabase/plugins
# 启动容器,将目录挂载到容器/tmp 目录下
docker run -d -v /data/docker/metabase/plugins:/tmp  \
			--name metabase  \
			metabase/metabase

Configure clickhouse driver

# 进入/data/docker/metabase/plugins 目录,下载clickhouse驱动包
wget https://github.com/enqueue/metabase-clickhouse-driver/releases/download/0.7.2/clickhouse.metabase-driver.jar
# 进入容器 
docker exec -it ${容器id} bash
# 移动jar到/plugins目录,之前安装github方式直接mount plugins,启动发现目录为空,所以改成其他目录导入形式
cp /tmp/clickhouse.metabase-driver.jar /plugins
# 退出重启容器
docker restart ${容器id}

After logging in at localhost:3000 , I found the driver of clickhouse:
Insert picture description here

Metabase time zone configuration

First of all, we must ensure that the time configuration of the clickhouse server is normal. /etc/clickhouse-server/config.xmlTime zone configuration in.

<timezone>Asia/Shanghai</timezone>

Link to clickhouse service and execute to select now();see if it is consistent with the current time.
Next, look at the time zone configuration in metabase in the Administrator -> Basic Settings -> Time Zone Report. It can be configured in China Asia/Hong_Kong, but unfortunately it does not take effect in ck. You can write SQL queries through the upper right corner of the metabase homepage.

select now();

So I started to look at the data source configuration of clickhouse. You can see that the link clickhouse uses the jdbc method, and the jdbc url theory can take parameters.
Insert picture description here
So I tried to configure the general parameters serverTimeZone=Asia/Shanghaiand found no effect. Then check the official ck documentation and find that the ck time zone requires --use_client_time_zonethe parameters of the client . So in the metabase configuration use_client_time_zone=Asia/Shanghai, an exception was thrown:

one of use_server_time_zone or use_time_zone must be enabled

This understanding on the strange, literal understanding is use_time_zoneand use_server_time_zonemust be a use of it, why has a configuration error. Try to configure another one use_time_zone, the same error is reported. Although I just arrived inexplicable, but seeing such a prompt, I feel that this parameter configuration is at least effective on the link. After trying to configure at the same time, finally passed. The UTC+8sum here Asia/Shanghaiis equivalent.

use_time_zone=UTC+8&use_server_time_zone=UTC+8

After the interface test select now();, the query database DateTime format column time shows normal.

Guess you like

Origin blog.csdn.net/yyoc97/article/details/107300441