暂无图片
暂无图片
1
暂无图片
暂无图片
1
暂无图片

[译文] Citus 入门 – 设置四节点集群

原创 Daniel Westermann 2021-08-10
1146

像 PostgreSQL 这样的传统数据库系统的一个问题是,无法轻松地进行垂直扩展。当然,您可以添加读取副本并卸载读取操作,但这要么需要更改应用程序,要么在前面放置一些理解 PostgreSQL 方言并自动将写入路由到主服务器并将读取分布到一个或多个副本(例如pgpool-二)。但即使你有一些东西,你也需要处理复制滞后或者你需要去同步复制(这有它自己的缺点)。垂直缩放的另一个答案是Citus。通过使用 Citus,可以通过简单的安装扩展在 PostgreSQL 中进行分片。

Citus的官方文档非常好,这里就不重复概念了。基本上你需要一个协调器:这是接收来自应用程序的所有流量的节点。所有其他节点都是所谓的工作节点,它们执行实际工作,将结果发送回协调器,协调器最终累积结果。

我们将从一个简单的节点开始,并在本文结尾处以一个协调器节点和三个工作节点结束:
image.png

从一开始就很重要:Citus 不是 PostgreSQL 的一个分支。Citus 作为扩展出现,您可以将它与普通社区 PostgreSQL 一起使用。不需要其他任何东西。当然,你需要安装扩展程序,有预构建包的是,无论是Debian的口味的红帽/ Fedora的口味。在这篇文章中,因为我已经从源代码安装了 PostgreSQL 13.2,我将介绍如何从源代码安装 Citus 扩展。

首先要做的是检查=环境。pg_config需要在 $PATH 中,以便 Citus 扩展在配置/编译时可以找到它:

postgres@ip-10-0-1-23:/home/postgres/ [pg132] which pg_config <font></font> /u01/app/postgres/product/13/db_2/bin/pg_config<font></font>
复制

一旦准备就绪,安装 Citus 扩展的过程就非常简单了。克隆git 存储库(它将为您提供最新的开发快照)或下载最新版本。对于本文的范围,我们将克隆存储库:

postgres@ip-10-0-1-23:/home/postgres/ [pg132] git clone https://github.com/citusdata/citus.git<font></font> Cloning into 'citus'...<font></font> remote: Enumerating objects: 66167, done.<font></font> remote: Counting objects: 100% (1447/1447), done.<font></font> remote: Compressing objects: 100% (638/638), done.<font></font> remote: Total 66167 (delta 942), reused 1166 (delta 804), pack-reused 64720<font></font> Receiving objects: 100% (66167/66167), 33.13 MiB | 25.28 MiB/s, done.<font></font> Resolving deltas: 100% (47834/47834), done.<font></font>
复制

准备好源代码、配置、编译和安装(我在这里为Debian安装软件包,你需要针对其他 Linux 发行版进行调整):

postgres@ip-10-0-1-23:/home/postgres/ [pg132] cd citus/ postgres@ip-10-0-1-23:/home/postgres/citus/ [pg132] sudo apt install libghc-curl-dev postgres@ip-10-0-1-23:/home/postgres/citus/ [pg132] sudo apt install libzstd-dev postgres@ip-10-0-1-23:/home/postgres/citus/ [pg132] ./configure <font></font> checking for a sed that does not truncate output... /usr/bin/sed<font></font> checking for gawk... no<font></font> checking for mawk... mawk<font></font> ...<font></font> config.status: creating src/include/citus_config.h<font></font> config.status: creating src/include/citus_version.h<font></font>
复制

准备编译…

postgres@ip-10-0-1-23:/home/postgres/citus/ [pg132] make<font></font> Makefile:51: warning: overriding recipe for target 'check'<font></font> /u01/app/postgres/product/13/db_2/lib/pgxs/src/makefiles/pgxs.mk:433: warning: ignoring old recipe for target 'check'<font></font> make -C src/backend/distributed/ all<font></font> ...<font></font> -D_GNU_SOURCE -I/usr/include/libxml2 -I/u01/app/postgres/product/13/db_2/include -I/home/postgres/citus/vendor/safestringlib/include -flto=thin -emit-llvm -c -o ../columnar/write_state_management.bc ../columnar/write_state_management.c<font></font> make[1]: Leaving directory '/home/postgres/citus/src/backend/distributed'<font></font>
复制

安装

postgres@ip-10-0-1-23:/home/postgres/citus/ [pg132] make install<font></font> Makefile:51: warning: overriding recipe for target 'check'<font></font> /u01/app/postgres/product/13/db_2/lib/pgxs/src/makefiles/pgxs.mk:433: warning: ignoring old recipe for target 'check'<font></font> make -C src/backend/distributed/ all<font></font> make[1]: Entering directory '/home/postgres/citus/src/backend/distributed'<font></font> ...<font></font> /usr/bin/install -c -m 644 ./src/include/citus_version.h '/u01/app/postgres/product/13/db_2/include/server/'<font></font> /usr/bin/install -c -m 644 /home/postgres/citus/./src/include/distributed/*.h '/u01/app/postgres/product/13/db_2/include/server/distributed/'<font></font>
复制

从现在开始,每个使用这些二进制文件初始化的 PostgreSQL 集群都可以使用 Citus 扩展。像往常一样,我们需要初始化一个新集群:

postgres@ip-10-0-1-23:/home/postgres/citus/ [pg132] mkdir -p /u02/pgdata/13/citus postgres@ip-10-0-1-23:/home/postgres/citus/ [pg132] initdb -D /u02/pgdata/13/citus<font></font> The files belonging to this database system will be owned by user "postgres".<font></font> This user must also own the server process.<font></font> <font></font> The database cluster will be initialized with locale "C.UTF-8".<font></font> The default database encoding has accordingly been set to "UTF8".<font></font> The default text search configuration will be set to "english".<font></font> <font></font> Data page checksums are disabled.<font></font> <font></font> fixing permissions on existing directory /u02/pgdata/13/citus ... ok<font></font> creating subdirectories ... ok<font></font> selecting dynamic shared memory implementation ... posix<font></font> selecting default max_connections ... 100<font></font> selecting default shared_buffers ... 128MB<font></font> selecting default time zone ... Etc/UTC<font></font> creating configuration files ... ok<font></font> running bootstrap script ... ok<font></font> performing post-bootstrap initialization ... ok<font></font> syncing data to disk ... ok<font></font> <font></font> initdb: warning: enabling "trust" authentication for local connections<font></font> You can change this by editing pg_hba.conf or using the option -A, or<font></font> --auth-local and --auth-host, the next time you run initdb.<font></font> <font></font> Success. You can now start the database server using:<font></font> <font></font> pg_ctl -D /u02/pgdata/13/citus -l logfile start<font></font>
复制

启动集群并安装 Citus 扩展:

postgres@ip-10-0-1-23:/home/postgres/citus/ [pg132] echo "shared_preload_libraries = 'citus,pg_stat_statements'" >> /u02/pgdata/13/citus/postgresql.auto.conf postgres@ip-10-0-1-23:/home/postgres/citus/ [pg132] pg_ctl -D /u02/pgdata/13/citus/ start postgres@ip-10-0-1-23:/home/postgres/citus/ [pg132] psql -c "select * from pg_available_extensions where name like '%citus%'" postgres<font></font> name | default_version | installed_version | comment <font></font> -------+-----------------+-------------------+----------------------------<font></font> citus | 10.1-1 | | Citus distributed database<font></font> (1 row)<font></font>
复制

将扩展安装到数据库中的工作方式与任何其他扩展一样(您会注意到该扩展默认创建一个自签名证书):

postgres@ip-10-0-1-23:/home/postgres/citus/ [pg132] psql -c "create database citus" postgres<font></font> CREATE DATABASE<font></font> postgres@ip-10-0-1-23:/home/postgres/citus/ [pg132] psql -c "create extension citus" citus<font></font> 2021-05-05 17:44:02.467 UTC [7306] LOG: citus extension created on postgres without ssl enabled, turning it on during creation of the extension<font></font> 2021-05-05 17:44:02.467 UTC [7306] CONTEXT: SQL statement "SELECT citus_setup_ssl()"<font></font> PL/pgSQL function inline_code_block line 5 at PERFORM<font></font> 2021-05-05 17:44:02.467 UTC [7306] STATEMENT: create extension citus<font></font> 2021-05-05 17:44:02.477 UTC [7306] LOG: no certificate present, generating self signed certificate<font></font> 2021-05-05 17:44:02.477 UTC [7306] CONTEXT: SQL statement "SELECT citus_setup_ssl()"<font></font> PL/pgSQL function inline_code_block line 5 at PERFORM<font></font> 2021-05-05 17:44:02.477 UTC [7306] STATEMENT: create extension citus<font></font> 2021-05-05 17:44:02.586 UTC [7289] LOG: received SIGHUP, reloading configuration files<font></font> 2021-05-05 17:44:02.587 UTC [7289] LOG: parameter "ssl" changed to "on"<font></font> 2021-05-05 17:44:02.587 UTC [7289] LOG: parameter "ssl_ciphers" changed to "ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES128-SHA256:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES128-SHA256:ECDHE-RSA-AES256-SHA384"<font></font> CREATE EXTENSION<font></font> postgres@ip-10-0-1-23:/home/postgres/citus/ [pg132] ls -latr /u02/pgdata/13/citus/server*<font></font> -rw------- 1 postgres postgres 1708 May 5 17:44 /u02/pgdata/13/citus/server.key<font></font> -rw------- 1 postgres postgres 981 May 5 17:44 /u02/pgdata/13/citus/server.crt<font></font>
复制

Citus 扩展已准备就绪:

postgres@ip-10-0-1-23:/home/postgres/citus/ [pg132] psql -c "select citus_version();" citus<font></font> 2021-05-05 17:51:13.927 UTC [7343] LOG: starting maintenance daemon on database 16384 user 10<font></font> 2021-05-05 17:51:13.927 UTC [7343] CONTEXT: Citus maintenance daemon for database 16384 user 10<font></font> citus_version <font></font> -----------------------------------------------------------------------------------------------------------------------<font></font> Citus 10.1devel on x86_64-pc-linux-gnu, compiled by gcc (Debian 8.3.0-6) 8.3.0, 64-bit gitref: master(sha: d0ba12206)<font></font> (1 row)<font></font>
复制

检查进程,有新的后台工作者:

postgres@ip-10-0-1-23:/home/postgres/citus/ [pg132] ps ax | grep Citus<font></font> 7343 ? Ss 0:00 postgres: Citus Maintenance Daemon: 16384/10 <font></font> 7351 pts/0 S+ 0:00 grep Citus<font></font>
复制

是时候使用pgbench创建一些表和数据了:

postgres@ip-10-0-1-23:/home/postgres/ [citus] pgbench -i -s 10 citus<font></font> dropping old tables...<font></font> NOTICE: table "pgbench_accounts" does not exist, skipping<font></font> NOTICE: table "pgbench_branches" does not exist, skipping<font></font> NOTICE: table "pgbench_history" does not exist, skipping<font></font> NOTICE: table "pgbench_tellers" does not exist, skipping<font></font> creating tables...<font></font> generating data (client-side)...<font></font> 1000000 of 1000000 tuples (100%) done (elapsed 4.18 s, remaining 0.00 s)<font></font> vacuuming...<font></font> creating primary keys...<font></font> done in 6.35 s (drop tables 0.00 s, create tables 0.03 s, client-side generate 4.43 s, vacuum 0.32 s, primary keys 1.56 s).<font></font>
复制

到目前为止,这些是标准表,我们可以使用“create_distributed_table”函数将它们转换为分布式表,并提供我们想要分片的列:

postgres@ip-10-0-1-23:/home/postgres/ [citus] psql -c "SELECT create_distributed_table('pgbench_accounts', 'aid')" citus<font></font> NOTICE: Copying data from local table...<font></font> NOTICE: copying the data has completed<font></font> DETAIL: The local data in the table is no longer visible, but is still on disk.<font></font> HINT: To remove the local data, run: SELECT truncate_local_data_after_distributing_table($$public.pgbench_accounts$$)<font></font> create_distributed_table <font></font> --------------------------<font></font> <font></font> (1 row)<font></font> postgres@ip-10-0-1-23:/home/postgres/ [citus] psql -c "SELECT truncate_local_data_after_distributing_table(\$\$public.pgbench_accounts\$\$)" citus<font></font> truncate_local_data_after_distributing_table <font></font> ----------------------------------------------<font></font> <font></font> (1 row)<font></font>
复制

这创建了一个分布式表,可以查询 citus_tables 以获取更多信息:

postgres@ip-10-0-1-23:/home/postgres/ [citus] psql -c "select * from citus_tables" citus<font></font> table_name | citus_table_type | distribution_column | colocation_id | table_size | shard_count | table_owner | access_method <font></font> ------------------+------------------+---------------------+---------------+------------+-------------+-------------+---------------<font></font> pgbench_accounts | distributed | aid | 1 | 151 MB | 32 | postgres | heap<font></font> (1 row)<font></font>
复制

对该表运行一个简单的查询,你会注意到执行计划显示了与通常不同的其他计划节点:

citus=# explain (analyze) select * from pgbench_accounts where aid=100;<font></font> QUERY PLAN <font></font> ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------<font></font> Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=0 width=0) (actual time=12.633..12.635 rows=1 loops=1)<font></font> Task Count: 1<font></font> Tuple data received from nodes: 89 bytes<font></font> Tasks Shown: All<font></font> -> Task<font></font> Tuple data received from node: 89 bytes<font></font> Node: host=localhost port=5432 dbname=citus<font></font> -> Index Scan using pgbench_accounts_pkey_102024 on pgbench_accounts_102024 pgbench_accounts (cost=0.29..8.30 rows=1 width=97) (actual time=0.019..0.021 rows=1 loops=1)<font></font> Index Cond: (aid = 100)<font></font> Planning Time: 0.407 ms<font></font> Execution Time: 0.046 ms<font></font> Planning Time: 0.481 ms<font></font> Execution Time: 12.658 ms<font></font> (13 rows)<font></font>
复制

由于我们目前只有一个节点,所有数据都来自这个节点。是时候向集群添加更多节点了。在执行此操作之前,在其余节点上重复 Citus 安装,以与上述相同的方式初始化一个新的 PostgreSQL 集群,并确保配置了身份验证以便节点可以相互通信 (pg_hba.conf)。在我们添加工作节点之前,我们需要指定哪个节点是协调器节点,我们将为此使用当前的节点

postgres@ip-10-0-1-23:/home/postgres/ [citus] psql -c "SELECT citus_set_coordinator_host('10.0.1.23') " citus<font></font> citus_set_coordinator_host <font></font> ----------------------------<font></font> <font></font> (1 row)<font></font>
复制

现在我们可以添加工人:

postgres@ip-10-0-1-23:/home/postgres/ [citus] psql -c "SELECT * from citus_add_node('10.0.1.16', 5432)" citus<font></font> NOTICE: shards are still on the coordinator after adding the new node<font></font> HINT: Use SELECT rebalance_table_shards(); to balance shards data between workers and coordinator or SELECT citus_drain_node('10.0.1.23',5432); to permanently move shards away from the coordinator.<font></font> citus_add_node <font></font> ----------------<font></font> 2<font></font> (1 row)<font></font> <font></font> postgres@ip-10-0-1-23:/home/postgres/ [citus] psql -c "SELECT * from citus_add_node('10.0.1.220', 5432)" citus<font></font> citus_add_node <font></font> ----------------<font></font> 3<font></font> (1 row)<font></font> <font></font> postgres@ip-10-0-1-23:/home/postgres/ [citus] psql -c "SELECT * from citus_add_node('10.0.1.27', 5432)" citus<font></font> citus_add_node <font></font> ----------------<font></font> 4<font></font> (1 row)<font></font>
复制

跨节点分发数据是您需要手动启动的:

postgres@ip-10-0-1-23:/home/postgres/ [citus] psql -c "SELECT rebalance_table_shards()" citus<font></font> NOTICE: Moving shard 102008 from 10.0.1.23:5432 to 10.0.1.16:5432 ...<font></font> NOTICE: Moving shard 102009 from 10.0.1.23:5432 to 10.0.1.220:5432 ...<font></font> NOTICE: Moving shard 102010 from 10.0.1.23:5432 to 10.0.1.27:5432 ...<font></font> NOTICE: Moving shard 102011 from 10.0.1.23:5432 to 10.0.1.16:5432 ...<font></font> NOTICE: Moving shard 102012 from 10.0.1.23:5432 to 10.0.1.220:5432 ...<font></font> NOTICE: Moving shard 102013 from 10.0.1.23:5432 to 10.0.1.27:5432 ...<font></font> NOTICE: Moving shard 102014 from 10.0.1.23:5432 to 10.0.1.16:5432 ...<font></font> NOTICE: Moving shard 102015 from 10.0.1.23:5432 to 10.0.1.220:5432 ...<font></font> NOTICE: Moving shard 102016 from 10.0.1.23:5432 to 10.0.1.27:5432 ...<font></font> NOTICE: Moving shard 102017 from 10.0.1.23:5432 to 10.0.1.16:5432 ...<font></font> NOTICE: Moving shard 102018 from 10.0.1.23:5432 to 10.0.1.220:5432 ...<font></font> NOTICE: Moving shard 102019 from 10.0.1.23:5432 to 10.0.1.27:5432 ...<font></font> NOTICE: Moving shard 102020 from 10.0.1.23:5432 to 10.0.1.16:5432 ...<font></font> NOTICE: Moving shard 102021 from 10.0.1.23:5432 to 10.0.1.220:5432 ...<font></font> NOTICE: Moving shard 102022 from 10.0.1.23:5432 to 10.0.1.27:5432 ...<font></font> NOTICE: Moving shard 102023 from 10.0.1.23:5432 to 10.0.1.16:5432 ...<font></font> NOTICE: Moving shard 102024 from 10.0.1.23:5432 to 10.0.1.220:5432 ...<font></font> NOTICE: Moving shard 102025 from 10.0.1.23:5432 to 10.0.1.27:5432 ...<font></font> NOTICE: Moving shard 102026 from 10.0.1.23:5432 to 10.0.1.16:5432 ...<font></font> NOTICE: Moving shard 102027 from 10.0.1.23:5432 to 10.0.1.220:5432 ...<font></font> NOTICE: Moving shard 102028 from 10.0.1.23:5432 to 10.0.1.27:5432 ...<font></font> NOTICE: Moving shard 102029 from 10.0.1.23:5432 to 10.0.1.16:5432 ...<font></font> NOTICE: Moving shard 102030 from 10.0.1.23:5432 to 10.0.1.220:5432 ...<font></font> NOTICE: Moving shard 102031 from 10.0.1.23:5432 to 10.0.1.27:5432 ...<font></font> rebalance_table_shards <font></font> ------------------------<font></font> <font></font> (1 row)<font></font>
复制

最后通过排空节点从协调器节点中删除数据:

postgres@ip-10-0-1-23:/home/postgres/ [citus] psql -c "SELECT citus_drain_node('10.0.1.23',5432)" citus<font></font> NOTICE: Moving shard 102032 from 10.0.1.23:5432 to 10.0.1.16:5432 ...<font></font> NOTICE: Moving shard 102033 from 10.0.1.23:5432 to 10.0.1.220:5432 ...<font></font> NOTICE: Moving shard 102034 from 10.0.1.23:5432 to 10.0.1.27:5432 ...<font></font> NOTICE: Moving shard 102035 from 10.0.1.23:5432 to 10.0.1.16:5432 ...<font></font> NOTICE: Moving shard 102036 from 10.0.1.23:5432 to 10.0.1.220:5432 ...<font></font> NOTICE: Moving shard 102037 from 10.0.1.23:5432 to 10.0.1.27:5432 ...<font></font> NOTICE: Moving shard 102038 from 10.0.1.23:5432 to 10.0.1.16:5432 ...<font></font> NOTICE: Moving shard 102039 from 10.0.1.23:5432 to 10.0.1.220:5432 ...<font></font> citus_drain_node <font></font> ------------------<font></font> <font></font> (1 row)<font></font>
复制

再次执行相同的查询,执行计划显示数据不再来自本地节点:

postgres@ip-10-0-1-23:/home/postgres/ [citus] psql citus<font></font> psql (13.2)<font></font> Type "help" for help.<font></font> <font></font> citus=# explain (analyze) select * from pgbench_accounts where aid=100;<font></font> QUERY PLAN <font></font> ------------------------------------------------------------------------------------------------------------------------------------------<font></font> Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=0 width=0) (actual time=20.801..20.803 rows=1 loops=1)<font></font> Task Count: 1<font></font> Tuple data received from nodes: 89 bytes<font></font> Tasks Shown: All<font></font> -> Task<font></font> Tuple data received from node: 89 bytes<font></font> Node: host=10.0.1.220 port=5432 dbname=citus<font></font> -> Index Scan using pgbench_accounts_pkey_102024 on pgbench_accounts_102024 pgbench_accounts (cost=0.29..8.30 rows=1 width=97) <font></font> Index Cond: (aid = 100)<font></font> Planning Time: 1.794 ms<font></font> Execution Time: 1.124 ms<font></font> Planning Time: 2.193 ms<font></font> Execution Time: 20.841 ms<font></font> (13 rows)<font></font>
复制

所有分片均匀分布在节点上:

postgres@ip-10-0-1-23:/home/postgres/ [citus] psql citus<font></font> psql (13.2)<font></font> Type "help" for help.<font></font> <font></font> citus=# explain (analyze) select * from pgbench_accounts where aid=100;<font></font> QUERY PLAN <font></font> ------------------------------------------------------------------------------------------------------------------------------------------<font></font> Custom Scan (Citus Adaptive) (cost=0.00..0.00 rows=0 width=0) (actual time=20.801..20.803 rows=1 loops=1)<font></font> Task Count: 1<font></font> Tuple data received from nodes: 89 bytes<font></font> Tasks Shown: All<font></font> -> Task<font></font> Tuple data received from node: 89 bytes<font></font> Node: host=10.0.1.220 port=5432 dbname=citus<font></font> -> Index Scan using pgbench_accounts_pkey_102024 on pgbench_accounts_102024 pgbench_accounts (cost=0.29..8.30 rows=1 width=97) <font></font> Index Cond: (aid = 100)<font></font> Planning Time: 1.794 ms<font></font> Execution Time: 1.124 ms<font></font> Planning Time: 2.193 ms<font></font> Execution Time: 20.841 ms<font></font> (13 rows)<font></font>
复制

所有分片均匀分布在节点上:

<font style="vertical-align: inherit;"><font style="vertical-align: inherit;">postgres@ip-10-0-1-23 </font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;">:/home/postgres/ [citus] psql -c "\d+" -h 10.0.1.16 citus</font></font><font></font><font style="vertical-align: inherit;"><font style="vertical-align: inherit;"> 关系列表</font></font><font></font> Schema | Name | Type | Owner | Persistence | Size | Description <font></font> --------+-------------------------+-------+----------+-------------+---------+-------------<font></font> public | citus_tables | view | postgres | permanent | 0 bytes | <font></font> public | pgbench_accounts_102008 | table | postgres | permanent | 4176 kB | <font></font> public | pgbench_accounts_102011 | table | postgres | permanent | 4128 kB | <font></font> public | pgbench_accounts_102014 | table | postgres | permanent | 4072 kB | <font></font> public | pgbench_accounts_102017 | table | postgres | permanent | 4120 kB | <font></font> public | pgbench_accounts_102020 | table | postgres | permanent | 4136 kB | <font></font> public | pgbench_accounts_102023 | table | postgres | permanent | 4144 kB | <font></font> public | pgbench_accounts_102026 | table | postgres | permanent | 4152 kB | <font></font> public | pgbench_accounts_102029 | table | postgres | permanent | 4136 kB | <font></font> public | pgbench_accounts_102032 | table | postgres | permanent | 4104 kB | <font></font> public | pgbench_accounts_102035 | table | postgres | permanent | 4104 kB | <font></font> public | pgbench_accounts_102038 | table | postgres | permanent | 4136 kB | <font></font> (12 rows)<font></font> <font></font> postgres@ip-10-0-1-23:/home/postgres/ [citus] psql -c "\d+" -h 10.0.1.220 citus<font></font> List of relations<font></font> Schema | Name | Type | Owner | Persistence | Size | Description <font></font> --------+-------------------------+-------+----------+-------------+---------+-------------<font></font> public | citus_tables | view | postgres | permanent | 0 bytes | <font></font> public | pgbench_accounts_102009 | table | postgres | permanent | 4152 kB | <font></font> public | pgbench_accounts_102012 | table | postgres | permanent | 4144 kB | <font></font> public | pgbench_accounts_102015 | table | postgres | permanent | 4136 kB | <font></font> public | pgbench_accounts_102018 | table | postgres | permanent | 4128 kB | <font></font> public | pgbench_accounts_102021 | table | postgres | permanent | 4128 kB | <font></font> public | pgbench_accounts_102024 | table | postgres | permanent | 4136 kB | <font></font> public | pgbench_accounts_102027 | table | postgres | permanent | 4128 kB | <font></font> public | pgbench_accounts_102030 | table | postgres | permanent | 4144 kB | <font></font> public | pgbench_accounts_102033 | table | postgres | permanent | 4160 kB | <font></font> public | pgbench_accounts_102036 | table | postgres | permanent | 4136 kB | <font></font> public | pgbench_accounts_102039 | table | postgres | permanent | 4152 kB | <font></font> (12 rows)<font></font> <font></font> postgres@ip-10-0-1-23:/home/postgres/ [citus] psql -c "\d+" -h 10.0.1.27 citus<font></font> List of relations<font></font> Schema | Name | Type | Owner | Persistence | Size | Description <font></font> --------+-------------------------+-------+----------+-------------+---------+-------------<font></font> public | citus_tables | view | postgres | permanent | 0 bytes | <font></font> public | pgbench_accounts_102010 | table | postgres | permanent | 4136 kB | <font></font> public | pgbench_accounts_102013 | table | postgres | permanent | 4152 kB | <font></font> public | pgbench_accounts_102016 | table | postgres | permanent | 4128 kB | <font></font> public | pgbench_accounts_102019 | table | postgres | permanent | 4136 kB | <font></font> public | pgbench_accounts_102022 | table | postgres | permanent | 4128 kB | <font></font> public | pgbench_accounts_102025 | table | postgres | permanent | 4144 kB | <font></font> public | pgbench_accounts_102028 | table | postgres | permanent | 4136 kB | <font></font> public | pgbench_accounts_102031 | table | postgres | permanent | 4136 kB | <font></font> public | pgbench_accounts_102034 | table | postgres | permanent | 4128 kB | <font></font> public | pgbench_accounts_102037 | table | postgres | permanent | 4112 kB | <font></font> (11 rows)<font></font>
复制

这就是 Citus 的初始设置。

原文地址:https://blog.dbi-services.com/getting-started-with-citus-setting-up-a-four-node-cluster/?yw

「喜欢这篇文章,您的关注和赞赏是给作者最好的鼓励」
关注作者
【版权声明】本文为墨天轮用户原创内容,转载时必须标注文章的来源(墨天轮),文章链接,文章作者等基本信息,否则作者和墨天轮有权追究责任。如果您发现墨天轮中有涉嫌抄袭或者侵权的内容,欢迎发送邮件至:contact@modb.pro进行举报,并提供相关证据,一经查实,墨天轮将立刻删除相关内容。

评论

功书学剑能几何
暂无图片
1年前
评论
暂无图片 0
踏实一点,能在postgres=# 执行sql语句吗,看的令人悬乎,着急。
1年前
暂无图片 点赞
评论