如何获取license状态?

用户使用license检测工具获取license状态信息,包括集群节点是否全部具备license文件,license为试用版还是商用版。
如果是试用版license,显示license到期日期,具体语法如下:

a)chkLicense  [-n 192.168.10.1,192.168.10.2,192.168.10.3] -i installpath -u username -p password
b)chkLicense  --hosts=demo.hosts  -f /path /filename -i installpath -u username -p password

其中,
a)用于查看指定一个或少数几个节点的License信息,在终端上输出显示;-n指定需要检查的节点的IP地址,该参数可省略,如省略则 默认检查本节点License信息;
b)用于查看--hosts=demo.hosts中指定的多个节点的License信息,并将结果汇总到-f /path /filename
-f 指定License检查结果存放的文件及路径
-i 指定集群安装路径
-u 指定集群安装的用户名
-p 指定集群安装用户的密码

示例,使用 gbase 用户进行如下操作:

$ chkLicense -n 10.10.10.1,10.10.10.2,10.10.10.3 -u gbase -p gbase -i /opt

其中,10.10.10.1,10.10.10.2,10.10.10.3 为集群节点 IP。
如果为商用版license,输出如下:

=====10.10.10.1=====
is_exist:yes
version:business
is_valid:yes
=====10.10.10.2=====
is_exist:yes
version:business
is_valid:yes
=====10.10.10.3=====
is_exist:yes
version:business
is_valid:yes

======================================================================
Successful node nums: 3
======================================================================

如果为试用版license,输出如下:

=====10.10.10.1=====
is_exist:yes
version:trial
expire_time:20161230
is_valid:yes
=====10.10.10.2=====
is_exist:yes
version:trial
expire_time:20161230
is_valid:yes
=====10.10.10.3=====
is_exist:yes
version:trial
expire_time:20161230
is_valid:yes

======================================================================
Successful node nums: 3
======================================================================

其中,
is_exist用于标识license文件是否存在,如果为yes代表存在,no为不存在;
version用于标识license类型,即是试用版还是商用版,如果为trial代表为试用版license,如果为business代表为商用版license;
is_valid用于标识license是否有效,如果为yes代表license有效,no代表license失效;
expire_time用于标识试用版license的到期日期,只在检测试用版license时才会显示。

如何修改审计日志的表结构?

审计日志表表结构
11.5_r12.4_R1.1版本对审计日志表表结构增加了4列。
原表结构:
start_time 开始执行的时间
user_host 登陆的用户名和host
query_time sql 执行的时间
rows 返回结果集行数
db sql 执行的当前数据库名
sql_text sql 内容
conn_type 用户登陆方式(CAPI、ODBC、JDBC、ADO)

审计日志表新增列的内容如下:
Taskid 全局唯一的任务号
End_time SQL执行结束的时间
Sql_type 标识SQL类型,DDL,DML,DQL,OTHERS
Status 标识SQL执行成功还是失败,SUCCESS,FAILED

项目上手动修改表结构。

修改审计日志表结构的方法
1)由于审计日志表是系统表,需要手工修改每个节点gcluster和gnode的审计日志表的表结构
2)修改审计日志表结构时需要关闭审计日志功能,set global audit_log=off;
3)修改审计日志表结构之前需要执行:set sql_mode=’’;
4)修改表结构有两种方法

  • 方法一,直接在原表上增加列

    Alter self table audit_log add column taskid bigint not null first;
    Alter self table audit_log add column end_time timestamp not null after start_time;
    Alter self table audit_log add column sql_type mediumtext not null after sql_text;
    Alter self table audit_log add column status mediumtext not null after sql_type;

  • 方法二,创建新表,倒数据后,替换原表

    Taskid bigint not null,
    Start_time timestamp not null,
    End_time timestamp not null,
    User_host mediumtext not null,
    Query_time time not null,
    Rows integer not null,
    Db varchar(512) not null,
    Sql_text mediumtext not null,
    Sql_type mediumtext not null,
    Status mediumtext not null,
    Conn_type mediumtext not null
    ) engine =gssys character set utf8 comment=’Audit log’;
    Insert into audit_log_new(start_time, user_host, query_time, rows, db, sql_text, conn_type) select * from audit_log;
    Alter self table audit_log rename to audit_log_bak;
    Alter self table audit_log_new rename to audit_log;
    5)替换完成后需要重新开启审计日志功能: set global audit_log=on;

license与设备硬件是什么关系,为什么服务器硬件变化会使license失效?

8a集群license功能包括试用版license和商用版license,试用版License受时间限制,商用版License在硬件不变换条件下永久有效。
试用版License和商用版License都绑定硬件,目前仅包括节点服务器所有网卡MAC地址,MAC地址变化则License失效,网卡位置变换不作为License失效的条件。
如果集群做节点替换需要重新生成新节点的license,然后导入新节点。

字符可以使用ascii函数获取其ascii码,但中文在utf8编码下一个中文占3个字节,无法通过ascii函数获取其ascii编码,有什么办法解决吗?

使用ord函数获取中文的ascii码,可参考SQL手册中ORD(str)函数的说明。

gbase> select ord('李');
 +------------+
 | ord('李')  |
 +------------+
 |   15113614 |
 +------------+
 1 row in set (Elapsed: 00:00:00.00)

 gbase> select char(ord('李'));
 +------------------+
 | char(ord('李')) |
 +------------------+
 | 李         |
 +------------------+
1 row in set (Elapsed: 00:00:00.00) 

删除数据能否回收rowid?

由于shrink space时,rowid回收,如果不含索引,回收的粒度是DC,即所有被delete的DC对应的rowid都能回收。
以下是做的简单测试:
(1)gnone层总行数6001215

gbase> select count(*) from lineitem;
+----------+
| count(*) |
+----------+
|  6001215 |
+----------+
1 row in set (Elapsed: 00:00:00.14)
gbase> select min(rowid),max(rowid) from lineitem;
+------------+------------+
| min(rowid) | max(rowid) |
+------------+------------+
|          0 |    6001214 |
+------------+------------+
1 row in set (Elapsed: 00:00:00.51)

(2)删除中间1个DC的数据

gbase> delete from lineitem where rowid> 65535 and rowid <2*65536;
Query OK, 65536 rows affected (Elapsed: 00:00:00.11)
gbase> alter table lineitem shrink space;
Query OK, 0 rows affected (Elapsed: 00:00:00.07)

(3)查看rowid

gbase> select min(rowid),max(rowid) from lineitem;
+------------+------------+
| min(rowid) | max(rowid) |
+------------+------------+
|          0 |    5935678 |
+------------+------------+
1 row in set (Elapsed: 00:00:00.45)

(4)插入数据后,查看rowid

gbase> insert into lineitem(l_comment) values('hello');
Query OK, 1 row affected (Elapsed: 00:00:00.40)
gbase> select rowid from lineitem where l_comment='hello';
+---------+
| rowid   |
+---------+
| 5935679 |
+---------+
1 row in set (Elapsed: 00:00:01.60)