| 本专栏全部文章 | https://blog.youkuaiyun.com/tonghu_note/category_11713514.html |
| 总目录 | https://blog.youkuaiyun.com/tonghu_note/article/details/124333034 |
来我的dou音 aa10246666, 看配套视频
一、实战环境
| 节点 cn_node1(协调节点,不存储数据) | postgresql 14.2 | 10.211.55.9 |
| 节点 worker1_node2(工作节点,存储数据) | postgresql 14.2 | 10.211.55.4 |
| 节点 worker2_node3(工作节点,存储数据) | postgresql 14.2 | 10.211.55.6 |
| citus-10.2 / debian 9 | ||
二、SQL命令参考
1、分布表转为普通表
在cn节点,查看系统中现有的Citus表
d1=# select * from citus_tables;
table_name | citus_table_type | distribution_column | colocation_id | table_size | shard_count | table_owner | access_method
------------+------------------+---------------------+---------------+------------+-------------+-------------+---------------
t1 | distributed | id | 2 | 8512 kB | 32 | postgres | heap
t11 | distributed | id | 2 | 8512 kB | 32 | postgres | heap
t2 | reference | <none> | 1 | 13 MB | 1 | postgres | heap
t22 | reference | <none> | 1 | 13 MB | 1 | postgres | heap
(4 rows)
在cn节点,我们将以上的分布表t1在线改为普通表
d1=# SELECT undistribute_table('t1');
NOTICE: creating a new table for public.t1
NOTICE: moving the data of public.t1
NOTICE: dropping the old public.t1
NOTICE: renaming the new table to public.t1
undistribute_table
--------------------
(1 row)
在cn节点,再查看系统中现有的Citus表,可以看到表t1已经转为了普通表
d1=# select * from citus_tables;
table_name | citus_table_type | distribution_column | colocation_id | table_size | shard_count | table_owner | access_method
------------+------------------+-

本文提供了一篇关于Citus的实战学习笔记,详细介绍了如何使用SQL命令进行分布表转换、设置表间亲和性、在worker节点上执行命令、添加和管理worker节点以及查看Citus表的大小和连接数等操作。内容包括从分布表转为普通表的过程,以及在不同worker节点上查看表情况和调整shard分布的方法。
最低0.47元/天 解锁文章
4974

被折叠的 条评论
为什么被折叠?



