按照文档TimesTen 18.1.2.1 Classic模式安装与配置过程,在Linux 7上安装TimesTen 18.1.3.2.0,一切顺利,创建示例数据库重成功。
但是将数据库内存增大到256G时,报错:
$ ttisql sampledb
Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=sampledb";
836: Cannot create database shared-memory segment, error 0
703: Subdaemon connect to database failed with error TT836
The command failed.
Done.
原因是当数据库内存超过256G时,需要开启HugePage。参见Database Connection Fails With Cannot create data store shared-memory segment, error 22 (Doc ID 1504153.1)。
以下操作参考文档Oracle® TimesTen In-Memory Database Installation, Migration, and Upgrade Guide Release 18.1 - Configure HugePages
首先查看Hugepage的单位,一般都是2M:
$ cat /proc/meminfo | grep Hugepagesize
Hugepagesize: 2048 kB
因为需求是256G,所有需要的HugePage数量为:
256 * 1024M = 262144 MB/ 2 MB = 131072
考虑到还有一些其它开销,将131072调整为132000。
查看instance admin的用户名和group信息:
$ id
uid=55000(oracle) gid=10000(timesten) groups=10000(timesten),10(wheel) context=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023
记录instance admin为oracle,group id为10000.
编辑文件/etc/sysctl.conf,添加以下两行:
vm.nr_hugepages=132000
vm.hugetlb_shm_group=10000
其中10000为instance admin的group id。132000是我们之前计算的值。
使其生效:
$ sudo sysctl -p
vm.nr_hugepages = 131072
vm.hugetlb_shm_group = 10000
编辑文件/etc/security/limits.conf,添加以下两行:
oracle soft memlock 300000000
oracle hard memlock 300000000
其中oracle为instace admin用户名,300000000是选取了一个大于以下计算结果的值:
256*1024*1024 = 268435456
然后用户需退出再登录,使其生效。
然后建库就没有问题了:
$ ttisql sampledb
Copyright (c) 1996, 2020, Oracle and/or its affiliates. All rights reserved.
Type ? or "help" for help, type "exit" to quit ttIsql.
connect "DSN=sampledb";
Connection successful: DSN=sampledb;UID=oracle;DataStore=/u01/database/data/ttdb;DatabaseCharacterSet=AL32UTF8;ConnectionCharacterSet=US7ASCII;LogFileSize=256;DRIVER=/home/oracle/tt181/install/lib/libtten.so;LogBufMB=256;LogDir=/u01/database/log;PermSize=262144;TempSize=1024;OracleNetServiceName=ttorcl;
(Default setting AutoCommit=1)
Command> dssize
The following values are in MB:
PERM_ALLOCATED_SIZE: 262144
PERM_IN_USE_SIZE: 13.979
PERM_IN_USE_HIGH_WATER: 13.979
TEMP_ALLOCATED_SIZE: 1024
TEMP_IN_USE_SIZE: 15.552
TEMP_IN_USE_HIGH_WATER: 15.759
Command> dssize g
The following values are in GB:
PERM_ALLOCATED_SIZE: 256
PERM_IN_USE_SIZE: .014
PERM_IN_USE_HIGH_WATER: .014
TEMP_ALLOCATED_SIZE: 1
TEMP_IN_USE_SIZE: .015
TEMP_IN_USE_HIGH_WATER: .015
其它监控数据:
$ cat /proc/meminfo|grep -i huge
AnonHugePages: 143360 kB
ShmemHugePages: 0 kB
HugePages_Total: 132000
HugePages_Free: 131868
HugePages_Rsvd: 131690
HugePages_Surp: 0
Hugepagesize: 2048 kB
[oracle@tthugepage ~]$ ipcs -a
------ Message Queues --------
key msqid owner perms used-bytes messages
------ Shared Memory Segments --------
key shmid owner perms bytes nattch status
0xf803da71 360448 oracle 660 1048576 1
0x1903cda4 458753 oracle 660 276316553216 10
0x1a03cda4 491522 oracle 660 134217728 2
------ Semaphore Arrays --------
key semid owner perms nsems
0xf803da71 196608 oracle 660 1
0x1903cda4 262145 oracle 660 2155