This section describes how to divide a new six-node physical cluster (having no service data) into two logical clusters. If your physical cluster already has service data, perform operations by referring to Tutorial: Converting a Physical Cluster That Contains Data into a Logical Cluster.
Create a six-node cluster. For details, see Creating a Cluster.
After about 2 minutes, the logical cluster is added.
1 | SELECT group_name FROM PGXC_GROUP; |
1 2 | CREATE USER u1 NODE GROUP "lc1" password '{password}'; CREATE USER u2 NODE GROUP "lc2" password '{password}'; |
1 2 3 | SET ROLE u1 PASSWORD '{password}'; CREATE TABLE u1.t1 (id int); INSERT INTO u1.t1 VALUES (1),(2); |
1 2 3 | SET ROLE u2 PASSWORD '{password}'; CREATE TABLE u2.t2 (id int); INSERT INTO u2.t2 VALUES (1),(2); |
1 | SELECT * FROM u1.t1; |
1 2 3 | SET ROLE dbadmin PASSWORD '{password}'; SELECT p.oid,relname,pgroup,nodeoids FROM pg_class p LEFT JOIN pgxc_class pg ON p.oid = pg.pcrelid WHERE p.relname = 't1'; SELECT p.oid,relname,pgroup,nodeoids FROM pg_class p LEFT JOIN pgxc_class pg ON p.oid = pg.pcrelid WHERE p.relname = 't2'; |
1 2 3 | GRANT usage ON NODE GROUP lc1 TO u2; GRANT usage ON SCHEMA u1 TO u2; GRANT select ON TABLE u1.t1 TO u2; |
Logical clusters implement permission isolation (by node groups) based on physical clusters. To let a user access data across logical clusters, you need to grant the logical cluster (node-group layer) permissions, schema permissions, and table permissions to the user in sequence. If no logical cluster permissions are granted, the error message "permission denied for node group xx" will be displayed.
1 2 | SET ROLE u2 PASSWORD '{password}'; SELECT * FROM u1.t1; |