- 验证环境
KADB版本:Greenplum Database 6.0.0 build dev.V003R002C001B0181.d354cc9215
KES版本:KingbaseES V008R006C007B0012
Java版本:openjdk version "1.8.0_262"
- PXF部署
以下操作假设KADB和KES已经部署完成并且启动正常,环境变量设置完成
- 设置环境变量
在mppadin用户的.bashrc文件加入以下内容:
export PATH=$GPHOME/pxf/bin:$PATH
export PXF_CONF=$GPHOME/pxf
- 安装JAVA
修改/home/mppadmin/kadb/pxf/conf/pxf-env.sh文件加入JAVA安装目录:
export JAVA_HOME=/usr/lib/jvm/java-1.8.0-openjdk-1.8.0.262.b10-1.el7.x86_64/jre
注:支持openjdk
- 注册pxf扩展
使用mppadmin用户登录master节点主机执行:
/home/mppadmin/mpp/pxf/bin/pxf cluster register
该命令拷贝pxf扩展文件到集群每一个节点的/home/mppadmin/kadb/share/postgresql/extension目录中,kadb介质已经完成此步骤,命令执行结果如下:
[mppadmin@mdw1 extension]$ pxf cluster register
Installing PXF extension on master host and 0 segment hosts...
PXF extension has been installed on 1 out of 1 host
- 拷贝KES JDBC驱动到KADB所有节点的$PXF_HOME/lib目录
- 创建jdbc连接参数配置文件
在KADB所有segment节点创建下面的文件(jdbc-site.xml文件模板在目录:/home/mppadmin/kadb/pxf/templates
修改改文件的下面参数:
- 启动PXF服务
在KADB master节点执行:
/home/mppadmin/mpp/pxf/bin/pxf cluster start
命令输出如下:
[mppadmin@mdw1 templates]$ pxf cluster start
Starting PXF on master host and 0 segment hosts...
PXF started successfully on 1 out of 1 host
查看pxf server允许状态:
[mppadmin@mdw1 templates]$ pxf cluster status
Checking status of PXF servers on master host and 0 segment hosts...
PXF is running on 1 out of 1 host
- 在测试数据库安装pxf扩展
登录KADB,在测试数据库中执行:
create extension pxf;
- KADB通过PXF连接KES测试性能
- KADB通过pxf外部表访问KES中的数据
- KES创建测试表
test=# \d test
Table "public.test"
Column | Type | Collation | Nullable | Default
--------+----------------------------+-----------+----------+---------
a | integer | | |
b | character varying(20 char) | | |
- 插入测试数据,并记录时间
test=# insert into test values(generate_series(1,1000000),'ccccccccccccccc');
INSERT 0 1000000
Time: 1147.879 ms (00:01.148)
- 登录KADB,创建测试数据库test
创建只读外部表test
create external table test(
a int,
b varchar(20))
location(‘pxf://test?profile =jdbc')
FORMAT 'CUSTOM' (FORMATTER='pxfwritable_import');
- 外部表读性能
postgres=# select count(*) from test1;
count
---------
2000002
(1 row)
Time: 3729.619 ms
KES本地读取性能
test=# select count(*) from test;
count
2000002
(1 row)
Time: 112.064 ms
- KADB通过pxf外部表写入KES数据
- KADB创建可写外部表
create writable external table test(
a int,
b varchar(20))
location('pxf://test?profile=jdbc')
FORMAT 'CUSTOM' (FORMATTER='pxfwritable_export');
- 通过外部表写入数据并记录时间
postgres=# insert into test values(generate_series(1,1000000),'ccccccccccccccc');
INSERT 0 1000000
Time: 11397.677 ms
- KES本地写入并记录时间
test=# insert into test values(generate_series(1,1000000),'ccccccccccccccc');
INSERT 0 1000000
Time: 1147.879 ms (00:01.148)