当前位置:   article > 正文

KingbaseES V8R6集群部署案例---指定数据库字符集脚本部署

kingbase 字符集

案例说明:
KingbaseES V8R6集群通过脚本部署,默认字符集是utf-8,可以通过修改部署配置参数支持其他类型的字符集。适用版本: KingbaseES V8R6

一、部署故障案例
1、在执行部署脚本时出现以下故障:

2、查看install.conf配置

3、查看系统字符集

  1. [kingbase@node101 r6_install]$ locale
  2. LANG=en_US.UTF-8
  3. LC_CTYPE="en_US.UTF-8"
  4. LC_NUMERIC="en_US.UTF-8"
  5. LC_TIME="en_US.UTF-8"
  6. LC_COLLATE="en_US.UTF-8"
  7. LC_MONETARY="en_US.UTF-8"
  8. LC_MESSAGES="en_US.UTF-8"
  9. LC_PAPER="en_US.UTF-8"
  10. LC_NAME="en_US.UTF-8"
  11. LC_ADDRESS="en_US.UTF-8"
  12. LC_TELEPHONE="en_US.UTF-8"
  13. LC_MEASUREMENT="en_US.UTF-8"
  14. LC_IDENTIFICATION="en_US.UTF-8"
  15. LC_ALL=

从以上内容可以获悉,部署时指定的字符集‘gbk’和目前系统的字符集‘utf8’不兼容,导致部署失败。

二、配置系统字符集
1、修改字符集配置文件

  1. [kingbase@node101 r6_install]$ cat /etc/locale.conf
  2. LANG="zh_CN.gbk"

2、重启系统后查看字符集

如下所示,系统字符集为gbk:

  1. [root@node101 ~]# locale
  2. LANG=zh_CN.gbk
  3. LC_CTYPE="zh_CN.gbk"
  4. LC_NUMERIC="zh_CN.gbk"
  5. LC_TIME="zh_CN.gbk"
  6. LC_COLLATE="zh_CN.gbk"
  7. LC_MONETARY="zh_CN.gbk"
  8. LC_MESSAGES="zh_CN.gbk"
  9. LC_PAPER="zh_CN.gbk"
  10. LC_NAME="zh_CN.gbk"
  11. LC_ADDRESS="zh_CN.gbk"
  12. LC_TELEPHONE="zh_CN.gbk"
  13. LC_MEASUREMENT="zh_CN.gbk"
  14. LC_IDENTIFICATION="zh_CN.gbk"
  15. LC_ALL=

三、部署集群
1、配置install.conf

  1. [kingbase@node101 r6_install]$ cat install.conf
  2. [install]
  3. ......
  4. 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.
  5. 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.
  6. db_ctype=""
  7. ......

2、执行脚本部署

  1. [kingbase@node101 r6_install]$ sh cluster_install.sh
  2. [CONFIG_CHECK] will deploy the cluster of DG
  3. [CONFIG_CHECK] checking db_encoding:gbk exists on 192.168.1.101 ....OK
  4. [CONFIG_CHECK] checking db_encoding:gbk exists on 192.168.1.102 ....OK
  5. [CONFIG_CHECK] checking db_encoding:gbk ...
  6. [CONFIG_CHECK] checking db_encoding:gbk,utf-8 should be set as utf8 ...OK
  7. [CONFIG_CHECK] comparing gbk with gbk ...
  8. [CONFIG_CHECK] comparing gbk with gbk ...OK
  9. [CONFIG_CHECK] comparing gbk with gbk ...
  10. [CONFIG_CHECK] comparing gbk with gbk ...OK
  11. ........
  12. 2023-08-16 11:56:29 repmgrd on "[192.168.1.102]" start success.
  13. ID | Name | Role | Status | Upstream | repmgrd | PID | Paused? | Upstream last seen
  14. ----+-------+---------+-----------+----------+---------+-------+---------+--------------------
  15. 1 | node1 | primary | * running | | running | 10374 | no | n/a
  16. 2 | node2 | standby | running | node1 | running | 8825 | no | 1 second(s) ago
  17. [2023-08-16 11:56:30] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/ha/kingbase/log/kbha.log"
  18. [2023-08-16 11:56:32] [NOTICE] redirecting logging output to "/home/kingbase/cluster/R6HA/ha/kingbase/log/kbha.log"
  19. 2023-08-16 11:56:34 Done.
  20. [INSTALL] start up the whole cluster ... OK

3、查看数据库字符集

  1. test=# show server_encoding ;
  2. server_encoding
  3. -----------------
  4. GBK
  5. (1 row)
  6. test=# \l+
  7. List of databases
  8. Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description
  9. -----------+--------+----------+-------------+-------------+-------------------+--------+-------------+------------------------------------
  10. esrep | system | GBK | zh_CN.gbk | zh_CN.gbk | | 13 MB | sys_default |
  11. kingbase | system | GBK | zh_CN.gbk | zh_CN.gbk | | 13 MB | sys_default | default administrative connection database
  12. security | system | GBK | zh_CN.gbk | zh_CN.gbk | | 13 MB | sys_default |
  13. template0 | system | GBK | zh_CN.gbk | zh_CN.gbk | =c/system +| 13 MB | sys_default | unmodifiable empty database
  14. | | | | | system=CTc/system | | |
  15. template1 | system | GBK | zh_CN.gbk | zh_CN.gbk | =c/system +| 13 MB | sys_default | default template for new databases
  16. | | | | | system=CTc/system | | |
  17. test | system | GBK | zh_CN.gbk | zh_CN.gbk | | 13 MB | sys_default | default administrative connection database
  18. (6 rows)

四、总结
KingbaseES V8R6集群部署支持utf-8、gbk等字符集,在通过脚本部署时,注意配置文件只当的字符集需要和系统的字符集匹配。
完整的脚本部署集群参考:https://www.cnblogs.com/tiany1224/p/16304701.html

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/码创造者/article/detail/980356
推荐阅读
相关标签
  

闽ICP备14008679号