Set the time zone

更新时间:
复制 MD 格式

If the time zone of your instance is different from the time zone of your business, you must change the time zone of your instance to ensure the accuracy of time information during data processing and the consistency of the displayed time information across time zones.

Limits

The system allows you to change the time zone of your StarRocks instance only if the last three-digit version number of the minor version of the instance is greater than or equal to 1.6.0. For example, if the minor version of a StarRocks instance is 3.3.2-1.81-1.6.5, the last three-digit version number is 1.6.5, which is greater than 1.6.0. In this case, the system allows you to change the time zone of the instance.

Precautions

Before you import data, make sure that the global time zone of StarRocks is consistent with the time zone of deployed frontend (FE) nodes. Otherwise, an exception occurs when data of the DATE type is imported.

Introduction to time zones

The default value of the StarRocks time zone is Asia/Shanghai.

  • system_time_zone: the time zone of the operating system. It is the time zone of deployed FE nodes. You can change the time zone in the console.

  • time_zone: the session-level or global time zone. You can execute an SQL statement to change the time zone.

Change the system time zone

Important

If you change the system time zone, the StarRocks instance is restarted. Therefore, we recommend that you perform this operation during off-peak hours.

  1. Go to the details page of an EMR Serverless StarRocks instance.

    1. Log on to the EMR console.

    2. In the left-side navigation pane, choose EMR Serverless > StarRocks.

    3. In the top navigation bar, select a region based on your business requirements.

    4. In the Instances section, find the desired StarRocks instance and click the name of the instance.

  2. On the Instance Details page, in the Basic Information section, click Modify Time Zone.

  3. In the Modify Time Zone dialog box, configure the following parameters and click OK.

    Parameter

    Description

    Select Time Zone

    Select the desired time zone.

    Restart Mode

    This parameter is available only for shared-data instances.

    You can select a rolling restart or a quick restart.

    • Rolling Restart (default): This mode restarts the compute nodes (CNs) in the instance one by one, ensuring that some nodes are always running to maintain service availability. Recommended for scenarios that require high service continuity and minimal user impact.

    • Quick Restart: This mode restarts all CNs at once for a faster restart process. However, this may cause a brief service interruption. Perform this operation during off-peak hours.

      Note

      A quick restart is supported only for shared-data instances with a minor version of 1.6.10 or later.

Execute an SQL statement to view the time zone

  1. Connect to the instance. For more information, see Use EMR StarRocks Manager to connect to an EMR Serverless StarRocks instance.

  2. Execute the following SQL statement to view the time zone configuration:

     SHOW VARIABLES LIKE '%time_zone%';

    The following information is returned:

    It lists all time zone-related variables, such as the system time zone and the current session or global time zone.

    • Variable_name: The name of the variable, such as system_time_zone and time_zone.

    • Value: The value of the variable. The value indicates the time zone, such as Asia/Shanghai.

Execute an SQL statement to specify the session-level or global time zone

You can configure the time_zone parameter in the SQL editor to specify the time zone of StarRocks, and specify whether the time zone configuration takes effect at the session level or globally.

  • If you want the time zone configuration to take effect at the session level, execute the SET time_zone = 'xxx'; SQL statement. Different time zones can be specified for different sessions. If you disconnect a client from an FE node, the time zone configuration becomes invalid.

  • If you want the time zone configuration to take effect globally, execute the SET global time_zone = 'xxx'; SQL statement. An FE node stores the time zone configuration. The time zone configuration remains effective after you disconnect a client from the FE node.