Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ClickHouse cannot properly detect local timezone #495

Closed
jarwin123 opened this issue Feb 15, 2017 · 16 comments
Closed

ClickHouse cannot properly detect local timezone #495

jarwin123 opened this issue Feb 15, 2017 · 16 comments
Assignees

Comments

@jarwin123
Copy link

@jarwin123 jarwin123 commented Feb 15, 2017

[root@localhost dbms]# clickhouse-server --config-file=/etc/clickhouse-server/config.xml
Include not found: clickhouse_remote_servers
Include not found: clickhouse_compression
/usr/share/zoneinfo/CST: No such file or directory
POCO ERROR: Exception: Cannot load time zone CST
terminate called after throwing an instance of 'Poco::Exception'
what(): Exception
Aborted (core dumped)

@jarwin123 jarwin123 changed the title ClickHouse complie error ClickHouse compile error Feb 15, 2017
@jarwin123 jarwin123 changed the title ClickHouse compile error ClickHouse run error Feb 15, 2017
@jarwin123

This comment has been minimized.

Copy link
Author

@jarwin123 jarwin123 commented Feb 15, 2017

[root@localhost ~]# date
Wed Feb 15 21:13:27 CST 2017
[root@localhost ~]# date -u
Wed Feb 15 13:13:29 UTC 2017
[root@localhost ~]#

@ztlpn

This comment has been minimized.

Copy link
Contributor

@ztlpn ztlpn commented Feb 15, 2017

For ClickHouse to function properly, server timezone must be set to one of TZ database timezones. These correspond to files in /usr/share/zoneinfo/. For CST the corresponding name is probably 'US/Central' or 'America/Chicago'.

How did you configure the timezone on your server? Could you please show the output of
ls -l /etc/localtime and echo $TZ?

As a workaround you can set TZ environment variable manually before starting ClickHouse:

TZ=US/Central clickhouse-server --config-file=/etc/clickhouse-server/config.xml
@jarwin123

This comment has been minimized.

Copy link
Author

@jarwin123 jarwin123 commented Feb 15, 2017

[root@localhost ~]# ls -l /etc/localtime
lrwxrwxrwx. 1 root root 35 Aug 19 2015 /etc/localtime -> ../usr/share/zoneinfo/Asia/Shanghai
[root@localhost ~]# echo $TZ

@jarwin123

This comment has been minimized.

Copy link
Author

@jarwin123 jarwin123 commented Feb 15, 2017

clickhouse have some User Defined Function?

@ztlpn

This comment has been minimized.

Copy link
Contributor

@ztlpn ztlpn commented Feb 15, 2017

Did you change timezone config parameter to CST? I guess you mean China Standard Time then, not US Central Standard Time, so default server timezone (which is Asia/Shanghai) should be OK.

@jarwin123

This comment has been minimized.

Copy link
Author

@jarwin123 jarwin123 commented Feb 15, 2017

no, i cannot change timezone,maybe poco library have some problem!

@ztlpn

This comment has been minimized.

Copy link
Contributor

@ztlpn ztlpn commented Feb 15, 2017

I mean, did you change ClickHouse config and set timezone parameter there?

@jarwin123

This comment has been minimized.

Copy link
Author

@jarwin123 jarwin123 commented Feb 15, 2017

yes ,i add 'Asia/Shanghai' in /etc/clickhouse-server/config.xml, clickhouse-server can run ,but clickhouse-client cannot run.
i modify dbms/src/Client/Client.cpp
307 setenv("TZ", "Asia/Shanghai",1);
308 tzset();
309 DateLUT::instance();

now clickhouse-client can run now.

@ztlpn

This comment has been minimized.

Copy link
Contributor

@ztlpn ztlpn commented Feb 15, 2017

Modifying the source code should not be necessary.

Do you run clickhouse-client on the same machine as clickhouse-server? What was the exact error message when clickhouse-client failed to start?

@jarwin123

This comment has been minimized.

Copy link
Author

@jarwin123 jarwin123 commented Feb 15, 2017

yes ,in same machine.
the error:
[root@localhost build]# clickhouse-client
ClickHouse client version 1.1.54164.
Connecting to localhost:9000.
Connected to ClickHouse server version 1.1.54164.

/usr/share/zoneinfo/CST: No such file or directory
Poco::Exception: Exception: Cannot load time zone CST

use this command clickhouse-client is ok
' TZ=Asia/Shanghai clickhouse-client'

@ztlpn

This comment has been minimized.

Copy link
Contributor

@ztlpn ztlpn commented Feb 15, 2017

I can't figure out where this erroneous timezone string 'CST' is coming from. Please provide additional information:

  1. Which Unix flavor/Linux distribution do you use?
  2. What happens when you erase timezone parameter from ClickHouse configs and start clickhouse-server? If it fails to start, what is the error message?
  3. What is the output of timedatectl?
  4. What is the output of cat /etc/sysconfig/clock?
@jarwin123

This comment has been minimized.

Copy link
Author

@jarwin123 jarwin123 commented Feb 16, 2017

@ztlpn
1.[root@localhost ~]# lsb_release -a
LSB Version: :core-4.1-amd64:core-4.1-noarch:cxx-4.1-amd64:cxx-4.1-noarch:desktop-4.1-amd64:desktop-4.1-noarch:languages-4.1-amd64:languages-4.1-noarch:printing-4.1-amd64:printing-4.1-noarch
Distributor ID: CentOS
Description: CentOS Linux release 7.1.1503 (Core)
Release: 7.1.1503
Codename: Core

2.[root@localhost dbms]# clickhouse-server --config-file=/etc/clickhouse-server/config.xml
Include not found: clickhouse_remote_servers
Include not found: clickhouse_compression
/usr/share/zoneinfo/CST: No such file or directory
POCO ERROR: Exception: Cannot load time zone CST
terminate called after throwing an instance of 'Poco::Exception'
what(): Exception
Aborted (core dumped)

3.[root@localhost ~]# timedatectl
Local time: Thu 2017-02-16 09:22:38 CST
Universal time: Thu 2017-02-16 01:22:38 UTC
RTC time: Thu 2017-02-16 01:22:38
Timezone: Asia/Shanghai (CST, +0800)
NTP enabled: yes
NTP synchronized: yes
RTC in local TZ: no
DST active: n/a

4.[root@localhost ~]# cat /etc/sysconfig/clock
cat: /etc/sysconfig/clock: No such file or directory

@ztlpn

This comment has been minimized.

Copy link
Contributor

@ztlpn ztlpn commented Feb 16, 2017

Ok, I've been able to reproduce, thanks for reporting!

@ztlpn ztlpn assigned ztlpn and unassigned proller Feb 16, 2017
@ztlpn ztlpn added the bug label Feb 16, 2017
@ztlpn ztlpn changed the title ClickHouse run error ClickHouse cannot properly detect local timezone Feb 17, 2017
@ztlpn

This comment has been minimized.

Copy link
Contributor

@ztlpn ztlpn commented Mar 30, 2017

Fixed in v1.1.54198.

@ztlpn ztlpn closed this Mar 30, 2017
@sharp-dev

This comment has been minimized.

Copy link

@sharp-dev sharp-dev commented Apr 5, 2017

clickhouse вроде российское произведение.. вы простите, но я не знаю английского, можно мне в 52 года не учить с нуля?. но вот хочу попользоваться. но запусти блин не могу. и советы по установке 'US/Central' or 'America/Chicago' мне как то не помогают. можно для не грамотного, но своего, подсказку как запустить в таймзоне RTZ2 ?

ps в юбунте 14.04 и в 17.04, если есть разница

@ztlpn

This comment has been minimized.

Copy link
Contributor

@ztlpn ztlpn commented Apr 5, 2017

@sharp-dev Здравствуйте. ClickHouse поддерживает наименования таймзон из IANA timezone database, вот полный список: https://en.wikipedia.org/wiki/List_of_tz_database_time_zones. Если под RTZ2 имеется в виду московское время, то его идентификатор Europe/Moscow. В большинстве случаев достаточно правильно настроить системную таймзону, в ubuntu это делается командой sudo dpkg-reconfigure tzdata.

Если проблемы с запуском останутся, заведите пожалуйста отдельный issue, в нём надо будет указать сообщение об ошибке, которое выдаёт ClickHouse.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
5 participants
You can’t perform that action at this time.