Configure a time zone and localization settings
This topic shows how to set a time zone and configure localization settings in Greengage DB (based on Greenplum) after installation. Localization settings include a locale and character sets used by DBMS.
Configure a time zone
Time zone support in Greengage DB is essential for various purposes, such as displaying and interpreting time stamps. You can learn more about time zones from the corresponding section in the PostgreSQL documentation: Time Zones.
Greengage DB uses the IANA Time Zone Database provided by the operating system for time zone support.
For example, Ubuntu and CentOS use the tzdata
package, which contains rules for time zones defined in the Time Zone Database.
When this package is updated, Greengage DB updates its list of available time zones accordingly.
During DBMS initialization, the time zone is selected automatically based on the system environment.
To set the time zone manually, use the TimeZone
server configuration parameter.
This parameter accepts the full time zone name, such as Europe/Moscow
.
You can find the list of recognized time zone names in the pg_timezone_names
system view.
The TimeZone
configuration parameter also accepts POSIX-style time zone specifications, such as MSK-3
.
To display and configure the time zone, use the gpconfig
utility:
-
Determine the currently used time zone as follows:
$ gpconfig -s TimeZone
The output depends on your system environment’s time zone and might look as follows:
Values on all segments are consistent GUC : TimeZone Master value: Etc/UTC Segment value: Etc/UTC
-
To set a different time zone, provide its full name using the
-v
option:$ gpconfig -c TimeZone -v 'Europe/Moscow'
The output should look as follows:
[INFO]:-completed successfully with parameters '-c TimeZone -v Europe/Moscow'
-
Reload the configuration using
gpstop
:$ gpstop -u
-
Recheck the used time zone:
$ gpconfig -s TimeZone
The output should show that the cluster uses the specified time zone:
Values on all segments are consistent GUC : TimeZone Master value: Europe/Moscow Segment value: Europe/Moscow
To configure the time zone for timestamps in the logs, use the log_timezone
configuration parameter.
Configure localization settings
Greengage DB supports two localization facilities:
-
Locale features of the operating system.
Locale features include a locale-specific collation order, number and time values formatting, and so on. Locale support is automatically initialized when Greengage DBMS is initialized. By default, the
gpinitsystem
utility initializes DBMS with the locale settings of its execution environment. You can set the required locale using the-n
(or--locale
) option provided bygpinitsystem
. -
Support for different character sets (also called encodings).
Character sets map characters to their binary representations, enabling DBMS to process and represent text data consistently. Standard character sets include UTF-8, LATIN-9, and so on. The default character set is selected while initializing your Greengage DBMS using
gpinitsystem
. You can specify the required character set in the database configuration file using theENCODING
option. Note that the specified character set must be compatible with the locale set using the-n
(--locale
) option.
You can learn more about localization from the corresponding section in the PostgreSQL documentation: Localization.
Configure a locale
To use the specified locale for your Greengage DBMS, follow the steps below:
-
Generate the required locale on all cluster hosts. The command below generates a locale for the Russian language (Russia) with the UTF-8 encoding:
$ sudo locale-gen ru_RU.UTF-8
-
Make sure that the generated locale is available for use:
$ localectl list-locales
The output should include the following line:
ru_RU.utf8
-
Execute the
gpinitsystem
command with the-n
(or--locale
) option to initialize DBMS with the specified locale:$ gpinitsystem -c init_config -h hostfile_segment_hosts -s smdw -n ru_RU.utf8
Ensure that the
ENCODING
value specified in the init_config file is compatible with the selected locale. -
After initializing Greengage DBMS, make sure that all the databases have the correct locale settings:
$ psql -l
In the output, check the
Collate
andCtype
columns:List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+---------+----------+------------+------------+--------------------- postgres | gpadmin | UTF8 | ru_RU.utf8 | ru_RU.utf8 | template0 | gpadmin | UTF8 | ru_RU.utf8 | ru_RU.utf8 | =c/gpadmin + | | | | | gpadmin=CTc/gpadmin template1 | gpadmin | UTF8 | ru_RU.utf8 | ru_RU.utf8 | =c/gpadmin + | | | | | gpadmin=CTc/gpadmin (3 rows)
The
Encoding
column shows the encoding specified in the database configuration file.