原文链接:【KWDB 创作者计划】KWDB单机部署我所踩的坑 - 墨天轮
作者:reddey
最近墨天轮的大佬都在发KWDB单机部署的相关文章,KWDB由于是时序数据库,平时在工作中几乎用得很少,几乎没用过。由于是周末,我也在自己的实验机上试装一下。由于我是菜鸟,心里对时序数据库没底,所以部署之前特意参考了墨天轮社区几位大佬的部署文章,从产品介绍中看出数据库支持容器和裸机两种方式,大佬们都是用裸机部署的。由于支持裸机部署的操作系统并不多,只有kylin、ubuntu、龙蜥等操作系统的几个特定版本。大佬在部署文章中,有些是用kylin操作系统,有些是用ubuntu系统。在这里,我记录一下在部署过程自己踩的坑。以下是KWDB数据库的功能特性介绍:
时间精度
时间戳数据类型:时序引擎的时间戳数据类型新增对微秒、纳秒级精度的支持。
时间日期函数:time_bucket 和 time_bucket_gapfill 函数支持以纳秒为单位的时间输入。
数据库对象
隔离级别:关系引擎新增对可重复读(Repeatable Read,RR)、读已提交(Read Committed,RC)隔离级别的支持。
DML 操作
无模式写入:支持按照 OpenTSDB 的 telnet 行协议及 JSON 格式协议进行数据写入;使用无模式写入方式创建库、表时,自动区分大小写。
数据查询
分组窗口函数:支持计数窗口、事件窗口、会话窗口、状态窗口和事件窗口函数,可基于时间间隔、数据行数或状态信息等条件对数据进行分组并执行聚合查询。
TWA 函数:支持使用 TWA 函数计算指定列在一定时间范围内的时间加权平均值。
ELAPSED 函数:支持使用 ELAPSED 函数计算周期内的连续时间长度。
insert INTO select:支持将跨模查询的结果写入时序表。
数据库运维
预分配空间控制:支持通过集群参数控制预分配空间的大小。
导入导出:
支持用户信息、用户权限及集群参数数据的导入。
支持大写 schema 的导入导出。
操作系统和环境:完善对 Ubuntu 18.04 的支持。
支持分页展示查询结果,优化大宽表的查询展示性能。
Debug 日志优化:记录线程号、类名、执行 SQL 语句、结果处理时间等日志信息。
增强日志能力:提升任务调度、查询结果处理及图形化绘制等模块的日志能力。
最后提交信息为: !507解决多模查询慢问题
KaiwuDB-Kafka-Connect-2.0.2.zip
KaiwuDB_datax-2.2.0.zip
KWDB-2.2.0-kylinV10_2403-x86_64-rpms.tar.gz
kaiwudb-jdbc-2.2.0.jar
KWDB-2.2.0-kylinV10_2403-aarch64-rpms.tar.gz
KWDB-2.2.0-ubuntu20.04-x86_64-debs.tar.gz
KWDB-2.2.0-ubuntu22.04-x86_64-debs.tar.gz
KaiwuDB_Developer_Center-2.0.4-win-x86_64.zip
KaiwuDB_Developer_Center-2.0.4-linux-x86_64.tar.gz
KaiwuDB_Developer_Center-2.0.4-mac-x86_64.tar.gz
KWDB-2.2.0-ubuntu22.04-x86_64-docker.tar.gz
KWDB-2.2.0-ubuntu22.04-aarch64-docker.tar.gz
下载 Source code (zip)
下载 Source code (tar.gz)
在这次的部署中,我选择了ubuntu操作系统。操作系统版本号为Ubuntu 22.04.5 LTS。
数据库版本下载了KWDB-2.2.0-ubuntu22.04-x86_64-debs.tar.gz。
tar -zxvf KWDB-2.2.0-ubuntu22.04-x86_64-debs.tar.gz
root@reddey-virtual-machine:~/kwdb_install# ls -al total 56 drwxr-xr-x 5 root root 4096 4月 13 09:45 . drwx------ 5 root root 4096 4月 13 09:47 .. -rwxr-xr-x 1 root root 2024 3月 31 15:11 add_user.sh -rw-r--r-- 1 root root 3605 3月 31 15:12 .construction_var -rw-r--r-- 1 root root 477 4月 13 09:34 deploy.cfg -rwxr-xr-x 1 root root 24410 3月 31 15:11 deploy.sh drwxr-xr-x 2 root root 4096 4月 13 09:24 log drwxr-xr-x 2 root root 4096 3月 31 15:22 packages drwxr-xr-x 2 root root 4096 3月 31 15:11 utils
关于操作系统的有组件依赖关系的下载和安装,还有操作系统的一些SSH设置,大家可以看一下IT邦德老师的文章https://www.modb.pro/db/1910644325709524992,里面介绍的很详细了。
deploy.sh是用来部署数据库的脚本,deploy.cfg是数据库的配置文件,配置文件如何设置和里面参数介绍,邦德老师已经详细介绍了,这里不再介绍了。
我在部署过程中,在执行./deploy.sh install --single时,出现这个提示。
[WARN] 2025-04-13 09:24:53 The number of CPU cores does not meet the requirement. KaiwuDB may running failed。
后面系统提示我输入数据库密码。
我后面检查了一下错误日志,内容如下
root@reddey-virtual-machine:~/kwdb_install/log# cat 2025-04-13 [WARN] 2025-04-13 09:24:53 The number of CPU cores does not meet the requirement. KaiwuDB may running failed. [INFO] 2025-04-13 09:24:58 start create /etc/kaiwudb/info/MODE /etc/kaiwudb/info/NODE. [INFO] 2025-04-13 09:24:58 create /etc/kaiwudb/info/MODE /etc/kaiwudb/info/NODE successfully. [ERROR] 2025-04-13 09:26:29 Start KaiwuDB failed. For more information, check kwbase log. [ERROR] 2025-04-13 09:26:51 Start KaiwuDB failed. For more information, check kwbase log. [ERROR] 2025-04-13 09:28:18 KaiwuDB is already installed. [ERROR] 2025-04-13 09:37:25 Start KaiwuDB failed. For more information, check kwbase log. [ERROR] 2025-04-13 09:37:29 KaiwuDB is not runnning now. [ERROR] 2025-04-13 09:37:41 KaiwuDB is not runnning now. [ERROR] 2025-04-13 09:37:51 Start KaiwuDB failed. For more information, check kwbase log. [ERROR] 2025-04-13 09:41:07 Start KaiwuDB failed. For more information, check kwbase log. [ERROR] 2025-04-13 09:41:29 Start KaiwuDB failed. For more information, check kwbase log. [ERROR] 2025-04-13 09:43:47 KaiwuDB is already installed. [WARN] 2025-04-13 09:45:21 The number of CPU cores does not meet the requirement. KaiwuDB may running failed.
从提示看,那个警告提示我的CPU核数不符合要求,数据库可能会运行失败,我的实验虚拟机是2核的。果不其然,我的数据库确实启动失败了。
CPU核数不够,我就关机增加了CPU核数。并且重启了操作系统,增加后如下所示:
root@reddey-virtual-machine:~/kwdb_install/log# lscpu Architecture: x86_64 CPU op-mode(s): 32-bit, 64-bit Address sizes: 42 bits physical, 48 bits virtual Byte Order: Little Endian CPU(s): 4 On-line CPU(s) list: 0-3 Vendor ID: GenuineIntel Model name: Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz CPU family: 6 Model: 158 Thread(s) per core: 1 Core(s) per socket: 1 Socket(s): 4 Stepping: 10 BogoMIPS: 6384.31 Flags: fpu vme de pse tsc msr pae mce cx8 apic sep mtrr pge mca cmov pat p se36 clflush dts mmx fxsr sse sse2 ss syscall nx pdpe1gb rdtscp lm constant_tsc arch_perfmon pebs bts nopl xtopology tsc_reliable nons top_tsc cpuid aperfmperf tsc_known_freq pni pclmulqdq ssse3 fma cx1 6 pcid sse4_1 sse4_2 x2apic movbe popcnt tsc_deadline_timer aes xsa ve avx f16c rdrand hypervisor lahf_lm abm 3dnowprefetch pti fsgsbas e tsc_adjust bmi1 hle avx2 smep bmi2 invpcid rtm rdseed adx smap xs aveopt dtherm ida arat pln pts hwp hwp_notify hwp_act_window hwp_ep p Virtualization features: Hypervisor vendor: VMware Virtualization type: full Caches (sum of all): L1d: 128 KiB (4 instances) L1i: 128 KiB (4 instances) L2: 1 MiB (4 instances) L3: 48 MiB (4 instances) NUMA: NUMA node(s): 1 NUMA node0 CPU(s): 0-3 Vulnerabilities: Gather data sampling: Unknown: Dependent on hypervisor status Itlb multihit: KVM: Mitigation: VMX unsupported L1tf: Mitigation; PTE Inversion Mds: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host sta te unknown Meltdown: Mitigation; PTI Mmio stale data: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host sta te unknown Reg file data sampling: Not affected Retbleed: Vulnerable Spec rstack overflow: Not affected Spec store bypass: Vulnerable Spectre v1: Mitigation; usercopy/swapgs barriers and __user pointer sanitizatio n Spectre v2: Mitigation; Retpolines; STIBP disabled; RSB filling; PBRSB-eIBRS No t affected; BHI Retpoline Srbds: Unknown: Dependent on hypervisor status Tsx async abort: Vulnerable: Clear CPU buffers attempted, no microcode; SMT Host sta te unknown 。
由于之前已经进行了部署,虽然部署失败,但生成的数据库文件还在。我决定是不是要把数据库部署删除重新部署,查看部署脚本deploy.sh内容,发现有以下参数:
Commands: install Install KaiwuDB uninstall Uninstall KaiwuDB in local node cluster Cluster operate start Start KaiwuDB in local node stop Stop KaiwuDB in local node restart Restart KaiwuDB in local node status Get local node KaiwuDB status 也就是我用uninstall参数,可以删除上次失败的部署,然后再进行重新部署。 firoot@reddey-virtual-machine:~/kwdb_install# ./deploy.sh uninstall --single When uninstalling KaiwuDB, you can either delete or keep all user data. Please confirm your choice: Do you want to delete the data? (y/N)y [UNINSTALL COMPLETED]:KaiwuDB has been uninstalled successfully. root@reddey-virtual-machine:~/kwdb_install# ./deploy.sh install --single [WARN] 2025-04-13 09:45:21 The number of CPU cores does not meet the requirement. KaiwuDB may running failed. Please input kaiwudb's password: [INSTALL COMPLETED]:KaiwuDB has been installed successfully! To start KaiwuDB, please execute the command 'systemctl daemon-reload'. root@reddey-virtual-machine:~/kwdb_install# ./deploy.sh start [START COMPLETED]:KaiwuDB start successfully.
增加CPU核数后,这次提示还是不满足CPU核数要求,但这次部署成功了,数据库服务也正常启动了。
登录数据库,命令如下
root@reddey-virtual-machine:~/kwdb_install/log# kwbase sql --insecure --host=192.168.200.71 # # Welcome to the KWDB SQL shell. # All statements must be terminated by a semicolon. # To exit, type: \q. # # Server version: KaiwuDB 2.2.0 (x86_64-linux-gnu, built 2025/03/31 07:20:02, go1.16.15, gcc 11.4.0) (same version as client) # Cluster ID: 4197999c-b24b-4138-8549-64596fc443c4 # # Enter \? for a brief introduction. # root@192.168.200.71:26257/defaultdb> show databases; database_name | engine_type ----------------+-------------- business_db | RELATIONAL defaultdb | RELATIONAL iot | TIME SERIES postgres | RELATIONAL system | RELATIONAL ts_db | TIME SERIES (6 rows) Time: 6.057073ms
这次的踩坑,让我想起英国著名作家莎士比亚的一句话“1000个《哈姆雷特》的读者,就有1000个哈姆雷特”。每个DBA成长道路上,可能会遇到完全不同于别人的挫折和失败,这些挫折和失败大部分都要自己去单独解决的。