关于安装GBase 8s数据库实例失败的问题
有用户在 GBase 8s 数据库初始化实例时出现问题,提示 shared memory not initialized for GBASEDBTSERVER ‘gbasedb’,(原帖子链接:麒麟V10 ARM架构下安装GBase 8s数据库实例失败,提示shared memory not initialized for GBASEDBTSERVER ‘gbasedb’)
这种情况通常与共享内存配置、权限问题或实例参数设置有关。以下是逐步排查与解决方案:
1. 检查操作系统共享内存参数
GBase 8s 依赖操作系统的共享内存机制,若内核参数未正确配置,会导致共享内存初始化失败。
查看当前共享内存参数:
sysctl -a | grep shm关键参数:
kernel.shmmax: 单个共享内存段的最大大小(建议为物理内存的 70-80%)。kernel.shmall: 系统可分配的共享内存总量(单位:页,需足够大)。kernel.shmmni: 共享内存段的最大数量。
临时修改参数(立即生效):
sysctl -w kernel.shmmax=1073741824 # 示例:1GB sysctl -w kernel.shmall=2097152 # 示例:总共享内存页数 sysctl -w kernel.shmmni=4096永久修改参数:
编辑/etc/sysctl.conf,添加以下内容后执行sysctl -p:kernel.shmmax = 1073741824 kernel.shmall = 2097152 kernel.shmmni = 4096
2. 检查用户权限与组配置
确认
gbasedbt用户权限:
确保gbasedbt用户为数据库安装目录、数据目录的所有者,并具有读写权限:chown -R gbasedbt:gbasedbt /opt/GBASE/gbase chmod -R 755 /opt/GBASE/gbase检查用户组限制:
某些系统可能限制用户可创建的共享内存大小。编辑/etc/security/limits.conf,添加:gbasedbt soft memlock unlimited gbasedbt hard memlock unlimited
3. 验证实例配置文件(onconfig)
初始化脚本依赖 onconfig 文件中的参数配置。检查以下关键参数:
文件路径:
确保onconfig文件位于正确路径(如/opt/GBASE/gbase/etc/onconfig.gbasedb),且文件名与实例名匹配。关键参数:
ROOTPATH /opt/GBASE/gbase/data/rootdbs # 确保路径存在且权限正确 SERVERNUM 0 # 唯一标识(通常为0) DBSERVERNAME gbasedb # 与错误提示中的实例名一致检查 ROOTPATH 对应的 chunk 文件:
若rootdbs文件未提前创建,需手动创建并赋予权限:touch /opt/GBASE/gbase/data/rootdbs chown gbasedbt:gbasedbt /opt/GBASE/gbase/data/rootdbs chmod 660 /opt/GBASE/gbase/data/rootdbs
4. 检查端口冲突
GBase 8s 默认使用端口 9088(可通过 onconfig 文件中的 DBSERVERALIASES 或 SQLHOSTS 文件确认)。
查看端口占用:
netstat -tulnp | grep 9088若端口被占用:
修改onconfig文件中的端口号或停止冲突进程。
5. 关闭 SELinux 或防火墙
临时关闭 SELinux 和防火墙,排除安全策略限制:
禁用 SELinux:
setenforce 0 # 临时关闭 sed -i 's/SELINUX=enforcing/SELINUX=disabled/g' /etc/selinux/config # 永久关闭关闭防火墙:
systemctl stop firewalld # CentOS/RHEL ufw disable # Ubuntu/Debian
6. 查看详细日志定位问题
检查消息日志(online.log):
日志默认路径为$GBASEDBTDIR/etc/online.log,直接查看错误详情:tail -n 100 /opt/GBASE/gbase/etc/online.log根据日志中的具体错误代码(如
-25578)进一步分析。
7. 手动初始化实例(可选)
如果脚本自动初始化失败,可尝试手动执行初始化:
# 切换到 gbasedbt 用户
su - gbasedbt
# 手动初始化
oninit -ivy # 强制初始化并显示详细日志总结
此错误的核心原因通常为:
操作系统共享内存参数配置不足。
实例配置文件(
onconfig)中路径或参数错误。权限问题导致无法创建共享内存或文件。
按上述步骤逐一排查,重点关注 共享内存参数、文件权限、配置文件。若问题仍未解决,请提供 online.log 中的关键错误日志片段以进一步分析。
评论
03/19/25 10:13:21 DR: ENCRYPT_HDR is 0 (HDR encryption Disabled)
03/19/25 10:13:21 Event notification facility epoll enabled.
03/19/25 10:13:21 GBase Database Server Version 12.10.FC4G1TL Software Serial Number AAA#B000000
03/19/25 10:13:21 Your evaluation license will expire on 2026-03-18 00:00:00
03/19/25 10:13:23 WARNING: mt_aio_wait: errno == EINVAL
03/19/25 10:13:23 Assert Warning: I/O read chunk 1, pagenum 0, pagecnt 1 --> errno = 2
03/19/25 10:13:23 GBase Database Server Version 12.10.FC4G1TL
03/19/25 10:13:23 Who: Session(1, gbasedbt@zbc-pc, 0, 0x53c8a028)
Thread(7, main_loop(), 53c43028, 9)
File: rsbuff.c Line: 5724
03/19/25 10:13:23 Action: Please notify GBASE Techical Support.
03/19/25 10:13:23 stack trace for pid 74654 written to /opt/GBASE/gbase/tmp/af.3ef2843
03/19/25 10:13:23 See Also: /opt/GBASE/gbase/tmp/af.3ef2843
03/19/25 10:13:23 oninit: Fatal error in shared memory initialization
14:40:13 GBase Database Server Started.
14:40:13 Requested shared memory segment size rounded from 237736KB to 240984KB
Wed Mar 19 14:40:15 2025
03/19/25 14:40:15 Requested shared memory segment size rounded from 905507KB to 905508KB
03/19/25 14:40:15 Successfully added a bufferpool of page size 2K.
03/19/25 14:40:15 Requested shared memory segment size rounded from 6483944KB to 6483948KB
03/19/25 14:40:15 shmget: [ENOSPC][28]: key 5256480b: The server could not allocate shared memory because an operating system limit was reached
03/19/25 14:40:15 Performance Advisory: Unable to allocate memory for bufferpool 16K
03/19/25 14:40:15 Action: Please notify GBASE Techical Support.
14:46:19 GBase Database Server Started.
14:46:19 Requested shared memory segment size rounded from 237736KB to 240984KB
Wed Mar 19 14:46:21 2025
03/19/25 14:46:21 Requested shared memory segment size rounded from 905507KB to 905508KB
03/19/25 14:46:21 Successfully added a bufferpool of page size 2K.
03/19/25 14:46:21 Requested shared memory segment size rounded from 6483944KB to 6483948KB
03/19/25 14:46:21 shmget: [EEXIST][17]: key 52564804: shared memory already exists
03/19/25 14:46:21 Performance Advisory: Unable to allocate memory for bufferpool 16K
03/19/25 14:46:21 Action: Please notify GBASE Techical Support.
热门帖子
- 12025-12-01浏览数:182759
- 22023-05-09浏览数:25044
- 42023-09-25浏览数:18519
- 52020-05-11浏览数:17526
根据您的建议我查了一下内存如下:
gbasedbt@zbc-pc:~$ free -h
总计 已用 空闲 共享 缓冲/缓存 可用
内存: 15Gi 3.0Gi 8.1Gi 569Mi 4.2Gi 11Gi
交换: 2.0Gi 0B 2.0Gi
根据您的建议,我选择了临时修改参数,如下:
sysctl -w kernel.shmmax=1073741824 # 示例:1GB
sysctl -w kernel.shmall=2097152 # 示例:总共享内存页数
sysctl -w kernel.shmmni=4096
除此之外,我逐一对比,发现以下不同之处并进行了调整:
1.onconfig文件,我的相关参数如下:
ROOTPATH /opt/GBASE/gbase/gbasedb_dbs/rootdbs # 对应的文件路径是存在的,所有我没有进行修改
SERVERNUM 139 # 我将此处的139改为了0
DBSERVERNAME gbasedb # 实例名一致
2.rootdbs文件是存在的(我的路径为/opt/GBASE/gbase/gbasedb_dbs/rootdbs),但是我看对应的权限是755,然后根据您的提示我修改为了660
3.9088端口并没有相关进程占用,SELinux 和防火墙也是关闭状态
root@zbc-pc:/home/gbasedbt# setenforce 0
setenforce: SELinux is disabled
root@zbc-pc:/home/gbasedbt# systemctl stop firewalld
Failed to stop firewalld.service: Unit firewalld.service not loaded.
4.手动初始化实例,还是失败了
root@zbc-pc:/home/gbasedbt# su - gbasedbt
gbasedbt@zbc-pc:~$ oninit -ivy
Your evaluation license will expire on 2026-03-18 00:00:00
Reading configuration file '/opt/GBASE/gbase/etc/onconfig.gbasedb'...succeeded
Allocating and attaching to shared memory...succeeded
Creating resident pool 237738 kbytes...succeeded
Creating infos file "/opt/GBASE/gbase/etc/.infos.gbasedb"...succeeded
Linking conf file "/opt/GBASE/gbase/etc/.conf.gbasedb"...succeeded
Initializing rhead structure...rhlock_t 131072 (4096K)... rlock_t (225781K)... oninit: Fatal error in shared memory creation
WARNING: server initialization failed or timed out.
Check the message log, online.log, for errors.