GBase 8a 9.5.3.27 DBlink配置---源端GBase

news/2025/1/30 13:15:30/

原理图

在这里插入图片描述

1.目标端集群将数据请求由gcluster的5258端口发送至dblink的9898端口
2.Dblink将请求由9898端口转发至源端集群的5258端口
3.源端数据库将接收的请求生成执行计划,由gcluster的5258端口下发至各gnode的5050端口
4.源端的5050端口接收到执行计划进行查询,并将返回结果与目标端集群的gnode的5050端口直接通讯。
5.目标端Gnode将查询结果汇总到gcluster层。

需求描述

多vc模式,源数据库B的t1数据库下存在t11两张表,现需要从数据库A建立DBlink访问数据库B的表。数据库A:
10.185.195.10 coor
10.185.195.101 data
10.185.195.102 data
vc:vc1数据库B:
10.185.195.199 coor
10.185.195.200 data
10.185.195.201 data
vc:vc1

---------------------------------安装---------------------------------------

一、源数据库B操作
### 1.1 建立用户设置默认VC
create user source_user identified by 'source_password';
set default_vc for source_user = vc1;### 1.2 授予库的权限
grant all on vc1.t1.* to source_user;
#select不授权会报错"ERROR 1105 (HY000): Table 'information_schema.table_distribution' doesn't exist",后面两个权限貌似可以不用授权
grant select on gbase.* to gbase_user;
#grant all on gctmpdb.* to gbase_user;
#grant all on vc1.gclusterdb.* to gbase_user;二、数据库A操作
### 2.1 建立用户
create user gbase_user identified by 'gbase_password';### 2.2 创建数据库与授权
create database t1_new;
grant all on vc1.t1_new.* to gbase_user;### 2.3 授权[第一个管理节点]
grant select on gbase.* to gbase_user;
grant all on gctmpdb.* to gbase_user;
grant all on vc1.gclusterdb.* to gbase_user;### 2.4 授权[所有数据节点]
gccli -ugbase -p -h 10.185.195.101  -P5050 -e "grant all on gctmpdb.* to gbase_user"
gccli -ugbase -p -h 10.185.195.102  -P5050 -e "grant all on gctmpdb.* to gbase_user"### 2.5 检查DBlink配置
# 所有管理节点的"[gbasedump]"上方加DBlink的ip与端口,我的DBlink准备配置在数据库A的管理节点上。配置完需要重启集群哦!
[gbase@GBASEMA01 config]$ pwd
/opt/10.185.195.10/gcluster/config
[gbase@GBASEMA01 config]$ cat gbase_8a_gcluster.cnf 
...
gbase_dblink_gateway_ip = 10.185.195.10
gbase_dblink_gateway_port = 9898
gcluster_dblink_direct_data_exchange = 0
...
[gbasedump]三、数据库A DBlink配置
### 3.1 数据源配置[这里写的是源数据库B的信息]
[gbase@GBASEMA01 dataSource]$ pwd
/opt/GBase8a_MPP_Cluster_Gateway_8.5.1.2_build4.26/conf/dataSource
[gbase@GBASEMA01 dataSource]$ vim gbase_link_t1.properties
[gbase1]
dataSource_IP=10.185.195.199
dataSource_port=5258
dataSource_dbname=t1
dataSource_dbtype=gcluster
dataSource_user=source_user
dataSource_pwd=source_password
dataSource_charset=utf8### 3.2 数据库配置[这里写的是数据库A的信息]
[gbase@GBASEMA01 gcluster]$ pwd
/opt/GBase8a_MPP_Cluster_Gateway_8.5.1.2_build4.26/conf/gcluster
[gbase@GBASEMA01 gcluster]$ cat gbase8a_gcluster.properties
[gc1]
gcluster_IP=10.185.195.10
gcluster_port=5258
gcluster_user=gbase_user
gcluster_pwd=gbase_password
gcluster_encode=utf-8[gn2]
gcluster_IP=10.185.195.101
gcluster_port=5050
gcluster_user=gbase_user
gcluster_pwd=gbase_password
gcluster_encode=utf-8[gn2]
gcluster_IP=10.185.195.102
gcluster_port=5050
gcluster_user=gbase_user
gcluster_pwd=gbase_password
gcluster_encode=utf-8### 3.3 启动DBlink[端口是9898可以检查下]
[gbase@GBASEMA01 GBase8a_MPP_Cluster_Gateway_8.5.1.2_build4.26]$ pwd
/opt/GBase8a_MPP_Cluster_Gateway_8.5.1.2_build4.26
[gbase@GBASEMA01 GBase8a_MPP_Cluster_Gateway_8.5.1.2_build4.26]$ bash gbaseGatewayServer.sh start### 3.4 建立DBlink
gbase> use vc vc1;
gbase> create database link gbase_link_t1 connect to '' identified by '' using 'gbase_link_t1';### 3.5 连接测试
[gbase@GBASEMA01 config]$ gccli -ugbase_user -pgbase_password
use vc vc1;
use t1_new;
select * from t11@gbase_link_t1;

---------------------------------验证---------------------------------------

一、数据库权限验证
### 1.1 源数据库B权限验证
gbase> show grants for source_user;           
+-----------------------------------------------------------------------------------------------------------------------------------+
| Grants for source_user@%                                                                                                          |
+-----------------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.*.* TO 'source_user'@'%' IDENTIFIED BY PASSWORD '*A06F45AD457FDD278DBDFB5061E99288102FA8D3' WITH TASK_PRIORITY 2 |
| GRANT ALL PRIVILEGES ON "vc00001"."t1".* TO 'source_user'@'%'                                                                     |
| GRANT ALL PRIVILEGES ON "vc00001"."t2".* TO 'source_user'@'%'                                                                     |
| GRANT SELECT ON "gbase".* TO 'source_user'@'%'                                                                                    |
+-----------------------------------------------------------------------------------------------------------------------------------+### 1.2 数据库B权限验证
# 第一个管理节点
gbase> show grants for gbase_user;
+----------------------------------------------------------------------------------------------------------------------------------+
| Grants for gbase_user@%                                                                                                          |
+----------------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.*.* TO 'gbase_user'@'%' IDENTIFIED BY PASSWORD '*88F4CD22002C0CB142518B20244FBCCA8A94493A' WITH TASK_PRIORITY 2 |
| GRANT SELECT ON "gbase".* TO 'gbase_user'@'%'                                                                                    |
| GRANT ALL PRIVILEGES ON "gctmpdb".* TO 'gbase_user'@'%'                                                                          |
| GRANT ALL PRIVILEGES ON "vc00001"."gclusterdb".* TO 'gbase_user'@'%'                                                             |
| GRANT ALL PRIVILEGES ON "vc00001"."t1_new".* TO 'gbase_user'@'%'                                                                 |
+----------------------------------------------------------------------------------------------------------------------------------+
5 rows in set (Elapsed: 00:00:00.00)# 所有数据节点
[gbase@GBASEMA01 logs]$ gccli -ugbase -p -h 10.185.195.101  -P5050 -e "show grants for  gbase_user"
+--------------------------------------------------------------------------------------------------------------------------------+
| Grants for gbase_user@%                                                                                                        |
+--------------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'gbase_user'@'%' IDENTIFIED BY PASSWORD '*88F4CD22002C0CB142518B20244FBCCA8A94493A' WITH TASK_PRIORITY 2 |
| GRANT ALL PRIVILEGES ON "gctmpdb".* TO 'gbase_user'@'%'                                                                        |
+--------------------------------------------------------------------------------------------------------------------------------+
[gbase@GBASEMA01 logs]$ gccli -ugbase -p -h 10.185.195.102  -P5050 -e "show grants for  gbase_user"
+--------------------------------------------------------------------------------------------------------------------------------+
| Grants for gbase_user@%                                                                                                        |
+--------------------------------------------------------------------------------------------------------------------------------+
| GRANT USAGE ON *.* TO 'gbase_user'@'%' IDENTIFIED BY PASSWORD '*88F4CD22002C0CB142518B20244FBCCA8A94493A' WITH TASK_PRIORITY 2 |
| GRANT ALL PRIVILEGES ON "gctmpdb".* TO 'gbase_user'@'%'                                                                        |
+--------------------------------------------------------------------------------------------------------------------------------+二、数据验证
### 2.1 源数据库B
[gbase@GBASEMA01 ~]$ gccli -usource_user -psource_password -e "use t1;select count(*) from t11;"
+----------+
| count(*) |
+----------+
|        2 |
+----------+### 2.2 数据库A
[gbase@GBASEMA01 logs]$ gccli -ugbase_user -pgbase_passwordGBase client 9.5.3.27.20_patch.9fc3fcec. Copyright (c) 2004-2025, GBase.  All Rights Reserved.gbase> use vc vc1;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)gbase> use t1_new;
Query OK, 0 rows affected (Elapsed: 00:00:00.00)gbase> select * from t11@gbase_link_t1;
+------+------+
| id   | name |
+------+------+
|    1 | mmm  |
|    2 | ddd  |
+------+------+
2 rows in set (Elapsed: 00:00:00.07)三、数据库A:DBlink验证
gbase> select * from gbase.db_links;                                                           
+--------+---------------+-------------+----------+----------+---------------+---------------------+
| owner  | db_link       | dblink_priv | username | password | host          | created             |
+--------+---------------+-------------+----------+----------+---------------+---------------------+
| public | gbase_link_t1 | PUBLIC      |          | NULL     | gbase_link_t1 | 2025-01-24 17:08:29 |
+--------+---------------+-------------+----------+----------+---------------+---------------------+
1 row in set (Elapsed: 00:00:00.08)

http://www.ppmy.cn/news/1567544.html

相关文章

【Validator】字段验证器介绍,及基本使用go案例

Go 语言 Validator 字段验证详解 validator 是 Go 语言中非常流行的一个字段验证库,支持多种数据类型的验证规则,非常适合用于表单校验、API 输入参数校验等场景。 安装 Validator go get github.com/go-playground/validator/v101. 初始化 Validator…

《网络数据安全管理条例》施行,企业如何推进未成年人个人信息保护(下)

文章目录 前言三、全流程推进未成年人个人信息保护1、处理前:未成年人个人信息处理的告知同意2、处理中:加强个人信息处理流程管理3、处理后:落实个人信息保护合规审计四、大型网络平台应每年发布社会责任报告前言 《网数条例》颁布前,我国已针对未成年人个人信息保护陆续…

MySQL核心知识:春招面试数据库要点

在前文中,我们深入剖析了MyBatis这一优秀的持久层框架,了解了它如何实现SQL语句与Java对象的映射,以及其缓存机制等重要内容。而作为数据持久化的核心支撑,数据库的相关知识在Java开发中同样至关重要。MySQL作为最流行的开源关系型…

开源先锋DeepSeek-V3 LLM 大语言模型本地调用,打造自己专属 AI 助手

DeepSeek-V3是一个强大的混合专家 (MoE) 语言模型,总共有 671B 个参数。为了实现高效的推理和经济高效的训练,DeepSeek-V3 采用了多头潜在注意力机制 (MLA) 和 DeepSeekMoE 架构,这些架构在 DeepSeek-V2 中得到了彻底的验证。此外&#xff0c…

LeetCode热题100(八)—— 438.找到字符串中所有字母异位词

LeetCode热题100(八)—— 438.找到字符串中所有字母异位词 题目描述代码实现思路解析 你好,我是杨十一,一名热爱健身的程序员在Coding的征程中,不断探索与成长LeetCode热题100——刷题记录(不定期更新&…

IPhone14 Pro Max设备详情

目录 产品宣传图内部图——后设备详细信息 产品宣传图 内部图——后 设备详细信息 信息收集于HubWeb.cn

flutter入门系列教程<2>:Http请求库-dio的使用

文章目录 11.3 Http请求库-dio11.3.1 引入dio11.3.2 通过dio发起请求11.3.3 实例 实战:注意点1.声明返回参数model2.请求接口3.渲染组件 11.3 Http请求库-dio 本处示例来自:https://book.flutterchina.club/chapter11/dio.html 通过上一节介绍&#xff0…

C++ —— vector 容器

C —— vector 容器 引言vector容器的使用vector容器的嵌套 引言 string只封装了字符数组&#xff0c;而vector容器支持任意类型的数组。 使用vector容器需要包含头文件&#xff1a;#include <vector> vector类模板的声明&#xff1a; template<class T, class Allo…