Citus初步测试
服務器主機配置:
CPU:單核2GHz
RAM:2GB
DISK:30GB HDD
Citus部署配置:
Coordinator X 1 (192.168.7.129)
Worker X 2 (192.168.7.130,192.168.7.131)
基于上一篇文章安裝部署完Citus后。用psql命令登陸Coordinator節點:
psql -h 192.168.7.129 -p 5432 -U postgres執行下列SQL語句
--創建表 create table test_table(id int, name varchar(16)); --表分片 SELECT master_create_distributed_table('test_table', 'id', 'hash'); --設定分片個數(2)及每個分片副本數(2) SELECT master_create_worker_shards('test_table', 2, 2); INSERT INTO test_table VALUES(1,'a'); INSERT INTO test_table VALUES(2,'b'); INSERT INTO test_table VALUES(3,'c'); INSERT INTO test_table VALUES(4,'d');--集群管理 --查看work節點 SELECT * from master_get_active_worker_nodes(); --元數據查看 SELECT * from master_get_table_metadata('test_table'); --分區查看 SELECT * from pg_dist_partition; --分片查看 SELECT * from pg_dist_shard; --分片分布查看 SELECT * from pg_dist_shard_placement;select * from test_table;id | name ----+------1 | a3 | c4 | d2 | b (4 行記錄)當停止一個worker_02(192.168.7.131)后,Coordinator仍然能夠正常連接,數據也能正常取到,但是執行SQL查詢時會出現警告,可以推斷出其中的數據是從worker_01(192.168.7.131)上的副本中取得的。
select * from test_table; WARNING: connection error: 192.168.7.131:5432 描述: could not connect to server: No route to hostIs the server running on host "192.168.7.131" and acceptingTCP/IP connections on port 5432?id | name ----+------1 | a3 | c4 | d2 | b (4 行記錄)當把兩個worker都停止后,Coordinator仍然能夠正常連接,但是SQL查詢已經取不到數據了。
select * from test_table; WARNING: connection error: 192.168.7.131:5432 描述: could not connect to server: No route to hostIs the server running on host "192.168.7.131" and acceptingTCP/IP connections on port 5432? WARNING: could not establish asynchronous connection after 5000 ms WARNING: connection error: 192.168.7.131:5432 描述: could not connect to server: No route to hostIs the server running on host "192.168.7.131" and acceptingTCP/IP connections on port 5432? WARNING: could not establish asynchronous connection after 5000 ms WARNING: connection error: 192.168.7.131:5432 描述: could not connect to server: No route to hostIs the server running on host "192.168.7.131" and acceptingTCP/IP connections on port 5432? ERROR: failed to execute task 4 《新程序員》:云原生和全面數字化實踐50位技術專家共同創作,文字、視頻、音頻交互閱讀總結
- 上一篇: 在CentOS7.2上部署基于Postg
- 下一篇: Citus数据分片分布研究(一 在工作节