GBase 8a集群能安装在中文目录下吗?

Linux支持中文目录,在计算机内部都是按字节处理的,中文是给人眼睛看的。但由于中文有各种编码类型,所以同样的中文内容,由于编码不同,字节也不同。所以原则上,GBase 8a是能安装在中文目录下并能正常使用的,但为了避免用户编码导致的使用问题,在代码里做了检测。但这部分代码,可以手工屏蔽,但风险也自行承担。

本文全部是UTF8编码,包括Linux 远程 , ssh客户端。

创建中文安装目录

[gbase@gbase_rh7_003 gcinstall]$ echo $LANG
en_US.UTF-8
[root@gbase_rh7_003 ~]# mkdir /opt/南大通用
[root@gbase_rh7_003 ~]# chown gbase:gbase /opt/南大通用

编写安装配置文件

其中的installPrefix配置成了中文目录

[gbase@gbase_rh7_003 gcinstall]$ cat demo.options
installPrefix= /opt/南大通用
coordinateHost = 10.0.2.103,10.0.2.104
coordinateHostNodeID = 234,235,237
dataHost = 10.0.2.103,10.0.2.104
#existCoordinateHost =
#existDataHost =
#existGcwareHost=
gcwareHost = 10.0.2.103,10.0.2.104
gcwareHostNodeID = 234,235,237
dbaUser = gbase
dbaGroup = gbase
dbaPwd = 'gbase1234'
rootPwd = ''
#dbaHome =
#numaCpuBind=''
#numaMemBind=''
#numaHddBind=''
#dbRootPwd = ''
#rootPwdFile = rootPwd.json
#characterSet = utf8
sshPort = 2222
#genDBUser=gbase
#genDBPwd=GBase2O11O531
[gbase@gbase_rh7_003 gcinstall]$

直接安装会报错

安装脚本里检测了,必须是数字,字母和一些特殊符号。

[gbase@gbase_rh7_003 gcinstall]$ ./gcinstall.py --silent=demo.options -a
Error: gcinstall.py(line 3898) -- installPrefix can only include digit,alpha,and character in [_,-,/],                     input installPrefix /opt/南大通用 include illegal character ▒
[gbase@gbase_rh7_003 gcinstall]$

手工调整安装脚本

编辑gcinstall.py, 搜索前面报错的关键字"installPrefix can only include digit"

将如下几行检测代码全部注释掉。


#    for c in Options.installPrefix:
#        if (not c.isalnum()) and (c not in ["-","_"," ","/"]):
#            raise InstallError("installPrefix can only include digit,alpha,and character in [_,-,/], \
#                    input installPrefix %s include illegal character %c" % (Options.installPrefix,c))

再次安装

安装成功,支持中文路径

10.0.2.104              Copying rmt.py to host 10.0.2.104:/opt/南大通用/10.0.2.104/cluster_prepare
10.0.2.103              Copying rmt.py to host 10.0.2.103:/opt/南大通用/10.0.2.103/cluster_prepare


。。。

10.0.2.104              install gcware and cluster on host 10.0.2.104 successfully.
10.0.2.103              install gcware and cluster on host 10.0.2.103 successfully.
Starting all gcluster nodes ...
adding new datanodes to gcware ...
InstallCluster Successfully
[gbase@gbase_rh7_003 gcinstall]$
[gbase@gbase_rh7_003 gcinstall]$ source ~/.gbase_profile
[gbase@gbase_rh7_003 gcinstall]$ gcadmin
CLUSTER STATE:         ACTIVE

====================================
| GBASE GCWARE CLUSTER INFORMATION |
====================================
| NodeName |  IpAddress   | gcware |
------------------------------------
| gcware1  |  10.0.2.103  |  OPEN  |
------------------------------------
| gcware2  |  10.0.2.104  |  OPEN  |
------------------------------------
====================================================
|      GBASE COORDINATOR CLUSTER INFORMATION       |
====================================================
|   NodeName   | IpAddress  | gcluster | DataState |
----------------------------------------------------
| coordinator1 | 10.0.2.103 |   OPEN   |     0     |
----------------------------------------------------
| coordinator2 | 10.0.2.104 |   OPEN   |     0     |
----------------------------------------------------
===========================================================
|        GBASE CLUSTER FREE DATA NODE INFORMATION         |
===========================================================
| NodeName  | IpAddress  | gnode | syncserver | DataState |
-----------------------------------------------------------
| FreeNode1 | 10.0.2.104 | OPEN  |    OPEN    |     0     |
-----------------------------------------------------------
| FreeNode2 | 10.0.2.103 | OPEN  |    OPEN    |     0     |
-----------------------------------------------------------

0 virtual cluster
2 coordinator node
2 free data node

初始化成功

[gbase@gbase_rh7_003 gcinstall]$ gcadmin distribution gcChangeInfo.xml p 1 d 1
gcadmin generate distribution ...

NOTE: node [10.0.2.104] is coordinator node, it shall be data node too
NOTE: node [10.0.2.103] is coordinator node, it shall be data node too
gcadmin generate distribution successful

[gbase@gbase_rh7_003 gcinstall]$ gccli
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
[gbase@gbase_rh7_003 gcinstall]$ gccli -pXXXXXXXXX

GBase client 9.5.3.28.18.r1_patch.8cdf32c2. Copyright (c) 2004-2025, GBase.  All Rights Reserved.

gbase> initnodedatamap;
Query OK, 1 row affected (Elapsed: 00:00:00.67)

建库建表正常


gbase> create database testdb;
Query OK, 1 row affected (Elapsed: 00:00:00.02)

gbase> use testdb;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)

gbase> create table td as select now() d from dual;
Query OK, 1 row affected (Elapsed: 00:00:00.29)

gbase> select * from td;
+---------------------+
| d                   |
+---------------------+
| 2025-04-01 13:22:11 |
+---------------------+
1 row in set (Elapsed: 00:00:00.02)

gbase> exit
Bye

服务启停正常



[gbase@gbase_rh7_003 gcinstall]$ gcluster_services all stop
Stopping gcrecover :                                       [  OK  ]
Stopping gcluster :                                        [  OK  ]
Stopping gbase :                                           [  OK  ]
Stopping syncserver :                                      [  OK  ]
[gbase@gbase_rh7_003 gcinstall]$ gcware_services all stop
Stopping GCWareMonit success!
Stopping gcware :                                          [  OK  ]
[gbase@gbase_rh7_003 gcinstall]$ ps -ef|grep gbase
avahi      585     1  0 Mar31 ?        00:00:00 avahi-daemon: running [gbaserh7003.local]
root     13281 27690  0 13:16 pts/0    00:00:00 su - gbase
gbase    13282 13281  0 13:16 pts/0    00:00:00 -bash
gbase    18460 13282  0 13:24 pts/0    00:00:00 ps -ef
gbase    18461 13282  0 13:24 pts/0    00:00:00 grep --color=auto gbase
root     24681 19382  0 Mar31 pts/1    00:00:00 su - gbase
gbase    24682 24681  0 Mar31 pts/1    00:00:00 -bash
[gbase@gbase_rh7_003 gcinstall]$ gcluster_services all start
Starting gbase :
[  OK  ]
Starting syncserver :
[  OK  ]
Starting gcluster :
[  OK  ]
Starting gcrecover :
[  OK  ]
[gbase@gbase_rh7_003 gcinstall]$ gcware_services all start
Starting gcware :                                          [  OK  ]
Starting GCWareMonit success!
[gbase@gbase_rh7_003 gcinstall]$ gcadmin
CLUSTER STATE:         ACTIVE
VIRTUAL CLUSTER MODE:  NORMAL

====================================
| GBASE GCWARE CLUSTER INFORMATION |
====================================
| NodeName |  IpAddress   | gcware |
------------------------------------
| gcware1  |  10.0.2.103  |  OPEN  |
------------------------------------
| gcware2  |  10.0.2.104  |  OPEN  |
------------------------------------
====================================================
|      GBASE COORDINATOR CLUSTER INFORMATION       |
====================================================
|   NodeName   | IpAddress  | gcluster | DataState |
----------------------------------------------------
| coordinator1 | 10.0.2.103 |   OPEN   |     0     |
----------------------------------------------------
| coordinator2 | 10.0.2.104 |   OPEN   |     0     |
----------------------------------------------------
=========================================================================================================
|                                    GBASE DATA CLUSTER INFORMATION                                     |
=========================================================================================================
| NodeName |                IpAddress                 | DistributionId | gnode | syncserver | DataState |
---------------------------------------------------------------------------------------------------------
|  node1   |                10.0.2.104                |       1        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------
|  node2   |                10.0.2.103                |       1        | OPEN  |    OPEN    |     0     |
---------------------------------------------------------------------------------------------------------

总结

为了避免中文编码问题导致使用出现问题,在安装脚本里对安装目录做了检测。但从实际结果看,GBase 8a集群可以在中文目录下正常安装和使用,但一定要注意中文编码问题。 建议全部同UTF8, 包括客户端,文本编辑器等可能涉及到安装目录的。