二、内置表
FarelDB在安装后,将自动产生1个内置数据库inner_db_sys以及多张内置表,内置数据库是FarelDB自带的,它提供了访问数据库元数据的方式以及其他中间件当前状态信息。元数据是关于数据的数据,如数据库名或表名,列的数据类型,注释等。有些时候用于表述该信息的其他术语包括“数据词典”和“系统目录”。
在FarelDB中,把 inner_db_sys 看作是一个数据库,确切说是信息数据库。其中保存着关于FarelDB服务器所维护的所有其他数据库的信息(当然也包括其本身)。在inner_db_sys中,有数个只读表,登录FarelDB后,使用查询表命令,可以查询到内置数据库inner_db_sys中包含的表信息,如下图所示:
FarelDb localhost:6800 > select * from inner_table_tables;
name database_name rows size inner_flag trace_flag create_time create_stmt last_modified_time
inner_table_connections inner_db_sys 1 420 true false 2023-11-05 20:03:34.973 "" 2023-11-05 20:03:40.397
inner_table_databases inner_db_sys 0 0 true false 2023-11-05 20:03:34.973 "" 2023-11-05 20:03:34.973
inner_table_tables inner_db_sys 0 0 true false 2023-11-05 20:03:34.973 "" 2023-11-05 20:03:34.973
inner_table_kv_tables inner_db_sys 1 582 true false 2023-11-05 20:03:34.973 "" 2023-11-05 20:03:34.977
inner_table_fields inner_db_sys 87 69513 true false 2023-11-05 20:03:34.974 "" 2023-11-05 20:03:34.977
inner_table_configs inner_db_sys 31 4278 true true 2023-11-05 20:03:34.976 "" 2023-11-05 20:03:34.977
inner_table_rpcs inner_db_sys 0 0 true true 2023-11-05 20:03:34.976 "" 2023-11-05 20:03:34.976
inner_table_comms inner_db_sys 0 0 true true 2023-11-05 20:03:34.976 "" 2023-11-05 20:03:34.976
inner_table_subscribes inner_db_sys 0 0 true true 2023-11-05 20:03:34.976 "" 2023-11-05 20:03:34.976
inner_table_userscripts inner_db_sys 0 0 true true 2023-11-05 20:03:34.977 "" 2023-11-05 20:03:34.977
inner_table_observers inner_db_sys 0 0 true true 2023-11-05 20:03:34.977 "" 2023-11-05 20:03:34.977
[11 rows]
FarelDb localhost:6800 >
上图中表查询命令(select * from inner_db_sys.inner_table_tables)以及二维表相关SQL操作的详细讲解将在后续章节详解。从上图中可以看出,内置数据库inner_db_sys下有多个内置表,他们分别是:
(1) 连接信息表(inner_table_connections)
(2) 数据库信息表(inner_table_databases)
(3) 二维表信息表(inner_table_tables)
(4) key-value表信息表(inner_table_kv_tables)
(5) 二维表列信息表(inner_table_fields)
(6) 系统配置信息表(inner_table_configs)
(7) RPC信息表(inner_table_rpcs)
(8) 通信通道信息表(inner_table_comms)
(9) 订阅发布信息表(inner_table_subscribes)
(10)用户脚本信息表(inner_table_userscripts)
(11)观察信息表(inner_table_observers)
下面将对这几个内置表逐个详细介绍。
1. 连接信息表(inner_table_connections)
登录FarelDB后,可以通过下面的命令查询当前服务中所有的客户端实时连接信息
FarelDb localhost:6800 > use database inner_db_sys
success, affected count: 1
FarelDb localhost:6800 > select * from select * from inner_table_connections
等价于下面的一条命令
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_connections
命令执行结果如下所示
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_connections
id host port create_time subscribes rpcs comms
127.0.0.1_51796 127.0.0.1 51796 2023-11-08 20:35:14.579 0 0 0
127.0.0.1_51902 127.0.0.1 51902 2023-11-08 21:33:54.104 0 0 0
[2 rows]
本例中,当前有两个客户端连接了FarelDB服务。
连接信息表中,每一列含义详细内容如下表所示:
列名 | 列含义 | 说明 | 备注 |
---|---|---|---|
id | 当前连接的信息号 | IP地址+端口号 | |
host | 客户端主机主机IP | ||
port | 客户端连接所使用的端口号 | ||
create_time | 创建时间 | 整数表示,定义为从格林威治时间1970年01月01日 00时00分00秒000毫秒起至现在的总毫秒数 | |
subscribes | 客户端订阅数量 | ||
rpcs | 客户端使用远程过程调用数量 | ||
comms | 客户端连接的通信通道数量 |
2. 数据库信息表(inner_table_databases)
登录FarelDB后,可以通过下面的命令查询当前服务中所有的数据库信息.
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_databases;
如下所示,第1条查询命令查询出当前系统内只有一个内置数据库inner_db_sys,随后用第2条命令创建一个用户数据库,用第3条同样的查询命令查询,显示查询出系统内置数据库inner_db_sys和用户创建成功的用户数据库myTestDatabase。
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_databases;
name tables size inner_flag create_time last_modified_time
inner_db_sys 0 0 true 2023-11-05 20:03:34.973 2023-11-05 20:11:13.378
[1 rows]
FarelDb localhost:6800 > create database myTestDatabase;
success, affected count: 1
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_databases;
name t ables size inner_flag create_time last_modified_time
inner_db_sys 0 0 true 2023-11-05 20:03:34.973 2023-11-05 20:11:13.378
myTestDatabase 0 0 false 2023-11-05 20:19:24.767 2023-11-05 20:19:24.767
[2 rows]
FarelDb localhost:6800 >
数据库信息每一列含义详细内容如下表所示:
列名 | 列含义 | 说明 | 备注 |
---|---|---|---|
name | 数据库名称 | ||
tables | 数据库包含表个数 | ||
size | 数据库大小 | 以字节计算的数据库占用内存空间 | 字节 |
inner_flag | 内置数据库标志 | Yes:系统创建的不可删除 No:用户自己创建的 | |
create_time | 创建时间 | 整数表示,定义为从格林威治时间1970年01月01日 00时00分00秒000毫秒起至现在的总毫秒数 | 可通过datetime(整数时间) 命令查询显示年月日时分秒格式 |
last_modified_time | 最后修改时间 | 整数表示,定义为从格林威治时间1970年01月01日 00时00分00秒000毫秒起至现在的总毫秒数 | 可通过datetime(整数时间) 命令查询显示年月日时分秒格式 |
3. 二维表信息表(inner_table_tables)
登录FarelDB后,可以通过下面的命令查询当前服务中所有的数据表信息.
FarelDb localhost:6800 > use database inner_db_sys
success, affected count: 1
FarelDb localhost:6800 > select * from inner_table_tables
等价于
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_tables
FarelDB在安装后,将自动产生11个内置数据表 ,内置数据表是不支持用户进行删除和修改操作的。
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_tables
name database_name rows size inner_flag trace_flag create_time create_stmt last_modified_time
inner_table_connections inner_db_sys 2 840 true false 2023-11-05 20:03:34.973 "" 2023-11-05 20:11:13.378
inner_table_databases inner_db_sys 0 0 true false 2023-11-05 20:03:34.973 "" 2023-11-05 20:03:34.973
inner_table_tables inner_db_sys 0 0 true false 2023-11-05 20:03:34.973 "" 2023-11-05 20:03:34.973
inner_table_kv_tables inner_db_sys 1 582 true false 2023-11-05 20:03:34.973 "" 2023-11-05 20:03:34.977
inner_table_fields inner_db_sys 87 69513 true false 2023-11-05 20:03:34.974 "" 2023-11-05 20:03:34.977
inner_table_configs inner_db_sys 31 4278 true true 2023-11-05 20:03:34.976 "" 2023-11-05 20:03:34.977
inner_table_rpcs inner_db_sys 0 0 true true 2023-11-05 20:03:34.976 "" 2023-11-05 20:03:34.976
inner_table_comms inner_db_sys 0 0 true true 2023-11-05 20:03:34.976 "" 2023-11-05 20:03:34.976
inner_table_subscribes inner_db_sys 0 0 true true 2023-11-05 20:03:34.976 "" 2023-11-05 20:03:34.976
inner_table_userscripts inner_db_sys 0 0 true true 2023-11-05 20:03:34.977 "" 2023-11-05 20:03:34.977
inner_table_observers inner_db_sys 0 0 true true 2023-11-05 20:03:34.977 "" 2023-11-05 20:03:34.977
[11 rows]
数据库表每一列含义详细内容如下表所示:
列名 | 列含义 | 说明 | 备注 |
---|---|---|---|
name | 表名称 | ||
database_name | 数所属数据库 | ||
rows | 表包含行数 | ||
size | 表大小 | 以字节计算的数据库占用内存空间 | 字节 |
inner_flag | 内置数据库标志 | true:系统创建的不可删除 false:用户自己创建的 | |
create_time | 创建时间 | 整数表示,定义为从格林威治时间1970年01月01日00时 00分00秒000毫秒起至现在的总毫秒数 | 可通过datetime(整数时间) 命令查询显示年月日时分秒格式 |
last_modified_time | 最后修改时间 | 整数表示,定义为从格林威治时间1970年01月01日 00时00分00秒000毫秒起至现在的总毫秒数 | 可通过datetime(整数时间) 命令查询显示年月日时分秒格式 |
4.key-value表信息表(inner_table_kv_tables)
登录FarelDB后,可以通过下面的命令查询当前服务中所有的key-value信息.
FarelDb localhost:6800 > use database inner_db_sys
success, affected count: 1
FarelDb localhost:6800 > select * from inner_table_kv_tables
等价于下面的一条命令
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_kv_tables
命令执行内容如下所示
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_kv_tables
name database_name keys string_keys hash_keys list_keys set_keys sortset_keys inner_flag create_time last_modified_time
inner_table_kv inner_db_kv 0 0 0 0 0 0 true 2023-11-08 20:05:27.999 2023-11-08 20:05:27.999
[1 rows]
列信息表每一列含义详细内容如下表所示:
列名 | 列含义 | 说明 | 备注 |
---|---|---|---|
name | kv表表名 | ||
database_name | 数据库名 | ||
keys | 所有key的数量 | ||
string_keys | 字符串类型key的数量 | ||
hash_keys | 哈希类型key的数量 | ||
list_keys | 列表类型key的数量 | ||
set_keys | 集合类型key的数量 | ||
sortset_keys | 有序集合类型key的数量 | ||
inner_flag | 内置数据库标志 | true:系统创建的不可删除 false:用户自己创建的 | |
create_time | 创建时间 | 整数表示,定义为从格林威治时间1970年01月01日 00时00分00秒000毫秒起至现在的总毫秒数 | 可通过datetime(整数时间) 命令查询显示年月日时分秒格式 |
last_modified_time | 最后修改时间 | 整数表示,定义为从格林威治时间1970年01月01日 00时00分00秒000毫秒起至现在的总毫秒数 | 可通过datetime(整数时间) 命令查询显示年月日时分秒格式 |
5. 二维表列信息表(inner_table_fields)
登录FarelDB后,可以通过下面的命令查询当前服务中所有的表包含的列信息.
FarelDb localhost:6800 > use database inner_db_sys
success, affected count: 1
FarelDb localhost:6800 > select * from inner_table_fields
等价于下面的一条命令
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_fields
命令执行内容如下所示
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_fields
name table_name database_name type length column_offset flags default_value position comment
id inner_table_connections inner_db_sys varchar 256 0 1 "" 0 ""
host inner_table_connections inner_db_sys varchar 128 256 0 "" 1 ""
port inner_table_connections inner_db_sys int 4 384 0 "" 2 ""
create_time inner_table_connections inner_db_sys timestamp 8 388 0 "" 3 ""
subscribes inner_table_connections inner_db_sys long 8 396 0 "" 4 ""
rpcs inner_table_connections inner_db_sys long 8 404 0 "" 5 ""
comms inner_table_connections inner_db_sys long 8 412 0 "" 6 ""
name inner_table_databases inner_db_sys varchar 255 0 1 "" 0 ""
tables inner_table_databases inner_db_sys long 8 255 0 "" 1 ""
size inner_table_databases inner_db_sys long 8 263 0 "" 2 ""
inner_flag inner_table_databases inner_db_sys varchar 8 271 0 "" 3 ""
create_time inner_table_databases inner_db_sys timestamp 8 279 0 "" 4 ""
last_modified_time inner_table_databases inner_db_sys timestamp 8 287 0 "" 5 ""
name inner_table_tables inner_db_sys varchar 255 0 1 "" 0 ""
database_name inner_table_tables inner_db_sys varchar 255 255 1 "" 1 ""
rows inner_table_tables inner_db_sys long 8 510 0 "" 2 ""
size inner_table_tables inner_db_sys long 8 518 0 "" 3 ""
inner_flag inner_table_tables inner_db_sys varchar 8 526 0 "" 4 ""
trace_flag inner_table_tables inner_db_sys varchar 8 534 0 "" 5 ""
create_time inner_table_tables inner_db_sys timestamp 8 542 0 "" 6 ""
create_stmt inner_table_tables inner_db_sys text 0 550 0 "" 7 ""
last_modified_time inner_table_tables inner_db_sys timestamp 8 550 0 "" 8 ""
name inner_table_kv_tables inner_db_sys varchar 255 0 1 "" 0 ""
database_name inner_table_kv_tables inner_db_sys varchar 255 255 0 "" 1 ""
keys inner_table_kv_tables inner_db_sys long 8 510 8 "" 2 ""
string_keys inner_table_kv_tables inner_db_sys long 8 518 8 "" 3 ""
hash_keys inner_table_kv_tables inner_db_sys long 8 526 8 "" 4 ""
list_keys inner_table_kv_tables inner_db_sys long 8 534 8 "" 5 ""
set_keys inner_table_kv_tables inner_db_sys long 8 542 8 "" 6 ""
sortset_keys inner_table_kv_tables inner_db_sys long 8 550 8 "" 7 ""
inner_flag inner_table_kv_tables inner_db_sys varchar 8 558 0 "" 8 ""
create_time inner_table_kv_tables inner_db_sys timestamp 8 566 0 "" 9 ""
last_modified_time inner_table_kv_tables inner_db_sys timestamp 8 574 0 "" 10 ""
name inner_table_fields inner_db_sys varchar 255 0 1 "" 0 ""
table_name inner_table_fields inner_db_sys varchar 255 255 1 "" 1 ""
database_name inner_table_fields inner_db_sys varchar 255 510 1 "" 2 ""
type inner_table_fields inner_db_sys varchar 10 765 0 "" 3 ""
length inner_table_fields inner_db_sys long 8 775 8 "" 4 ""
column_offset inner_table_fields inner_db_sys long 8 783 8 "" 5 ""
flags inner_table_fields inner_db_sys int 4 791 8 "" 6 ""
default_value inner_table_fields inner_db_sys text 0 795 0 "" 7 ""
position inner_table_fields inner_db_sys int 4 795 8 "" 8 ""
comment inner_table_fields inner_db_sys text 0 799 0 "" 9 ""
name inner_table_configs inner_db_sys varchar 128 0 1 "" 0 ""
value inner_table_configs inner_db_sys text 0 128 0 "" 1 ""
writeable inner_table_configs inner_db_sys varchar 10 128 0 "" 2 ""
name inner_table_rpcs inner_db_sys varchar 255 0 1 "" 0 ""
host inner_table_rpcs inner_db_sys varchar 128 255 0 "" 1 ""
port inner_table_rpcs inner_db_sys int 4 383 0 "" 2 ""
create_time inner_table_rpcs inner_db_sys timestamp 8 387 0 "" 3 ""
connection_id inner_table_rpcs inner_db_sys varchar 256 395 0 "" 4 ""
id inner_table_comms inner_db_sys long 8 0 5 "" 0 ""
name inner_table_comms inner_db_sys varchar 256 8 0 "" 1 ""
local_host inner_table_comms inner_db_sys varchar 128 264 0 "" 2 ""
local_port inner_table_comms inner_db_sys int 4 392 0 "" 3 ""
type inner_table_comms inner_db_sys varchar 128 396 0 "" 4 ""
remote_host inner_table_comms inner_db_sys varchar 128 524 0 "" 5 ""
remote_port inner_table_comms inner_db_sys int 4 652 0 "" 6 ""
auto_reconnect_milliseconds inner_table_comms inner_db_sys varchar 10 656 0 "" 7 ""
status inner_table_comms inner_db_sys varchar 128 666 0 "" 8 ""
create_time inner_table_comms inner_db_sys timestamp 8 794 0 "" 9 ""
last_connect_time inner_table_comms inner_db_sys timestamp 8 802 0 "" 10 ""
last_disconnect_time inner_table_comms inner_db_sys timestamp 8 810 0 "" 11 ""
connection_id inner_table_comms inner_db_sys varchar 256 818 0 "" 12 ""
subscribe_name inner_table_subscribes inner_db_sys varchar 256 0 1 "" 0 ""
connection_id inner_table_subscribes inner_db_sys varchar 256 256 1 "" 1 ""
create_time inner_table_subscribes inner_db_sys timestamp 8 512 0 "" 2 ""
name inner_table_userscripts inner_db_sys varchar 256 0 1 "" 0 ""
type inner_table_userscripts inner_db_sys varchar 20 256 0 "" 1 ""
enable_flag inner_table_userscripts inner_db_sys varchar 10 276 0 "" 2 ""
content inner_table_userscripts inner_db_sys text 0 286 0 "" 3 ""
cron inner_table_userscripts inner_db_sys varchar 64 286 0 "" 4 ""
subscribe inner_table_userscripts inner_db_sys varchar 256 350 0 "" 5 ""
comment inner_table_userscripts inner_db_sys text 0 606 0 "" 6 ""
status inner_table_userscripts inner_db_sys varchar 10 606 0 "" 7 ""
create_time inner_table_userscripts inner_db_sys timestamp 8 616 0 "" 8 ""
last_run_time inner_table_userscripts inner_db_sys timestamp 8 624 0 "" 9 ""
last_run_duration inner_table_userscripts inner_db_sys long 8 632 0 "" 10 ""
last_error_time inner_table_userscripts inner_db_sys timestamp 8 640 0 "" 11 ""
last_error inner_table_userscripts inner_db_sys text 0 648 0 "" 12 ""
last_error_log inner_table_userscripts inner_db_sys text 0 648 0 "" 13 ""
acc_run_times inner_table_userscripts inner_db_sys long 8 648 0 "" 14 ""
acc_run_success_times inner_table_userscripts inner_db_sys long 8 656 0 "" 15 ""
acc_run_failed_times inner_table_userscripts inner_db_sys long 8 664 0 "" 16 ""
name inner_table_observers inner_db_sys text 0 0 1 "" 0 ""
type inner_table_observers inner_db_sys varchar 20 0 1 "" 1 ""
create_time inner_table_observers inner_db_sys timestamp 8 20 0 "" 2 ""
[87 rows]
列信息表每一列含义详细内容如下表所示:
列名 | 列含义 | 说明 | 备注 |
---|---|---|---|
name | 列名称 | ||
table_name | 列所属表名称 | ||
database_name | 列所属数据库名称 | ||
type | 列数据类型 | 参见下面数据类型表 | |
length | 列长度 | 字节 | |
column_offset | 列偏移 | 在其行数据内存中,列的字节位置 | |
flags | 类型标记 | 1:主键 2:不为空 4:自动增长 8:无符号整型(短整型,长整型,整型) | flags支持多个flag按位或运算得到。 例如某列是主键,且自动增长,则flags为5 |
default_value | 默认值 | ||
position | 列所在行的排序位置 | ||
comment | 注释 |
数据类型表:
type类型 | 类型名称 | fareldb存储大小 | 备注 |
---|---|---|---|
short | 短整型 | 2字节 | |
int | 整形 | 4字节 | |
long | 长整型 | 8字节 | |
float | 浮点型 | 4字节 | |
double | 双精度浮点型 | 8字节 | |
varchar | 字符串 | 自定义 | 需要指定长度 |
blob | 二进制 | 自定义 | 需要指定长度 |
text | 默认值 | 没有长度限制 |
6. 系统配置信息表(inner_table_configs)
登录FarelDB后,可以通过下面的命令查询当前服务中所有的配置信息.
FarelDb localhost:6800 > use database inner_db_sys
success, affected count: 1
FarelDb localhost:6800 > select * from inner_table_configs
等价于下面的一条命令
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_configs
FarelDB运行时,会默认加载安装目录的fareldb.conf配置文件,结合配置文件中的配置信息和内置配置信息后启动运行。配置信息表包括配置名(name)和配置值(value) 两列,如下所示:
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_configs
name value writeable
product_name FarelDb false
version 1.0.4.4 false
release_time 2021-10-30 false
platform x64 false
path C:\Users\Administrator\Desktop\fdb_1.0.4.4_20231030 false
pid 7912 false
host localhost false
port 6800 false
table_increase_size 1000 false
default_database_sys inner_db_sys false
default_kvtable inner_table_kv false
keep_alive_time 30 false
keep_alive_interval 5 false
keep_alive_count 2 false
timeout 0 false
save_interval 60 false
save_file ./rtdb.dump false
use_shared_memory true false
max_connections 10000 false
max_memory 268435456 false
table_trace_memory 4194304 false
table_trace_count 20 false
table_trace_includes "" false
table_trace_excludes "" false
hz 10 false
observe_flag true true
user_script_print_flag true true
user_script_log_flag true true
user_script_log_file ./scriptlog.txt false
user_script_count_call_type_flag true true
user_script_rpc_timeout 600 false
[31 rows]
配置含义详细内容如下表所示:
配置名 | 配置含义 | 默认值 | 可配置 |
---|---|---|---|
product_name | 产品名称 | FarelDb | 否 |
version | 版本号 | 当前版本号 | 否 |
release_time | 发布时间 | 当前版本发布时间 | 否 |
path | 服务运行路径 | 当前服务运行路径 | 否 |
platform | 运行的cpu平台 | x64 | 否 |
pid | 服务进程ID | 当前服务进程的ID | 否 |
host | 主机名 | 服务运行主机IP地址或主机名 | 是 |
port | 端口号 | 服务运行主机端口号 | 是 |
table_increase_size | 每次申请空间大小,单位:字节 | 最小值:0,默认:1000 | 是 |
default_database_sys | 默认系统的数据库 | inner_db_sys | 否 |
default_kvtable | 默认的key-value表 | inner_table_kv | 否 |
keep_alive_time | 客户端建立TCP连接后,若本参数时间内双方 没有任何数据交互,则启动发送心跳包,单位:秒 | 30 | 是 |
keep_alive_interval | 启动发送心跳包后,按照本参数作为发送间隔,单位:秒 | 5 | 是 |
keep_alive_count | 和客户端通信异常并启动发送心跳包后,连续发送次数超过 本参数设定次数仍未获得反馈的则主动断开连接。单位:次 | 2 | 是 |
timeout | 一个客户端连接空闲N秒后,自动关闭此连接, 单位:秒,0表示长时间保持连接 | 0 | 否 |
save_interval | 参数时间内,如果数据库有变化,则持久化,单位:秒 | 60 | 否 |
save_file | 持久化文件路径与名称 | ./rtdb.dump | 否 |
use_shared_memory | 客户端和服务端在同一台服务器运行时, 交互是否采用共享内存来替代TCP,以取得更快速度和效率 | yes | 是 |
max_connections | 最大活动连接数量 | 10000 | 否 |
max_memory | 最大分配内存,单位:字节 | 268435456(256MB) | 否 |
table_trace_memory | 二维表数据追踪的内存限制,单位:字节 | 4194304 (4MB) | 否 |
table_trace_count | 二维表数据追踪的历史条数限制 | 20 | 否 |
table_trace_includes 二维表数据追踪包含的表名称 | 无 | 否 | |
table_trace_excludes | 二维表数据追踪不包含的表名称 | 无 | 否 |
hz | 过期键值清理时,服务器Cpu的利用率占比阈值,CPU的 利用率高于本参数设置的阈值,则推迟过期键值清理单位:% | 10 | 是 |
observe_flag | 是否允许实时观察数据库对象变化情况 | true | 是 |
user_script_print_flag | 是否在服务端console界面显示lua脚本的print字符串 | true | 是 |
user_script_log_flag | 是否允许脚本输出日志到文件 | true | 是 |
user_script_log_file | 脚本输出日志的文件名 | ./scriptlog.txt | 否 |
user_script_count_call_type_flag | CALL类型的脚本在被调用时是否被统计到 inner_db_sys.inner_table_userscripts 表内 | true | 是 |
user_script_rpc_timeout | 用户脚本调用RPC服务后的通道保持时间,单位:秒 | 600 | 否 |
7.RPC信息表(inner_table_rpcs)
登录FarelDB后,可以通过下面的命令查询当前服务中所有远程过程调用的信息
FarelDb localhost:6800 > use database inner_db_sys
success, affected count: 1
FarelDb localhost:6800 > select * from inner_table_rpcs
等价于下面的一条命令
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_rpcs
命令执行结果如下所示
FarelDb localhost:6800 > select * from inner_table_rpcs
name host port create_time connection_id
sum_a_b 127.0.0.10 7000 2023-11-10 17:12:08.784 127.0.0.1_3267
[1 rows]
本例中,服务器上存在一个远程过程调用(RPC)服务,该服务调用的方法名为sum_a_b
连接信息表中,每一列含义详细内容如下表所示:
列名 | 列含义 | 说明 | 备注 |
---|---|---|---|
name | RPC提供调用的函数名 | 全局唯一 | |
host | 提供RPC服务的IP地址 | ||
port | RPC服务使用的端口 | ||
create_time | RPC服务创建的时间 | 整数表示,定义为从格林威治时间1970年01月01日 00时00分00秒000毫秒起至现在的总毫秒数 | |
connection_id | RPC服务与FarelDB连接的ID | FarelDB服务地址+ 与FarelDB连接的RPC端口号 |
8. 通信通道信息表(inner_table_comms)
登录FarelDB后,可以通过下面的命令查询当前服务中所有的通信通道信息
FarelDb localhost:6800 > use database inner_db_sys
success, affected count: 1
FarelDb localhost:6800 > select * from select * from inner_table_comms
等价于下面的一条命令
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_comms
命令执行结果如下所示
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_comms
连接信息表中,每一列含义详细内容如下表所示:
列名 | 列含义 | 说明 | 备注 |
---|---|---|---|
id | |||
name | |||
local_host | 本地主机IP | ||
local_port | 本地主机端口 | ||
type | |||
remote_host | 远程主机IP | ||
remote_port | 远程主机端口 | ||
auto_reconnect_milliseconds | 超时重连的时间 | ||
status | 连接状态 | ||
create_time | 通道创建时间 | 整数表示,定义为从格林威治时间1970年01月01日 00时00分00秒000毫秒起至现在的总毫秒数 | |
last_connect_time | 最后连接时间 | 整数表示,定义为从格林威治时间1970年01月01日 00时00分00秒000毫秒起至现在的总毫秒数 | |
last_disconnect_time | 最后断开连接时间 | 整数表示,定义为从格林威治时间1970年01月01日 00时00分00秒000毫秒起至现在的总毫秒数 | |
connection_id | 连接ID |
9. 订阅发布信息表(inner_table_subscribes)
登录FarelDB后,可以通过下面的命令查询当前服务中所有的订阅发布信息
FarelDb localhost:6800 > use database inner_db_sys
success, affected count: 1
FarelDb localhost:6800 > select * from inner_table_subscribes
等价于下面的一条命令
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_subscribes
命令执行结果如下所示
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_subscribes
subscribe_name connection_id create_time
inner_subscribe_observe_table_inner_db_sys.inner_table_userscripts 127.0.0.1_3366 2023-11-10 17:24:52.031
inner_subscribe_observe_table_inner_db_sys.inner_table_userscripts.name 127.0.0.1_3371 2023-11-10 17:25:52.879
inner_subscribe_observe_kv_key_inner_table_kv.observeKey 127.0.0.1_4488 2023-11-10 17:28:30.147
[3 rows]
本例中订阅了3个条目,分别订阅了一张二维表、一张二维表中的某一列、键值对中的一个键
连接信息表中,每一列含义详细内容如下表所示:
列名 | 列含义 | 说明 | 备注 |
---|---|---|---|
subscribe_name | 订阅的具体内容 | ||
connection_id | 连接ID | FarelDB的IP+客户端连接时自身的端口号 | |
create_time | 创建订阅的时间 | 整数表示,定义为从格林威治时间1970年01月01日 00时00分00秒000毫秒起至现在的总毫秒数 |
10.用户脚本信息表(inner_table_userscripts)
登录FarelDB后,可以通过下面的命令查询当前服务中所有的用户脚本信息
FarelDb localhost:6800 > use database inner_db_sys
success, affected count: 1
FarelDb localhost:6800 > select * from inner_table_userscripts
等价于下面的一条命令
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_userscripts
命令执行结果如下所示
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_userscripts
name type enable_flag content cron subscribe comment status create_time last_run_time last_run_duration last_error_time last_error last_error_log acc_run_times acc_run_success_times acc_run_failed_times
add call true local res=DbUtil.callRpcFunc("sum_a_b", "10","11150")local objRes=JsonUtil.fromJson(res.vals[1])print(objRes.res[1][1]) "" "" "" waiting 2023-11-10 18:01:10.082 1970-01-01 08:00:00.000 0 1970-01-01 08:00:00.000 "" "" 0 0 0
[1 rows]
本例中,服务器中存在1个用户脚本。
连接信息表中,每一列含义详细内容如下表所示:
列名 | 列含义 | 说明 | 备注 |
---|---|---|---|
name | 用户脚本名称 | 其他脚本通过此名称进行调用 | |
type | 调用类型 | 类型见下表 | |
enable_flag | 是否使用 | ||
content | 用户脚本内容 | ||
cron | cron表达式 | 当脚本的调用类型(type)字段为timer时,定时调用脚本 | |
subscribe | 订阅对象 | 当脚本的调用类型(type)字段为subscribe时,定时调用脚本 | |
comment | 用户脚本说明 | ||
status | 用户脚本使用状态 | ||
create_time | 用户脚本创建时间 | 整数表示,定义为从格林威治时间1970年01月01日 00时00分00秒000毫秒起至现在的总毫秒数 | |
last_run_time | 最后一次执行的时间 | 整数表示,定义为从格林威治时间1970年01月01日 00时00分00秒000毫秒起至现在的总毫秒数 | |
last_run_duration | 最后一次执行花费的时间 | 单位:毫秒 | |
last_error_time | 最后一次执行出错的时间 | 整数表示,定义为从格林威治时间1970年01月01日 00时00分00秒000毫秒起至现在的总毫秒数 | |
last_error | 最后一个错误信息 | ||
last_error_log | 最后一个错误日志 | ||
acc_run_times | 用户脚本累计运行次数 | ||
acc_run_success_times | 用户脚本累计执行正确次数 | ||
acc_run_failed_times | 用户脚本累计执行错误次数 |
用户脚本类型:
type类型 | 含义 | 说明 |
---|---|---|
call | 可被其他脚本调用执行 | 可使用DbUtil.runScriptFromServer(name, para1,…) 调用call类型脚本 |
timer | 定时执行 | 定时的时间使用corn表达式表示 |
unique | 独占执行 | |
subscribe | 订阅执行 |
11.观察信息表(inner_table_observers)
登录FarelDB后,可以通过下面的命令查询当前服务中所有的观察信息
FarelDb localhost:6800 > use database inner_db_sys
success, affected count: 1
FarelDb localhost:6800 > select * from inner_table_observers
等价于下面的一条命令
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_observers
命令执行结果如下所示
FarelDb localhost:6800 > select * from inner_db_sys.inner_table_observers
name type create_time
inner_db_sys.inner_table_userscripts table 2023-11-10 17:24:52.206
inner_table_kv.observeKey kv_key 2023-11-10 17:28:31.043
[2 rows]
本例中,有两条观察信息,分别观察了一张二维表inner_table_userscripts和一个名为observeKey的键值对
连接信息表中,每一列含义详细内容如下表所示:
列名 | 列含义 | 说明 | 备注 |
---|---|---|---|
name | 观察对象名称 | ||
type | 观察对象类型 | kv_key:键值对类型 table:二维表类型 | |
create_time | 创建观察 | 整数表示,定义为从格林威治时间1970年01月01日 00时00分00秒000毫秒起至现在的总毫秒数 |