MV版本中内存计算

带mv的版本中,内存参数会因mv功能需要做出一定的调整。

SHMTOTAL参数变得关键

以下面为例,测试服务器的总内存为4G,一般SHMTOTAL设置为约90%,如下onstat -g mv mem的输出:
Mem Total: [3,574,886,400]

gbase01: On-Line -- Up 00:06:04 -- 1475700 Kbytes

===================================================
MV MEM STATISTICS:
MV Mem Total:           [98353152]
MV Mem Used Total:      [23772840]
MV Mem Blk Used Total:  [27238400]
MV Mem Eff Used Total:  [14507432]
MV Mem Used Rate:       [24.170898%]
MV Mem Blk Used Rate:   [27.694486%]
MV Mem Eff Used Rate:   [61.025237%]
MV Mem Mid[MID_MV_DIFF            ] Used:       [1360]
MV Mem Mid[MID_MV_HUB             ] Used:       [5208]
MV Mem Mid[MID_MV_PAGE            ] Used:       [2179072]
MV Mem Mid[MID_MV_ACTIVE          ] Used:       [11959320]
MV Mem Mid[MID_MV_VER             ] Used:       [2097152]
MV Mem Mid[MID_MV_FULLVER         ] Used:       [240]
MV Mem Mid[MID_MV_MUTEX           ] Used:       [368]
MV Mem Mid[MID_MV_ROW             ] Used:       [1922304]
MV Mem Mid[MID_MV_TCB             ] Used:       [973904]
MV Mem Mid[MID_MV_TX              ] Used:       [304]
MV Mem Mid[MID_MV_IDX_LIFE        ] Used:       [161120]
MV Mem Mid[MID_MV_IDX_ITEM        ] Used:       [174720]
MV Mem Mid[MID_MV_IDX_KEY         ] Used:       [91168]
MV Mem Mid[MID_MV_IDX_PAGE        ] Used:       [107536]
MV Mem Mid[MID_MV_IDX_TX          ] Used:       [139808]
MV Mem Mid[MID_MV_VER_DIFF        ] Used:       [192]
MV Mem Mid[MID_MV_SBBLOB          ] Used:       [178712]
MV Mem Mid[MID_MV_HUBSBB          ] Used:       [201472]
MV Mem Mid[OTHERS             ] Used:   [3840]
===================================================
TOTAL MEM STATISTICS:
Mem Total:                      [3574886400]
Mem Used Total:                 [1440002048]
Mem Total(NoBP):                [3347832832]
Mem Used Total(NoBP):           [1212948480]
Mem Used Rate:                  [36.230856%]
Mem Used Level                  [1]
Host Mem Total:                 [3574886400]
Host Mem Used Total:            [1454792704]
Host Mem Total(NoBP):           [3347832832]
Host Mem Used Total(NoBP):      [1227739136]
Host Mem Used Rate:             [36.672654%]
Host Mem Used Level             [1]
===================================================
BLK ALLOC STAT:
morecore_in_mv_segs     [11972]
morecore_in_other_segs  [22792]
freeblks_in_mv_segs     [5608]
freeblks_in_other_segs  [1379]

阅读全文»

带MVCC功能性能测试优化

sysbench示例 500并发

只读只写
363tps 18271.28, qps 292340.41tps 12803.10, qps 76818.61
MVCCtps 16184.41, qps 259017.18tps 24416.42, qps 146498.53
测试实例
363       SHMVIRTSIZE 4096000
MVCC版本  SHMVIRTSIZE 10240000

MVCC版本脚本初始化安装后调大SHMVIRTSIZE参数,原基础上增大2-3倍,
关闭HUB(onmode -wf HUB_CFG=0),
性能测试前,手动清理数据库内存onmode -F

性能测试过程中,观察CPU负载情况和数据库V段,如果CPU没有跑满,V段申请较多,可以继续增加SHMVIRTSIZE 。

GBase 8s数据库GSDK错误代码

错误消息说明

  • GCI错误码均为正数
  • 小于900000的错误代码表明是GCI侧运行时产生的报错信息。
  • 大于900000的错误码表明是Server报错信息,需减900000后结合Server错误码查看。Server错误码不区分正负值,取绝对值即可。

阅读全文»

GBase 8s 数据库错误代码

GBase 8s 数据库错误代码

基于数据库版本:GBase 8s v8.8 3.6.3_3x2_1

cals

ErrCodeDescription
-23101Unable to load locale categories.
-23102Memory allocation failed during locale processing.
-23103Code-set conversion function failed due to illegal sequence or invalid value.
-23104Error opening required code-set conversion object file.
-23105The current database engine does not support code-set conversion.
-23106Invalid argument for the code-set conversion initializing function.
-23107DBLANG and CLIENT_LOCALE environment variables are incompatible.
-23108An error occurred during locale structure creation.
-23109Invalid locale specification.
-23110An error occurred during environment variable processing.
-23111Internal error. Illegal argument for locale initialization.
-23112Place holder for invalid GCV argument.
-23113Place holder for unknown GCV error.
-23114Place holder for GCV truncation.
-23115Code sets of the locale categories are not the same.
-23190Multibyte database name is not allowed in this system.
-23194Code-set conversion restore failed.
-23195Reset locale failed. Connection refused.
-23196Unknown locale in selected database.
-23197Database locale information mismatch.
-23198GL_COLLATE information is missing from the system catalogs.
-23199GL_CTYPE information is missing from the system catalogs.
-23100An Error has occurred during locale structure creation.

阅读全文»

获取干支纪年的函数

干支纪年可通过年份计算得来(东汉以后)

drop function if exists getY2TGDZ(int);
create function getY2TGDZ(p_year int)
returns varchar(20) with (not variant);
  define v_tg int;
  define v_dz int;
  -- 天干:mod(年份,10),前移3
  let v_tg = mod(p_year,10)+7;
  if v_tg > 10 then
    let v_tg = v_tg - 10;
  end if;
  -- 地支:mod(年份,12),前移3
  let v_dz = mod(p_year,12)+9;
  if v_dz > 12 then
    let v_dz = v_dz - 12;
  end if;
  return substr('甲乙丙丁戊己庚辛壬癸',v_tg,1) || substr('子丑寅卯辰巳午未申酉戌亥',v_dz,1);
end function;

示例:

select getY2TGDZ(2025) as tz from dual;

结果:

tz 乙巳  

mysql group by兼容写法FIRST_ROW

从mysql迁移库,存在非聚集列不在group by 的语句。
这样的sql会被认为是不合法的sql,因为:
1,order by后面的列必须是在select后面存在的
2,select、having或order by后面存在的非聚合列必须全部在group by中存在

通用情况下,mysql可以通过以下三种方式解决报错问题
1,修改sql使其遵守only_full_group_by规则
2,关闭only_full_group_by规则
3,降级数据库版本在5.7以下

阅读全文»

GBase 8s数据库用户登陆验证大致过程

注:对非gbasedbt或者root用户
注:仅是大致过程

1,访问系统库sysuser的表sysintauthuser。
如果用户名不匹配username,则认为不是内部用户,转使用操作系统验证;如果匹配username,则继续2。
2,访问系统库sysuser的表sysusermap。
如果用户名不匹配username,刚使用默认用户(default user的properties);如果匹配username,则获取surrogate_id。继续3。
3,访问系统库sysuser的表syssurrogates。
如果surrogate_id不匹配,则报错退出; 如果匹配,则获取os_username。继续4。
4,与加载到内存中的allowed.surrogates对比。
如果不匹配,报警告,转使用操作系统验证;如果匹配,完成检验。

GBase 8s内部用户与操作系统用户验证关系

分为两个场景

先有操作系统用户

1,未创建同名的内部用户

用户验证使用操作系统检验。

2,使用默认方式创建同名内部用户

将自动与同名操作系统用户绑定代理映射,用户检验时先从内部校验,但找不到代理映射用户(online.log中会的警告),而后将使用操作系统检验。
注:这种情况下,修改allowed.surrogates增加同名代理映射用户,并重新加载到内存。此时,内部用户检验通过,将使用内部检验。

3,创建同名内部用户时指定有效的代理映射用户

用户检验使用内部检验

先有内部用户(代理映射正常)

1,未创建同名的操作系统用户

用户校验使用内部检验

2,创建同名的操作系统用户

用户校验使用内部检验