一步一步学习OceanBase系列回顾:
第一篇:OceanBase 1.4 集群手动安装步骤
第二篇:obproxy的安装、配置和使用
第三篇:OceanBase 1.4 集群——租户的创建和使用
第四篇:OceanBase1.4 集群扩容
第五篇:OceanBase1.4 集群——租户的扩容
第六篇:OceanBase1.4 集群——节点宕机故障体验
本篇是第七篇 oceanbase 1.4集群跨节点访问问题。
oceanbase 1.4集群跨节点访问问题
ERROR 1235 (0A000): strong consistency across distributed node not supported
数据分布情况:
MySQL [oceanbase]> SELECT t1.tenant_id,t1.tenant_name,t2.database_name,t3.table_id,t3.table_Name,t3.tablegroup_id,t3.part_num,t4.partition_Id,
-> t4.zone,t4.svr_ip,t4.role, round(t4.data_size/1024/1024) data_size_mb
-> from `gv$tenant` t1
-> join `gv$database` t2 on (t1.tenant_id = t2.tenant_id)
-> join gv$table t3 on (t2.tenant_id = t3.tenant_id and t2.database_id = t3.database_id and t3.index_type = 0)
-> left join `gv$partition` t4 on (t2.tenant_id = t4.tenant_id and ( t3.table_id = t4.table_id or t3.tablegroup_id = t4.table_id ) and t4.role in (1,2))
-> where t1.tenant_id = 1001
-> order by t3.tablegroup_id, t3.table_name,t4.partition_Id ;
| tenant_id | tenant_name | database_name | table_id | table_Name | tablegroup_id | part_num | partition_Id | zone | svr_ip | role | data_size_mb |
+-----------+--------------+---------------+------------------+------------+---------------+----------+--------------+-------+---------------+------+--------------+
| 1001 | my_test_tent | testdb | 1100611139453777 | test | -1 | 1 | 0 | zone2 | 192.168.0.89 | 2 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453777 | test | -1 | 1 | 0 | zone3 | 192.168.0.41 | 1 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453777 | test | -1 | 1 | 0 | zone1 | 192.168.0.106 | 2 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 0 | zone2 | 192.168.0.89 | 2 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 0 | zone3 | 192.168.0.41 | 2 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 0 | zone1 | 192.168.0.151 | 1 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 1 | zone2 | 192.168.0.43 | 2 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 1 | zone3 | 192.168.0.41 | 1 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 1 | zone1 | 192.168.0.106 | 2 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 2 | zone3 | 192.168.0.143 | 1 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 2 | zone1 | 192.168.0.106 | 2 | 0 |
| 1001 | my_test_tent | testdb | 1100611139453778 | test_hash | -1 | 3 | 2 | zone2 | 192.168.0.43 | 2 | 0 |
+-----------+--------------+---------------+------------------+------------+---------------+----------+--------------+-------+---------------+------+--------------+
12 rows in set (0.06 sec)
MySQL [oceanbase]>
非分区表test的p0号分区,主副本在zone3下的41节点,两个备副本在zone1的106节点和zone2的89节点。
test_hash分区表的p0分区,主副本在zone1下的151节点,两个备副本在zone2的89节点和zone3下的41节点。
test_hash分区表的p1分区,主副本在zone3下的41节点,两个备副本在zone1的106节点和zone2的43节点。
test_hash分区表的p2分区,主副本在zone3的143节点,两个备副本在zone1下的106节点和zone2的43节点。
$ mysql -h192.168.0.151 -uaps2@my_test_tent#obdemo -P2883 -paps2#12345 -c -A testdb
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MySQL connection id is 524814
Server version: 5.6.25 OceanBase 1.4.60 (r1571952-758a58e85846f9efb907b1c14057204cb6353846) (Built Mar 9 2018 14:32:07)
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MySQL [testdb]>
查询test非分区表,不会涉及跨节点访问,查询不会有问题。
MySQL [testdb]> select * from test;
+------+---------+------+---------------------+
| id | name | age | dt |
+------+---------+------+---------------------+
| 1 | ob1.4.6 | 20 | 2020-08-07 14:05:40 |
| 2 | 张三 | 26 | 1998-06-17 00:00:00 |
| 3 | 李四 | 32 | 1989-10-13 00:00:00 |
| 4 | Tom | 30 | 1990-02-21 00:00:00 |
+------+---------+------+---------------------+
4 rows in set (0.01 sec)
MySQL [testdb]>
查询test_hash分区表,指定分区键,也不会涉及跨节点访问,查询也不会有问题。
MySQL [testdb]> select * from test_hash where id=1;
+----+--------+------+---------------------+
| id | name | age | dt |
+----+--------+------+---------------------+
| 1 | 张三 | 26 | 1998-06-17 00:00:00 |
+----+--------+------+---------------------+
1 row in set (0.01 sec)
MySQL [testdb]>
查询test_hash分区表,当涉及跨节点访问,查询会报错。
MySQL [testdb]> select * from test_hash;
ERROR 1235 (0A000): strong consistency across distributed node not supported
MySQL [testdb]>
从集中式数据库转分布式数据库,会面临一个挑战。一个查询读取的数据跨节点时如何保证强一致(全局一致性版本,或者理解为全局的 scn)。
这个需要数据库内部有全局时间服务(GTS)或者类似机制。 OB 1.4 没有GTS 服务,OB 2.0 以后都有了。
OB 1.4为了保证数据读取是全局一致的,当发现数据跨节点就直接报错。
ERROR 1235 (0A000): strong consistency across distributed node not supported
可以通过 对查询 加 弱一致性读 hint 规避 /*+ read_consistency(weak) */
MySQL [testdb]> select /*+ read_consistency(weak) */ * from test_hash;
+----+--------+------+---------------------+
| id | name | age | dt |
+----+--------+------+---------------------+
| 3 | Tom | 30 | 1990-02-21 00:00:00 |
| 1 | 张三 | 26 | 1998-06-17 00:00:00 |
| 2 | 李四 | 32 | 1989-10-13 00:00:00 |
+----+--------+------+---------------------+
3 rows in set (0.00 sec)
MySQL [testdb]>
1.4版本会存在这个问题,其他功能之前文章已体验了,还是不错的。 高可用、负载均衡都是很完备的。
一步一步学习OceanBase系列
下次实操继续更新~~~~~
复制
最后修改时间:2020-08-12 12:02:04
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。
评论
相关阅读
2025年4月中国数据库流行度排行榜:OB高分复登顶,崖山稳驭撼十强
墨天轮编辑部
1876次阅读
2025-04-09 15:33:27
2025年3月国产数据库大事记
墨天轮编辑部
869次阅读
2025-04-03 15:21:16
OceanBase 接入 MCP 架构:贯通数据孤岛,释放 AI 创新潜能
OceanBase数据库
396次阅读
2025-03-28 15:32:52
OceanBase 单机版发布,针对中小规模业务场景
通讯员
259次阅读
2025-03-28 12:01:19
AI关键场景得到全面支持!OceanBase入选Forrester报告三大领域代表厂商
OceanBase数据库
229次阅读
2025-04-19 22:27:54
数据库管理-第313期 分布式挑战单机,OceanBase单机版试玩(20250411)
胖头鱼的鱼缸
210次阅读
2025-04-10 22:41:56
OceanBase CEO杨冰:2025年分布式数据库将迎来本地部署和国产升级的全面爆发
通讯员
199次阅读
2025-04-03 09:35:26
OceanBase亮相「党政信息化产品技术选型供需对接会」,助力党政关键业务系统升级
OceanBase
190次阅读
2025-03-27 09:55:58
OceanBase单机版产品解读
多明戈教你玩狼人杀
178次阅读
2025-04-11 15:28:33
2024年中国联通软研院OceanBase扩容单一来源采购公示
通讯员
157次阅读
2025-04-21 15:55:59