Pivotal Greenplum® 6.9-安装指南-配置时区和本地化设置

配置时区和本地化设置

描述Greenplum数据库的可用时区和本地化功能。

父主题: 安装和升级Greenplum
 

配置时区

Greenplum数据库从一组内部存储的PostgreSQL时区中选择要使用的时区。可用的PostgreSQL时区取自互联网数字分配机构(IANA)时区数据库,当IANA数据库针对PostgreSQL有更改时,Greenplum数据库会根据需要更新其可用时区列表。

Greenplum数据库选择时区的方式:将PostgreSQL的时区与Timezone服务器的配置参数的值进行匹配,或当Timezone服务器未设置时则依据主机系统的时区。例如,当从主机系统时区中选择默认时区时,Greenplum数据库根据主机系统时区文件,使用一种算法来选择PostgreSQL时区。如果系统时区包含闰秒信息,则Greenplum数据库无法将系统时区与PostgreSQL时区匹配。在这种情况下,Greenplum数据库根据来自主机系统的信息,计算与PostgreSQL时区的“最佳匹配”。

最佳做法是,将Greenplum数据库和主机系统配置为使用已知的、受支持的时区。这将为Greenplum数据库主master和segment实例设置时区,并防止Greenplum Database在每次重启集群时,使用当前系统时区和Greenplum Database时区文件(自上次重启后,可能已从IANA数据库更新),来选择最佳匹配的时区。使用 gpconfig工具来显示和设置Greenplum数据库时区。例如,以下命令显示Greenplum数据库时区,并将时区设置为 美国/太平洋。

# gpconfig -s TimeZone
# gpconfig -c TimeZone -v 'US/Pacific'

更改时区后,必须重新启动Greenplum数据库。命令gpstop -ra重新启动Greenplum数据库。目录视图 pg_timezone_names 提供了Greenplum数据库时区信息。

关于Greenplum数据库中的本地化支持

Greenplum数据库通过两种方法支持本地化:

  • 使用操作系统的语言环境功能,来提供特定于语言环境的集合顺序、数字格式等。
  • 提供Greenplum数据库服务器中定义的许多不同字符集,包括多字节字符集,以支持存储各种语言的文本,并提供客户端和服务器之间的字符集转换。

本地化支持是指一个应用程序遵守了有关字母、排序、数字格式等文化偏好。Greenplum Database使用服务器操作系统提供的标准ISO C和POSIX区域设置功能。相关更多信息,请参阅您的操作系统的文档。

初始化Greenplum数据库系统时,将自动初始化本地化支持。初始化工具gpinitsystem会默认使用其执行环境的本地化设置,来初始化Greenplum阵列,因此,如果您的系统已设置为使用Greenplum数据库系统中想要的语言环境,则无需执行其他操作。

当您准备启动Greenplum数据库并且想要使用其他的本地化(或者不确定系统所设置的本地化)时,可以通过指定-n 本地化选项,指示gpinitsystem确切地使用哪个本地化环境。例如:

$ gpinitsystem -c gp_init_config -n sv_SE

有关数据库初始化过程的信息,请参阅初始化Greenplum数据库系统

上面的示例将本地化设置为瑞典(SE)和瑞典语(sv)。其他的可能有en_US (美国英语)和 fr_CA (加拿大法语)。如果一个地区可以使用多个字符集,则说明如下所示:cs_CZ.ISO8859-2。系统上可用的本地化环境的名称,取决于操作系统供应商提供的内容和安装的内容。在大多数系统上,命令locale -a 将提供可用的本地化环境的列表。

有时,混用来自多个语言环境的规则很有用,例如,使用英语排序规则但使用西班牙语消息。为了支持这一点,存在一组本地化环境子类别,它只能控制本地化规则的某些方面:

  • LC_COLLATE ——字符串排序顺序
  • LC_CTYPE ——字符分类(什么是字母?等价的大写字母?)
  • LC_MESSAGES ——消息的语言
  • LC_MONETARY ——货币金额格式
  • LC_NUMERIC ——数字格式
  • LC_TIME ——日期和时间的格式

如果您希望系统与本地化环境无关,请使用特殊的本地化:C 或者 POSIX。

有一些本地化环境类别的性质是,它们的值必须在Greenplum数据库系统的整个生命周期内固定不变。即一旦gpinitsystem 已运行,您无法再更改它们。 LC_COLLATE 和 LC_CTYPE便是这些类别。它们影响索引的排序顺序,因此必须保持固定,否则文本列上的索引将损坏。Greenplum数据库通过记录gpinitsystem看见的LC_COLLATE 和 LC_CTYPE的值,来确保其固定不变。服务器根据初始化时选择的本地化环境,自动采用这两个值。

其他的本地化环境类别,可以在服务器运行时根据需要更改,方法是设置与本地化环境类别名称相同的服务器配置参数(有关设置服务器配置参数的更多信息,请参阅《Greenplum数据库参考指南》)。gpinitsystem选择的默认值被写入master和segment的配置文件postgresql.conf,以使得它们在启动Greenplum数据库系统时作为默认值。如果您从master和每个segment的postgresql.conf 文件中删除这些设置,则服务器将从其执行环境继承设置。

请注意,服务器的本地化环境行为是由服务器所看到的环境变量确定的,而不是由任何客户端的环境确定的。因此,在启动系统之前,请注意在每个Greenplum数据库主机(master服务器和segment服务器)上配置正确的本地化环境设置。这样的结果是,如果客户端和服务器设置为不同的本地化环境,则消息可能会以不同的语言显示,这具体取决于它们的来源。

在大多数操作系统上,从执行环境继承本地化环境,意味着:对于给定的本地化环境类别,例如排序,将按以下顺序查询以下环境变量,直到找到一个设置为止: LC_ALL, LC_COLLATE (对应于相应类别的变量), LANG。如果未设置这些环境变量,则区域设置默认为C。

一些消息的本地化库还会查看环境变量LANGUAGE,它会覆盖所有其他的本地化设置,来设置消息的语言。如有疑问,请参阅您操作系统的文档,尤其是gettext,来获取更多信息。

本机语言支持(NLS),它可将消息转换为用户的首选语言,在Greenplum数据库中对英语之外的其他语言,此功能未被启用。这独立于其他本地化环境支持。

本地化的行为

本地化环境设置会影响以下SQL功能:

  • 对文本数据使用ORDER BY查询后的排序
  • 在索引上使用Like 语句的能力
  • upper、lower、initcap 功能
  • to_char 功能族

在Greenplum数据库中,使用本地化环境而非C或POSIX的缺点是性能影响。它减慢了字符处理速度,并阻止了普通索引被用于LIKE。因此,仅在实际需要时才使用本地化环境。

本地化的故障排除

如果本地化设置支持无法按预期方式工作,请检查是否正确配置了操作系统中的区域设置支持。要检查系统上安装了哪些本地化环境,可以使用此命令locale -a(如果您的操作系统有提供)。

检查Greenplum数据库是否实际使用了您认为的本地化环境。 LC_COLLATE 和 LC_CTYPE 设置是在初始化时确定的,如果不重做 gpinitsystem,它们是无法更改的。其他区域设置包括 LC_MESSAGES 和 LC_MONETARY,初始化时由master和/或segment主机的操作系统环境确定,但可以在初始化后通过编辑每个Greenplum master和segment实例的文件postgresql.conf,来实现更改。您可以使用SHOW命令,来检查master主机当前使用的语言环境设置。请注意,Greenplum数据库阵列中的每个主机都应使用相同的本地化环境设置。

字符集支持

Greenplum数据库中的字符集支持您将文本存储为多种字符集,包括单字节字符集(例如ISO 8859系列)和多字节字符集(例如EUC(扩展的Unix代码),UTF-8,和Mule内部码。所有受支持的字符集均可被客户端透明地使用,不过有一些字符集是不支持在服务器内部使用的(即,作为服务器端编码)。使用Greenplum初始化数据库阵列时,将选择默认的字符集。创建数据库时可以覆盖它,因此可以有多个数据库,每个数据库都有不同的字符集。

表1. Greenplum数据库字符集
NameDescriptionLanguageServer?Bytes/CharAliases
BIG5Big FiveTraditional ChineseNo1-2WIN950, Windows950
EUC_CNExtended UNIX Code-CNSimplified ChineseYes1-3 
EUC_JPExtended UNIX Code-JPJapaneseYes1-3 
EUC_KRExtended UNIX Code-KRKoreanYes1-3 
EUC_TWExtended UNIX Code-TWTraditional Chinese, TaiwaneseYes1-3 
GB18030National StandardChineseNo1-2 
GBKExtended National StandardSimplified ChineseNo1-2WIN936, Windows936
ISO_8859_5ISO 8859-5, ECMA 113Latin/CyrillicYes1 
ISO_8859_6ISO 8859-6, ECMA 114Latin/ArabicYes1 
ISO_8859_7ISO 8859-7, ECMA 118Latin/GreekYes1 
ISO_8859_8ISO 8859-8, ECMA 121Latin/HebrewYes1 
JOHABJOHAKorean (Hangul)Yes1-3 
KOI8KOI8-R(U)CyrillicYes1KOI8R
LATIN1ISO 8859-1, ECMA 94Western EuropeanYes1ISO88591
LATIN2ISO 8859-2, ECMA 94Central EuropeanYes1ISO88592
LATIN3ISO 8859-3, ECMA 94South EuropeanYes1ISO88593
LATIN4ISO 8859-4, ECMA 94North EuropeanYes1ISO88594
LATIN5ISO 8859-9, ECMA 128TurkishYes1ISO88599
LATIN6ISO 8859-10, ECMA 144NordicYes1ISO885910
LATIN7ISO 8859-13BalticYes1ISO885913
LATIN8ISO 8859-14CelticYes1ISO885914
LATIN9ISO 8859-15LATIN1 with Euro and accentsYes1ISO885915
LATIN10ISO 8859-16, ASRO SR 14111RomanianYes1ISO885916
MULE_INTERNALMule internal codeMultilingual EmacsYes1-4 
SJISShift JISJapaneseNo1-2Mskanji, ShiftJIS, WIN932, Windows932
SQL_ASCIIunspecified2anyNo1 
UHCUnified Hangul CodeKoreanNo1-2WIN949, Windows949
UTF8Unicode, 8-bitallYes1-4Unicode
WIN866Windows CP866CyrillicYes1ALT
WIN874Windows CP874ThaiYes1 
WIN1250Windows CP1250Central EuropeanYes1 
WIN1251Windows CP1251CyrillicYes1WIN
WIN1252Windows CP1252Western EuropeanYes1 
WIN1253Windows CP1253GreekYes1 
WIN1254Windows CP1254TurkishYes1 
WIN1255Windows CP1255HebrewYes1 
WIN1256Windows CP1256ArabicYes1 
WIN1257Windows CP1257BalticYes1 
WIN1258Windows CP1258VietnameseYes1ABC, TCVN, TCVN5712, VSCII

设置字符集

gpinitsystem通过在初始化时读取 gp_init_config文件中ENCODING参数的设置,来定义Greenplum数据库系统的默认字符集。 默认字符集是 UNICODE 或 UTF8。

除了用作系统范围的默认字符集之外,还可以使用其他字符集创建数据库。例如:

=> CREATE DATABASE korean WITH ENCODING 'EUC_KR';
重要说明:尽管您可以为数据库指定所需的任何编码,但是选择与所选本地化环境所期望的编码不同的编码是不明智的。LC_COLLATE 和 LC_CTYPE 设置表示特定的编码,并且与本地化环境相关的操作(例如排序)可能会曲解那些使用了不兼容编码的数据。

由于这些本地化环境设置被gpinitsystem冻结,因此在不同数据库中使用不同编码,这种表面上的灵活性是理论意义大于实际意义。

安全使用多种编码的一种方法是,在初始化期间将本地化环境设置为C或者POSIX,从而禁用任何真实的本地化环境感知。

服务器和客户端之间的字符集转换

Greenplum数据库支持服务器和客户端之间针对某些字符集组合的自动字符集转换。转换信息存储在master的pg_conversion系统目录表。Greenplum数据库附带了一些预定义的转换,或者您可以使用SQL命令CREATE CONVERSION创建新的转换。

表 2. 客户端/服务器字符集转换
服务器字符集可用的客户端字符集
BIG5not supported as a server encoding
EUC_CNEUC_CN, MULE_INTERNAL, UTF8
EUC_JPEUC_JP, MULE_INTERNAL, SJIS, UTF8
EUC_KREUC_KR, MULE_INTERNAL, UTF8
EUC_TWEUC_TW, BIG5, MULE_INTERNAL, UTF8
GB18030not supported as a server encoding
GBKnot supported as a server encoding
ISO_8859_5ISO_8859_5, KOI8, MULE_INTERNAL, UTF8, WIN866, WIN1251
ISO_8859_6ISO_8859_6, UTF8
ISO_8859_7ISO_8859_7, UTF8
ISO_8859_8ISO_8859_8, UTF8
JOHABJOHAB, UTF8
KOI8KOI8, ISO_8859_5, MULE_INTERNAL, UTF8, WIN866, WIN1251
LATIN1LATIN1, MULE_INTERNAL, UTF8
LATIN2LATIN2, MULE_INTERNAL, UTF8, WIN1250
LATIN3LATIN3, MULE_INTERNAL, UTF8
LATIN4LATIN4, MULE_INTERNAL, UTF8
LATIN5LATIN5, UTF8
LATIN6LATIN6, UTF8
LATIN7LATIN7, UTF8
LATIN8LATIN8, UTF8
LATIN9LATIN9, UTF8
LATIN10LATIN10, UTF8
MULE_INTERNALMULE_INTERNAL, BIG5, EUC_CN, EUC_JP, EUC_KR, EUC_TW, ISO_8859_5, KOI8, LATIN1 to LATIN4, SJIS, WIN866, WIN1250, WIN1251
SJISnot supported as a server encoding
SQL_ASCIInot supported as a server encoding
UHCnot supported as a server encoding
UTF8all supported encodings
WIN866WIN866
ISO_8859_5KOI8, MULE_INTERNAL, UTF8, WIN1251
WIN874WIN874, UTF8
WIN1250WIN1250, LATIN2, MULE_INTERNAL, UTF8
WIN1251WIN1251, ISO_8859_5, KOI8, MULE_INTERNAL, UTF8, WIN866
WIN1252WIN1252, UTF8
WIN1253WIN1253, UTF8
WIN1254WIN1254, UTF8
WIN1255WIN1255, UTF8
WIN1256WIN1256, UTF8
WIN1257WIN1257, UTF8
WIN1258WIN1258, UTF8

要启用自动字符集转换,您必须告诉Greenplum数据库您要在客户端中使用的字符集(编码)。有几种方法可以实现此目的:

  • 在psql内使用 \encoding 命令 ,这使您可以即时更改客户端编码。
  • 使用 SET client_encoding TO。可以使用以下SQL命令来设置客户端编码:
    => SET CLIENT_ENCODING TO 'value';

    要查询当前的客户端编码:

    => SHOW client_encoding;

    要返回默认编码:

    => RESET client_encoding;
  • 使用环境变量PGCLIENTENCODING 。当PGCLIENTENCODING 在客户端环境中定义后,在与服务器建立连接时会自动选择客户端编码。(随后可以使用上述任何其他方法来覆盖客户端编码。)
  • 设置配置参数 client_encoding。如果 client_encoding 在master的postgresql.conf 文件中有设置,则当与Greenplum数据库建立连接时,将自动选择客户端编码。(随后可以使用上述任何其他方法来覆盖客户端编码。)

如果无法转换特定字符——假设您选择了 EUC_JP 用于服务器和 LATIN1 用于客户端,则某些日语字符在LATIN1无法表示 ——然后报告错误。

如果客户端字符集定义为 SQL_ASCII,无论服务器的字符集如何,都将禁用编码转换。除非您使用全ASCII数据,否则使用SQL_ASCII 是不明智的。 SQL_ASCII 不支持作为服务器编码。

1 并非所有的API都支持所有列出的字符集。例如,JDBC驱动程序不支持MULE_INTERNAL,LATIN6,LATIN8和LATIN10。
2 SQL_ASCII设置的行为与其他设置大不相同。字节值0-127根据ASCII标准进行解释,而字节值128-255被视为不可解释的字符。如果要处理任何非ASCII数据,将SQL_ASCII设置用作客户端编码是不明智的。不支持将SQL_ASCII作为服务器编码。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
greenplum-db-6.2.1-rhel7-x86_64.rpm Pivotal Greenplum 6.2 Release Notes This document contains pertinent release information about Pivotal Greenplum Database 6.2 releases. For previous versions of the release notes for Greenplum Database, go to Pivotal Greenplum Database Documentation. For information about Greenplum Database end of life, see Pivotal Greenplum Database end of life policy. Pivotal Greenplum 6 software is available for download from the Pivotal Greenplum page on Pivotal Network. Pivotal Greenplum 6 is based on the open source Greenplum Database project code. Important: Pivotal Support does not provide support for open source versions of Greenplum Database. Only Pivotal Greenplum Database is supported by Pivotal Support. Release 6.2.1 Release Date: 2019-12-12 Pivotal Greenplum 6.2.1 is a minor release that includes new features and resolves several issues. New Features Greenplum Database 6.2.1 includes these new features: Greenplum Database supports materialized views. Materialized views are similar to views. A materialized view enables you to save a frequently used or complex query, then access the query results in a SELECT statement as if they were a table. Materialized views persist the query results in a table-like form. Materialized view data cannot be directly updated. To refresh the materialized view data, use the REFRESH MATERIALIZED VIEW command. See Creating and Managing Materialized Views. Note: Known Issues and Limitations describes a limitation of materialized view support in Greenplum 6.2.1. The gpinitsystem utility supports the --ignore-warnings option. The option controls the value returned by gpinitsystem when warnings or an error occurs. If you specify this option, gpinitsystem returns 0 if warnings occurred during system initialization, and returns a non-zero value if a fatal error occurs. If this option is not specified, gpinitsystem returns 1 if initialization completes with warnings, and returns value of 2 or greater if a fatal error occurs. PXF version 5.10.0 is included, which introduces several new and changed features and bug fixes. See PXF Version 5.10.0 below. PXF Version 5.10.0 PXF 5.10.0 includes the following new and changed features: PXF has improved its performance when reading a large number of files from HDFS or an object store. PXF bundles newer tomcat and jackson libraries. The PXF JDBC Connector now supports pushdown of OR and NOT logical filter operators when specified in a JDBC named query or in an external table query filter condition. PXF supports writing Avro-format data to Hadoop and object stores. Refer to Reading and Writing HDFS Avro Data for more information about this feature. PXF is now certified with Hadoop 2.x and 3.1.x and Hive Server 2.x and 3.1, and bundles new and upgraded Hadoop libraries to support these versions. PXF supports Kerberos authentication to Hive Server 2.x and 3.1.x. PXF supports per-server user impersonation configuration. PXF supports concurrent access to multiple Kerberized Hadoop clusters. In previous releases of Greenplum Database, PXF supported accessing a single Hadoop cluster secured with Kerberos, and this Hadoop cluster must have been configured as the default PXF server. PXF introduces a new template file, pxf-site.xml, to specify the Kerberos and impersonation property settings for a Hadoop or JDBC server configuration. Refer to About Kerberos and User Impersonation Configuration (pxf-site.xml) for more information about this file. PXF now supports connecting to Hadoop with a configurable Hadoop user identity. PXF previously supported only proxy access to Hadoop via the gpadmin Greenplum user. PXF version 5.10.0 deprecates the following configuration properties. Note: These property settings continue to work. The PXF_USER_IMPERSONATION, PXF_PRINCIPAL, and PXF_KEYTAB settings in the pxf-env.sh file. You can use the pxf-site.xml file to configure Kerberos and impersonation settings for your new Hadoop server configurations. The pxf.impersonation.jdbc property setting in the jdbc-site.xml file. You can use the pxf.service.user.impersonation property to configure user impersonation for a new JDBC server configuration. Note: If you have previously configured a PXF JDBC server to access Kerberos-secured Hive, you must upgrade the server definition. See Upgrading PXF in Greenplum 6.x for more information. Changed Features Greenplum Database 6.2.1 includes these changed features: Greenplum Stream Server version 1.3.1 is included in the Greenplum distribution. Resolved Issues Pivotal Greenplum 6.2.1 is a minor release that resolves these issues: 29454 - gpstart During Greenplum Database start up, the gpstart utility did not report when a segment instance failed to start. The utility always displayed 0 skipped segment starts. This issue has been resolved. gpstart output was also enhanced to provide additional warnings and summary information about the number of skipped segments. For example: [WARNING]:-********

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值