pg原生和mysql中间件分布式之间路由操作对比
阅读使人充实,讨论使人敏捷,写作使人精确。
温馨提示:文章观点不代表官方。
场景一:通过DN删除CN创建的表
--1.通过CN建表:成功
mysql -h 192.168.8.1 -P 15260 -u dbmgr -p -D testdbcreate table testdb.akentab02 ( a int, b int, c char(20),primary key (a,b),unique key u_1(a,c) );
--2.通过DN删表:成功
mysql -h 192.168.8.2 -P 4005 -u dbmgr -D -d testdbdrop table testdb.akentab02;
--3.通过CN重建表、访问表:异常。
mysql -h 192.168.8.1 -P 15260 -u dbmgr -p -D testdbMySQL [testdb]> show tables; --路由查看表已不存在Empty set (0.03 sec)MySQL [testdb]> create table testdb.akentab02 ( a int, b int, c char(20),primary key (a,b),unique key u_1(a,c) );ERROR 687 (HY000): Proxy ERROR:Table already exists --重建同名表失败,路由信息依旧存在--但该表无法访问、无法drop: Unknown table 'testdb.akentab'MySQL [testdb]> drop table akentab02;ERROR 1051 (42S02): Unknown table 'testdb.akentab'MySQL [testdb]>
场景二:通过CN访问DN创建的表
--1.通过DN建表:成功
mysql -h 192.168.8.2 -P 4005 -u dbmgr -D -d testdb -A -ccreate table testdb.akentab ( a int, b int, c char(20),primary key (a,b),unique key u_1(a,c) );
--2.通过CN访问表:异常
mysql -h 192.168.8.1 -P 15260 -u dbmgr -p -D testdb -A -cMySQL [testdb]> show tables;+------------------+Tables_in_testdb |+------------------+akentab |+------------------+1 row in set (0.02 sec)MySQL [testdb]> select * from testdb.akentab01; ---无法读取到表的路由信息ERROR 660 (HY000): Proxy ERROR:Table:'testdb.akentab01' does not existMySQL [testdb]>
>>> 原生路由分布式
--CN连接,进行建表:成功
[tbase@ ~]$ psql -h 192.168.8.1 -p 11345 akendbpsql (10.6, server 10.0 TBase V2)Type "help" for help.akendb=# create table aken01(id serial,name text);CREATE TABLEakendb=#
--DN连接,尝试drop在CN连接创建的表,提示read-only transaction,拒绝通过直连DN进行DML、DDL操作
[tbase@ ~]$ psql -h 192.168.8.2 -p 11002 -U tbase -d akendbpsql (PostgreSQL 10.0 TBase V2)Type "help" for help.akendb=# \dtList of relationsSchema | Name | Type | Owner--------+-----------------------------+-------+-------public | aken01 | table | tbasepublic | aken02 | table | tbasepublic | aken03 | table | tbasepublic | tab | table | tbasepublic | tbase_subscription | table | tbasepublic | tbase_subscription_parallel | table | tbase(6 rows)akendb=# drop table aken01;ERROR: cannot execute DROP TABLE in a read-only transactionakendb=#akendb=# create table aken04(id serial,name text);ERROR: cannot execute CREATE TABLE in a read-only transactionakendb=#
往期推荐
1.
2.
——让学习成为一种习惯-Aken
