【问题标题】:Cassandra displaying different time zonesCassandra 显示不同的时区
【发布时间】:2017-12-30 21:58:31
【问题描述】:

当我启动 cassandra 时,时间显示是正确的。它正在使用我的机器时间。但是,在插入数据时,我使用的是时间戳列。时间戳使用 UTC 时区。我希望两次同步。

cassandra 启动时:

INFO  [main] 2017-07-25 11:46:57,933 StorageService.java:2248 - Node localhost/127.0.0.1 state jump to NORMAL

在列中:

 seq     | age | city      | dollar | first     | last    | last_modified                   | pick | state     | street          | zip 
 --------+-----+-----------+--------+-----------+---------+--------------------------------+------+-----------+-----------------+--------
 2100005 |  23 | Bangalore | $40000 | Sushmitha | Vegesna | 2017-07-25 06:19:12.950000+0000 | BLUE | Karnataka | 10th cross road | 500049

【问题讨论】:

    标签: cassandra timezone


    【解决方案1】:

    cassandra 启动时:

    INFO [main] 2017-07-25 11:46:57,933 StorageService.java:2248 - 节点 localhost/127.0.0.1 状态跳转到NORMAL

    这是 casssandra 在控制台/日志文件上打印的日志...它使用您的系统日期时间。

    向cassandra插入数据时,可以手动指定时区,使用特定时区。

    Insert into table (timestamp_column1) values ('2017-07-25 00:00:00+0530');
    

    当使用 cqlsh 查询数据时,时间戳列使用 .cqlshrc 文件中设置的时区值显示。默认为 UTC 时区。 在 .cqlshrc 文件中更改显示时区更改

    [ui]
    ;; Display timezone
    timezone = Etc/UTC
    

    TimeStamp in cassandra

    【讨论】:

    • 我没有找到任何 .cqlshrc 文件,而是找到了 cqlshrc.sample 文件并在其中进行了更改。但是输出没有变化。
    • 如果使用windows... cqlshrc文件需要在C:\user\your_user\.cassandra
    • 我使用的是 Ubuntu。
    • 如果未指定时区,则使用处理写入请求的 Cassandra 协调器节点的时区。为了准确起见,DataStax 建议指定时区,而不是依赖于 Cassandra 节点上配置的时区.....issues.apache.org/jira/browse/CASSANDRA-10397
    猜你喜欢
    • 2010-11-26
    • 2020-03-28
    • 2020-09-15
    • 2012-07-22
    • 2018-01-09
    • 2016-12-28
    • 1970-01-01
    • 2018-09-07
    相关资源
    最近更新 更多