其他分享
首页 > 其他分享> > GuassDB 200跨集群访问其他数据平台

GuassDB 200跨集群访问其他数据平台

作者:互联网

本文分别介绍GuassDB跨集群访问远端oracle以及远端MPPDB数据库。因环境有限,这里不列举对接HDFS以及对接Spark功能。

一、对接oracle数据库

1、约束限制

[root@hd06 ~]# su - omm
Last login: Tue Oct 29 16:43:45 CST 2019
[omm@hd06 ~]$ gsql -d postgres -p 25308
gsql ((GaussDB Kernel V300R002C00 build 8a9c1eb6) compiled at 2019-08-01 18:47:38 commit 6093 last mr 10175 )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

postgres=#CREATE DATA SOURCE ds_oracle TYPE 'ORACLE' OPTIONS (DSN 'oracle_DSN', USERNAME 'spwuser', PASSWORD 'redhat', ENCODING 'UTF8');
CREATE DATA SOURCE

使用下面的语句验证是否可以连接到远端oracle数据库:

postgres=# SELECT * FROM exec_on_extension('ds_oracle', 'select * from web_customer;') AS (c1 int,c2 text,c3 text,c4 text);

如下图所示:
GuassDB 200跨集群访问其他数据平台
注:使用“exec_on_extension”之前需要创建Data Source对象。
以下举例将远端的查询结果导入本地表:

[omm@hd06 ~]$ gsql -d postgres -p 25308
gsql ((GaussDB Kernel V300R002C00 build 8a9c1eb6) compiled at 2019-08-01 18:47:38 commit 6093 last mr 10175 )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

postgres=#\c rhnschema
rhnschema=# CREATE TABLE dd AS SELECT * FROM exec_on_extension('ds_oracle', 'select * from rhnpackagefile;') AS (package_id numeric,capability_id numeric,device numeric,
inode numeric,file_mode numeric,username character varying(32),groupname character varying(32),rdev numeric,file_size numeric,mtime timestamp with time zone,
checksum_id numeric,linkto character varying(256),flags numeric,verifyflags numeric,lang character varying(32),created timestamp with time zone,modified timestamp with time zone);
NOTICE:  The 'DISTRIBUTE BY' clause is not specified. Using 'package_id' as the distribution column by default.
HINT:  Please use 'DISTRIBUTE BY' clause to specify suitable data distribution column.
INSERT 0 6304854
rhnschema=# select count(*) from dd;
  count  
---------
 6304854
(1 row)

二、对接远端MPPDB

GaussDB 200支持两种方式访问远端MPPDB数据库集群,包括通过FusionInsight Manager配置方式和创建Foreign Table的方式。

2.1、通过FusionInsight Manager配置方式

[omm@hd03 ~]$ gs_guc check -Z coordinator -I all -c "listen_addresses"
expected guc information: hd02: listen_addresses=NULL: [/srv/BigData/mppdb/data1/coordinator/postgresql.conf]
gs_guc check: hd02: listen_addresses='localhost,192.168.110.24': [/srv/BigData/mppdb/data1/coordinator/postgresql.conf]

Total GUC values: 1. Failed GUC values: 0.
The value of parameter listen_addresses is same on all instances.
    listen_addresses='localhost,192.168.110.24'

如果没有监听业务IP,可以使用下面的方法将其加入监听里:

[omm@hd03 ~]$ gs_guc set -I all -Z coordinator -c "listen_addresses='localhost,192.168.110.24'"                                  
expected instance path: [/srv/BigData/mppdb/data1/coordinator/postgresql.conf]
gs_guc set: listen_addresses='*': [/srv/BigData/mppdb/data1/coordinator/postgresql.conf]

Total instances: 1. Failed instances: 0.
Success to perform gs_guc!

以上只在集群的一个节点有效,其他节点也需要单独操作。另外多个IP之间,用逗号隔开。
在远端集群CN设置认证方式
默认情况下,系统只允许集群各个节点之间互相通信。如果其他网段需要访问就必须设置认证方式,这个在任意一个节点执行即可。

[omm@hd01 ~]$ gs_guc reload -Z coordinator -N all -I all -h "host all all 192.168.120.0/24 sha256"
Begin to perform gs_guc for all coordinators.

Total instances: 3. Failed instances: 0.
Success to perform gs_guc!

设置完成后,重启集群:

[omm@hd01 ~]$ gs_om -t stop && gs_om -t start

GuassDB 200跨集群访问其他数据平台

[omm@hd06 ~]$ gsql -d postgres -p 25308
gsql ((GaussDB Kernel V300R002C00 build 8a9c1eb6) compiled at 2019-08-01 18:47:38 commit 6093 last mr 10175 )
Non-SSL connection (SSL connection is recommended when requiring high-security)
Type "help" for help.

postgres=# CREATE DATA SOURCE ds_mppdb type 'MPPDB' OPTIONS (DSN 'mppdb_DSN', USERNAME 'spwuser', PASSWORD 'abcABC12', ENCODING 'UTF8');
CREATE DATA SOURCE
postgres=# SELECT * FROM exec_on_extension('ds_oracle', 'select * from web_customer;') AS (c1 int,c2 text,c3 text,c4 text);
 c1 |  c2  |             c3              |             c4              
----+------+-----------------------------+-----------------------------
  1 | xzxj | 2019-4-11 8:42:35.094133000 | 2019-4-11 8:42:35.094168000
(1 row)

2.2 使用Foreign Table方式

注意事项:

标签:200,GuassDB,postgres,zip,omm,集群,oracle,hd06
来源: https://blog.51cto.com/candon123/2446396