KingbaseES V8R6集群部署案例---指定数据库字符集脚本部署
案例说明:
KingbaseES V8R6集群通过脚本部署,默认字符集是utf-8,可以通过修改部署配置参数支持其他类型的字符集。
适用版本:
KingbaseES V8R6
一、部署故障案例
1、在执行部署脚本时出现以下故障:
2、查看install.conf配置
3、查看系统字符集
[kingbase@node101 r6_install]$ locale
LANG=en_US.UTF-8
LC_CTYPE="en_US.UTF-8"
LC_NUMERIC="en_US.UTF-8"
LC_TIME="en_US.UTF-8"
LC_COLLATE="en_US.UTF-8"
LC_MONETARY="en_US.UTF-8"
LC_MESSAGES="en_US.UTF-8"
LC_PAPER="en_US.UTF-8"
LC_NAME="en_US.UTF-8"
LC_ADDRESS="en_US.UTF-8"
LC_TELEPHONE="en_US.UTF-8"
LC_MEASUREMENT="en_US.UTF-8"
LC_IDENTIFICATION="en_US.UTF-8"
LC_ALL=
从以上内容可以获悉,部署时指定的字符集‘gbk’和目前系统的字符集‘utf8’不兼容,导致部署失败。
二、配置系统字符集
1、修改字符集配置文件
[kingbase@node101 r6_install]$ cat /etc/locale.conf
LANG="zh_CN.gbk"
2、重启系统后查看字符集
如下所示,系统字符集为gbk:
[root@node101 ~]# locale
LANG=zh_CN.gbk
LC_CTYPE="zh_CN.gbk"
LC_NUMERIC="zh_CN.gbk"
LC_TIME="zh_CN.gbk"
LC_COLLATE="zh_CN.gbk"
LC_MONETARY="zh_CN.gbk"
LC_MESSAGES="zh_CN.gbk"
LC_PAPER="zh_CN.gbk"
LC_NAME="zh_CN.gbk"
LC_ADDRESS="zh_CN.gbk"
LC_TELEPHONE="zh_CN.gbk"
LC_MEASUREMENT="zh_CN.gbk"
LC_IDENTIFICATION="zh_CN.gbk"
LC_ALL=
三、部署集群
1、配置install.conf
[kingbase@node101 r6_install]$ cat install.conf
[install]
......
db_encoding="gbk" # Cararcter set encoding to use in the new database.Specify a tring constant,or an integer encoding number, default value provided by locale command.
db_collate="" # Collation order(LC_COLLATE) to use in the new database,This affects the sort order applied to strings, default value provided by locale command.
db_ctype=""
......
2、执行脚本部署
[kingbase@node101 r6_install]$ sh cluster_install.sh
[CONFIG_CHECK] will deploy the cluster of DG
[CONFIG_CHECK] checking db_encoding:gbk exists on 192.168.1.101 ....OK
[CONFIG_CHECK] checking db_encoding:gbk exists on 192.168.1.102 ....OK
[CONFIG_CHECK] checking db_encoding:gbk ...
[CONFIG_CHECK] checking db_encoding:gbk,utf-8 should be set as utf8 ...OK
[CONFIG_CHECK] comparing gbk with gbk ...
[CONFIG_CHECK] comparing gbk with gbk ...OK
[CONFIG_CHECK] comparing gbk with gbk ...
[CONFIG_CHECK] comparing gbk with gbk ...OK
........
2023-08-16 11:56:29 repmgrd on "[192.168.1.102]" start success.
ID | Name | Role | Status | Upstream | repmgrd | PID | Paused? | Upstream last seen
----+-------+---------+-----------+----------+---------+-------+---------+--------------------
1 | node1 | primary | * running | | running | 10374 | no | n/a
2 | node2 | standby | running | node1 | running | 8825 | no | 1 second(s) ago
[2023-08-16 11:56:30] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/ha/kingbase/log/kbha.log"
[2023-08-16 11:56:32] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/ha/kingbase/log/kbha.log"
2023-08-16 11:56:34 Done.
[INSTALL] start up the whole cluster ... OK
3、查看数据库字符集
test=# show server_encoding ;
server_encoding
-----------------
GBK
(1 row)
test=# \l+
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description
-----------+--------+----------+-------------+-------------+-------------------+--------+-------------+------------------------------------
esrep | system | GBK | zh_CN.gbk | zh_CN.gbk | | 13 MB | sys_default |
kingbase | system | GBK | zh_CN.gbk | zh_CN.gbk | | 13 MB | sys_default | default administrative connection database
security | system | GBK | zh_CN.gbk | zh_CN.gbk | | 13 MB | sys_default |
template0 | system | GBK | zh_CN.gbk | zh_CN.gbk | =c/system +| 13 MB | sys_default | unmodifiable empty database
| | | | | system=CTc/system | | |
template1 | system | GBK | zh_CN.gbk | zh_CN.gbk | =c/system +| 13 MB | sys_default | default template for new databases
| | | | | system=CTc/system | | |
test | system | GBK | zh_CN.gbk | zh_CN.gbk | | 13 MB | sys_default | default administrative connection database
(6 rows)
四、总结
KingbaseES V8R6集群部署支持utf-8、gbk等字符集,在通过脚本部署时,注意配置文件只当的字符集需要和系统的字符集匹配。
完整的脚本部署集群参考:https://www.cnblogs.com/tiany1224/p/16304701.html
KINGBASE研究院