Citus安装指导
【摘要】 1,集群规划主机名IP角色端口coordinate192.168.0.55coordinate5432worker1192.168.0.65worker5432worker2192.168.0.66worker5432worker3192.168.0.67worker5432worker4192.168.0.68worker5432coordinate:协调节点,一般称为cn,存储所有元数据...
1,集群规划
主机名 |
IP |
角色 |
端口 |
coordinate |
192.168.0.55 |
coordinate |
5432 |
worker1 |
192.168.0.65 |
worker |
5432 |
worker2 |
192.168.0.66 |
worker |
5432 |
worker3 |
192.168.0.67 |
worker |
5432 |
worker4 |
192.168.0.68 |
worker |
5432 |
coordinate:协调节点,一般称为cn,存储所有元数据,不存实际数据。
2,配置pg网络策略
worker节点的pg_hba.conf配置:
# IPv4 local connections:
host all all 192.168.0.0/24 trust
3,安装citus
软件下载:(根据需求选择对应版本)
wget https://github.com/citusdata/citus/archive/v8.1.1.tar.gz
依赖软件包安装:
yum install curl
yum install curl-devel
citus安装:
# 安装
[root@localhost citus-8.1.1]# ./configure
[root@localhost citus-8.1.1]# make
[root@localhost citus-8.1.1]# make install
4,在worker节点安装 citus extension
[postgres@localhost ~]$ psql
psql (10.3)
Type "help" for help.
postgres=# \c test
You are now connected to database "test" as user "postgres"
.test=# create extension citus;
5,协调节点增加worker节点
#仅仅在协调节点(cn)上操作
#添加节点
test=# SELECT * from master_add_node('worker1', 5432);
test=# SELECT * from master_add_node('worker2', 5432);
#查看工作节点:
test=# SELECT * FROM master_get_active_worker_nodes();
node_name | node_port
-----------+-----------
worker2 | 5432
worker4 | 5432
worker1 | 5432
worker3 | 5432
(4 rows)
6,创建分片表
#创建分片表
test=# create table shiptrack(gid serial primary key,tracktime timestamp without time zone,geom geometry(Point,4326));
#配置分片策略
#设置分片数,4个主机,设置分片4,每个主机一张表
test=# set citus.shard_count=4;
# 配置副本数
test=# set citus.shard_replication_factor=2;
test=# SELECT create_distributed_table('shiptrack', 'gid', 'hash');
# 查看分片分布
test=# SELECT * from pg_dist_shard_placement order by shardid, placementid;
shardid | shardstate | shardlength | nodename | nodeport | placementid
---------+------------+-------------+----------+----------+-------------
102016 | 1 | 0 | worker1 | 5432 | 25
102016 | 1 | 0 | worker2 | 5432 | 26
102017 | 1 | 0 | worker2 | 5432 | 27
102017 | 1 | 0 | worker3 | 5432 | 28
102018 | 1 | 0 | worker3 | 5432 | 29
102018 | 1 | 0 | worker4 | 5432 | 30
102019 | 1 | 0 | worker4 | 5432 | 31
102019 | 1 | 0 | worker1 | 5432 | 32
有4个worker,所以数据分片为4,每个分片,做两个副本。通过分片分布,如102016分布在worker1,worker2上,同理102017分布在worker2,worker3上。
参考手册:
【版权声明】本文为华为云社区用户原创内容,转载时必须标注文章的来源(华为云社区)、文章链接、文章作者等基本信息, 否则作者和本社区有权追究责任。如果您发现本社区中有涉嫌抄袭的内容,欢迎发送邮件进行举报,并提供相关证据,一经查实,本社区将立刻删除涉嫌侵权内容,举报邮箱:
cloudbbs@huaweicloud.com
- 点赞
- 收藏
- 关注作者
评论(0)