暂无图片
暂无图片
2
暂无图片
暂无图片
暂无图片

【金仓数据库征文】_金仓 KES V9最新版安装体验

原创 听见风的声音 2025-06-16
324

1 介绍

国产数据库里,金仓数据库也算是比较早的了,中电科金仓(北京)科技股份有限公司(以下简称“电科金仓”)成立于1999年,次年就发布了KingbaseES1.0版本,目前最新的版本是2024年发布的KingbaseV9,这个版本的发布历史如下

版本号 发布日期
V009R001C002B0014 2024-10-30
V009R001C001B0030 2024-6-19
V009R001C001B0025 2023-11-4

最新版本继续完善MySQL/Oracle模式兼容,注重功能和可用性提升,分别对MySQL/Oracle模式下数据类型、函数、语法等进一步兼容优化,新增OLEDB接口相关功能并不断增强JDBC、ODBC和.DCI等各种客户端编程接口及框架能力,提高开发人员代码开发的效率。优化软件安装配置,提供自适应配置功能,提升产品易用性,完善集群部署、管理、故障转移恢复和增强备份还原能力,提升产品可用性。深度优化产品内核处理及语句转换机制,支持精准问题诊断和性能调优,实现性能稳定提升,加强访问控制策略和审计功能,强化产品安全措施,确保为用户提供稳定、可靠和安全的数据库产品。
这次安装体验选择最新的版本V009R001C002B0014,操作系统使用Ubuntu 最新版本24.04。

2 安装前准备

2.1 安装环境

2.1.1 主机配置

root@dbsrv:~# lshw -short|grep -E 'processor|memory|volume' /0/1 memory 11GiB System memory /0/2 processor Intel(R) Xeon(R) CPU E5-2680 v2 @ 2.80GHz /0/100/d/0.0.0/2 /dev/sda2 volume 119GiB EXT4 volume

2.1.2 操作系统版本

root@dbsrv:/tmp# cat /etc/os-release PRETTY_NAME="Ubuntu 24.04.2 LTS" NAME="Ubuntu" VERSION_ID="24.04" VERSION="24.04.2 LTS (Noble Numbat)" VERSION_CODENAME=noble ID=ubuntu ID_LIKE=debian HOME_URL="https://www.ubuntu.com/" SUPPORT_URL="https://help.ubuntu.com/" BUG_REPORT_URL="https://bugs.launchpad.net/ubuntu/" PRIVACY_POLICY_URL="https://www.ubuntu.com/legal/terms-and-policies/privacy-policy" UBUNTU_CODENAME=noble LOGO=ubuntu-logo
2.2 准备安装介质

2.2.1 下载安装介质
官网最新版下载地址在这里

2.2.2 mount安装介质
将下载后的ISO映像安装包挂载到虚拟机上,然后切换到root用户操作

root@dbsrv:~# lsblk NAME MAJ:MIN RM SIZE RO TYPE MOUNTPOINTS sda 8:0 0 120G 0 disk ├─sda1 8:1 0 1M 0 part └─sda2 8:2 0 120G 0 part / sr0 11:0 1 2.5G 0 rom root@dbsrv:~# cd /tmp root@dbsrv:/tmp# mkdir KingbaseESV root@dbsrv:/tmp# mount /dev/sr0 /tmp/KingbaseESV mount: /tmp/KingbaseESV: WARNING: source write-protected, mounted read-only. root@dbsrv:/tmp# ls -l total 34 dr-xr-xr-x 3 root root 2048 Sep 23 2024 KingbaseESV drwx------ 2 root root 4096 Jun 14 08:56 snap-private-tmp drwx------ 3 root root 4096 Jun 14 09:59 systemd-private-e70d2d7f1efe4fa9b2a57fa52b6a9228-fwupd.service-svv78g drwx------ 3 root root 4096 Jun 14 08:56 systemd-private-e70d2d7f1efe4fa9b2a57fa52b6a9228-ModemManager.service-7L35zw drwx------ 3 root root 4096 Jun 14 08:56 systemd-private-e70d2d7f1efe4fa9b2a57fa52b6a9228-polkit.service-LmS4yQ drwx------ 3 root root 4096 Jun 14 08:56 systemd-private-e70d2d7f1efe4fa9b2a57fa52b6a9228-systemd-logind.service-EweVKU drwx------ 3 root root 4096 Jun 14 08:56 systemd-private-e70d2d7f1efe4fa9b2a57fa52b6a9228-systemd-resolved.service-xWw9Bf drwx------ 3 root root 4096 Jun 14 08:56 systemd-private-e70d2d7f1efe4fa9b2a57fa52b6a9228-systemd-timesyncd.service-iFWo2T drwx------ 3 root root 4096 Jun 14 09:59 systemd-private-e70d2d7f1efe4fa9b2a57fa52b6a9228-upower.service-I2uBih
2.3 预安装工作

2.3.1 配置内核参数
编辑/etc/sysctl.conf文件,根据下面文件更改相关参数,改完后激活

fs.aio-max-nr= 1048576 ## 本参数限制并发发出的请求数量。应该设置以避免IO 子系统的失败。 fs.file-max= 6815744 kernel.shmall= 2097152 kernel.shmmax= 4294967295 ## 最小: 536870912最大: 物理内存值减去1字节 建议: 大于物理内存的一半 kernel.shmmni= 4096 kernel.sem= 250 32000 100 128 net.ipv4.ip_local_port_range= 9000 65500 net.core.rmem_default= 262144 net.core.rmem_max= 4194304 net.core.wmem_default= 262144 net.core.wmem_max= 1048576

资源使用参数,编辑etc/security/limits.conf,加入以下条目,删除以前相同设置

# *表示所有用户,可只设置root和kingbase用户 * soft nofile 65536 # 注意:设置nofile的hard limit不能大于/proc/sys/fs/nr_open,否则注销后将无法正常登陆 * hard nofile 65535 * soft nproc 65536 * hard nproc 65535 # unlimited表示无限制 * soft core unlimited * hard core unlimited

2.3.2 创建数据库用户

root@dbsrv:~# useradd -m kingbase root@dbsrv:~# passwd kingbase New password: Retype new password: passwd: password updated successfully

2.3.3 创建安装目录

root@dbsrv:~# mkdir -p /opt/Kingbase/ES/V9 root@dbsrv:~# chmod o+rwx /opt/Kingbase/ES/V9

这个步骤是严格按照安装文档执行的,可是在后面安装的过程中却出了问题,

3 安装数据库

3.1 检查设置安装语言
$ echo $LANG en_US.UTF-8 $ export LANG=zh_CN.UTF-8
3.2 启动安装程序
$ pwd /tmp/KingbaseESV $ sh setup.sh -i console ##### 3.3 根据提示安装 ```bash ##前面是license等,一路回车即可 Where would you like to install? Default Install Folder: /opt/Kingbase/ES/V9 ENTER AN ABSOLUTE PATH, OR PRESS <ENTER> TO ACCEPT THE DEFAULT : You do not have write permissions to the chosen installation destination. Please choose a different location for installation ## 在另一个窗口,登入到root用户,运行下面的命令 root@dbsrv:~# chown -R kingbase /opt/Kingbase/ES/V9 ## 回到原来的窗口继续 Install Folder: /opt/Kingbase/ES/V9 Product Features: SERVER, INTERFACE, DEPLOY, KINGBASEHA, KSTUDIO, KDTS Install Disk Space Information Require Disk space : 5378 MB Free Disk Space : MB Please choose a folder. The folder must be empty. ##数据目录可以不指定,如指定必须为空目录 Data folder (Default: /opt/Kingbase/ES/V9/data): Please enter database service listened port, default 54321.## 指定数据库监听端口 Port (Default: 54321): =============================================================================== User ---- Please enter database administrator user name. User (Default: system): Please enter database administrator user name. User (Default: system): =============================================================================== Enter Password -------------- Please Enter the Password: Please Enter the Password:******* =============================================================================== Enter Password again -------------------- Please Enter the Password Again: Please Enter the Password Again:******* =============================================================================== Server Encoding --------------- Please enter server character set encoding. 1- default ->2- UTF8 3- GBK 4- GB2312 5- GB18030 Locale ------ Please enter the Database Locale. 1- C ->2- zh_CN.UTF-8 3- en_US.UTF-8 ERROR ----- Locale not supported by the OS, please select another one. PRESS <ENTER> TO CONTINUE: ## 另开一个窗口 vboxuser@dbsrv:~$ sudo locale -a C C.utf8 en_US.utf8 POSIX ## 当前的操作系统没有支持的本地化设置只有四个,并且没有中文支持,先选择英文安装 Please enter the Database Locale. 1- C ->2- zh_CN.UTF-8 3- en_US.UTF-8 ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT:3 =============================================================================== lease enter database mode. 1- PG ->2- ORACLE 3- MySQL ENTER THE NUMBER FOR YOUR CHOICE, OR PRESS <ENTER> TO ACCEPT THE DEFAULT: =============================================================================== Case Sensitivity ---------------- Please enter the case sensitivity. ->1- YES Block Size ---------- Please enter block size used in storing data. ->1- 8k 2- 16k 3- 32k Please enter the authentication method. ->1- scram-sha-256 2- scram-sm3 3- sm4 4- sm3 Custom ------ Please enter database custom parameters. Custom (Default: ): Tips ---- The database will be initialized, which may take some time. Please be patient. Installation Complete --------------------- Congratulations. KingbaseES V9 has been successfully installed to: /opt/Kingbase/ES/V9 If you want to register KingbaseES V9 as OS service, please run /opt/Kingbase/ES/V9/install/script/root.sh root@dbsrv:/tmp# /opt/Kingbase/ES/V9/install/script/root.sh

4 安装后检查

4.1 查看安装日志

安装完成后,要检查安装是否成功,安装过程有无报错,就要查看安装日志。安装日志位于目录/opt/Kingbase/ES/V9/install/Logs下,文件名为KingbaseES_V9_Install_06_14_2025_02_30_12.log,记录了安装的整个过程,下面是这个文件的部分内容

Installed by InstallAnywhere 21.0 Premier Build 6597 User Interactions ----------------- #Choose Install Set #------------------ CHOSEN_FEATURE_LIST=SERVER,INTERFACE,DEPLOY,KINGBASEHA,KSTUDIO,KDTS CHOSEN_INSTALL_FEATURE_LIST=SERVER,INTERFACE,DEPLOY,KINGBASEHA,KSTUDIO,KDTS CHOSEN_INSTALL_SET=Full #Choose Install Folder #--------------------- USER_INSTALL_DIR=/opt/Kingbase/ES/V9 Installation: Successful with errors. Summary ------- 13939 Successes 0 Warnings 2 NonFatalErrors 0 FatalErrors Action Notes: None

安装虽然成功了,但是有两个非致命的报错。在Install Log Detail:部分可以看到这两个错误

Execute Script/Batch file: Other files Status: SUCCESSFUL Custom Action: com.kingbase.iacustom.plugin.trimspace.TrimVariableAction Status: SUCCESSFUL Custom Action: com.kingbase.iacustom.plugin.checkfolder.CheckFolderAction Status: SUCCESSFUL Custom Action: com.kingbase.iacustom.plugin.checkDiskAvailSpace.CheckAvailDiskSpace Status: ERROR Additional Notes: ERROR - class com.kingbase.iacustom.plugin.checkDiskAvailSpace.CheckAvailDiskSpace.install() runtime exception : Custom Action: com.kingbase.iacustom.plugin.trimspace.TrimVariableAction Status: ERROR Additional Notes: ERROR - class com.kingbase.iacustom.plugin.trimspace.TrimVariableAction.install() runtime exception: Custom Action: com.kingbase.iacustom.plugin.datetime.GetDateTimeAction Status: SUCCESSFUL

后面还有更详细的信息,这里就不展示了,虽然有两个action报错了,整个脚本的执行确实成功的,没有影响到后面的安装。

4.2 登录数据库查看
$ ./ksql -p 54321 -U system test Password for user system: Type "help" for help. test=# \d List of relations Schema | Name | Type | Owner --------+-------------------------+------+-------- public | sys_stat_statements | view | system public | sys_stat_statements_all | view | system select version(); test=# select version(); version ---------------------------------------------------------------------------------------------------------------------- KingbaseES V009R001C002B0014 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-28), 64-bit (1 row)
4.3 检查数据库是否自启动

以root身份登录运行root.sh后,会创建一个名为kingbased的系统服务,数据库启动后这个服务的状态如下:

root@dbsrv:/tmp# systemctl status kingbased ● kingbased.service - LSB: Start and stop the kingbase server Loaded: loaded (/etc/init.d/kingbased; generated) Active: active (exited) since Sat 2025-06-14 10:39:11 CST; 13min ago Docs: man:systemd-sysv-generator(8) Process: 4838 ExecStart=/etc/init.d/kingbased start (code=exited, status=0/SUCCESS) CPU: 22ms Jun 14 10:39:08 dbsrv systemd[1]: Starting kingbased.service - LSB: Start and stop the kingbase server... Jun 14 10:39:08 dbsrv kingbased[4838]: Starting KingbaseES V9: Jun 14 10:39:08 dbsrv su[4840]: (to kingbase) root on none Jun 14 10:39:08 dbsrv su[4840]: pam_unix(su-l:session): session opened for user kingbase(uid=1001) by (uid=0) Jun 14 10:39:11 dbsrv kingbased[4860]: waiting for server to start..... done Jun 14 10:39:11 dbsrv kingbased[4860]: server started Jun 14 10:39:11 dbsrv kingbased[4838]: KingbaseES V9 started successfully Jun 14 10:39:11 dbsrv systemd[1]: Started kingbased.service - LSB: Start and stop the kingbase server.

5 安装过程中的几个问题

5.1 操作系统不支持locale问题

Locale(区域设置)是Linux系统中用于定义用户语言、地区和文化习惯的一组环境变量。它决定了系统如何显示和处理以下内容:

  • 字符编码和文字方向
  • 日期和时间格式
  • 数字和货币格式
  • 排序和比较规则
  • 消息翻译(如错误提示)

一个完整的locale表示通常由语言代码(如 en 表示英语)、 国家/地区代码(如 US 表示美国) 、字符编码(如 UTF-8)
比如en_US.UTF-8 表示英语,美国,使用UTF-8编码。locale的变量相当复杂,有10多个,可以看下面显示的当前的locale设置,其中LANG变量是默认的区域设置,决定了其它变量的默认值,LC_ALL的优先级最高,会覆盖其它的变量的设置

## 显示当前的locale设置 vboxuser@dbsrv:~$ locale LANG=en_US.UTF-8 LANGUAGE= 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=

显示操作系统当前可用的locale设置

vboxuser@dbsrv:~$ locale -a C C.utf8 en_US.utf8 POSIX

当前系统支持的locale设置只有4个,且没有中文至此,如果想支持中文,可以使用下面命令安装

vboxuser@dbsrv:~$ apt install language-pack-zh-hans language-pack-zh-hans-base [sudo] password for vboxuser: Reading package lists... Done Building dependency tree... Done Reading state information... Done The following NEW packages will be installed: language-pack-zh-hans language-pack-zh-hans-base 0 upgraded, 2 newly installed, 0 to remove and 128 not upgraded. ############省去多行########################## Generating locales (this might take a while)... zh_CN.UTF-8... done zh_SG.UTF-8... done Generation complete. #####安装完成后在查看可用的locale vboxuser@dbsrv:~$ sudo locale -a C C.utf8 en_US.utf8 POSIX zh_CN.utf8 zh_SG.utf8
5.2 数据库安装目录的权限问题

在安装的过程中,选择默认的安装目录时,报错 you do not have write permissions to the chosen installation destination,安装目录的权限是按照官网文档做的,也验证过,用户kingbase对这个目录有写权限,报这个错不知是什么原因。

5.3 文档中几个目录路径同版本不符

可能是因为版本的原因,数据库安装日志的目录和数据库bin目录和官方文档里面的不同。

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论