Citus初步测试
服務(wù)器主機(jī)配置:
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節(jié)點(diǎn):
psql -h 192.168.7.129 -p 5432 -U postgres執(zhí)行下列SQL語(yǔ)句
--創(chuàng)建表 create table test_table(id int, name varchar(16)); --表分片 SELECT master_create_distributed_table('test_table', 'id', 'hash'); --設(shè)定分片個(gè)數(shù)(2)及每個(gè)分片副本數(shù)(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節(jié)點(diǎn) SELECT * from master_get_active_worker_nodes(); --元數(shù)據(jù)查看 SELECT * from master_get_table_metadata('test_table'); --分區(qū)查看 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 行記錄)當(dāng)停止一個(gè)worker_02(192.168.7.131)后,Coordinator仍然能夠正常連接,數(shù)據(jù)也能正常取到,但是執(zhí)行SQL查詢時(shí)會(huì)出現(xiàn)警告,可以推斷出其中的數(shù)據(jù)是從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 行記錄)當(dāng)把兩個(gè)worker都停止后,Coordinator仍然能夠正常連接,但是SQL查詢已經(jīng)取不到數(shù)據(jù)了。
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 《新程序員》:云原生和全面數(shù)字化實(shí)踐50位技術(shù)專家共同創(chuàng)作,文字、視頻、音頻交互閱讀總結(jié)
- 上一篇: 在CentOS7.2上部署基于Postg
- 下一篇: 小孩做艾森克个性测验,原始分为精神质1,