KlustronDB Tenant Creation Configuration Operation Method
KlustronDB Tenant Creation Configuration Operation Method
Note:
Unless otherwise specified, the version numbers in the text can be replaced with the version numbers of any released version. All released versions can be found at: Release_notes.
Overview
This article assumes that users are already familiar with how to create clusters in the KlustronDB database before the experiment, and are familiar with how to perform routine operations on KlustronDB database cluster instances through the web interface provided by the XPanel service.
In the content of this article, we will respectively show how to create tenants in a KlustronDB database cluster instance, create tables in the tenant's database, and insert data into the tables; then perform a logical backup of a schema in one cluster instance within the tenant, and later restore it to another cluster instance of the tenant. This article will include detailed demonstration steps.
01 Environment Description:
The server IP where the XPanel service is installed in this article is 192.168.56.112. Open a browser and enter the address: http://192.168.56.112:18080/KunlunXPanel/#/login?redirect=/dashboard
(The initial login username and password are: super_dba/super_dba. The super_dba password needs to be changed upon first login.)
After logging in, check the 'Cluster List', where the two previously configured clusters are already prepared:
The cluster name is 'cluster', the IP of the Kluscomp instance in this cluster is: 192.168.56.112, and the service port is: 47001

The cluster name is 'cluster2', the Kluscomp instance IP of this cluster is: 192.168.56.113, and the service port is: 47001

Before performing a logical backup, it is necessary to configure the backup storage target in XPanel. Prior to this, the HDFS service needs to be prepared. For the specific configuration process of the HDFS service, please refer to 'KlustronDB HDFS Backup Storage Configuration.' In the environment referred to in this document, the HDFS service has been configured on the 192.168.56.115 node, and afterwards, it is added to the system in XPanel through 'Backup Storage Target Management,' as shown in the following interface:

02 Create Tenant
2.1 Enter in the browser: http://192.168.56.112:18080/KunlunXPanel/#/login?redirect=/cluster, then click 'Register' to enter the tenant registration interface

2.2 Enter the name of the tenant you want to create (for example: kunlunuser) and the password on the tenant registration page, then click 'Register Now'.

2.3 Enter the tenant (for example: kunlunuser) and password on the login screen, then click login

2.4 After logging in, you can view the clusters that have been created: Cluster and Cluster2.

03 Creating Tables and Manipulating Data in the Tenant Database
3.1Connect to the Cluster tenant (_kunlunuser) database, create tables in the database, and insert data into the tables
postgres=# psql -h 192.168.56.112 -p 47001 -U abc postgres
postgres=#\l
postgres=#\c _kunlunuser
postgres=# create table testtable1 (id int primary key);
postgres=# insert into testtable1 select generate_series(1,10);

3.2View data of table testtable1
postgres=#select * from testtable1;

04 Tenant Database Logical Backup
4.1 Click the 'Settings' button on the right side of the cluster

4.2 Click 'Logical Backup' in the left menu bar

4.3 In the backup type, select: schema, and in the backup table, select the schema name to perform a logical backup.

4.4 Click 'Save' to start the backup operation

4.5 After the backup is successful, the prompt message is as follows:

The subsequent schema logic recovery tasks will select the appropriate backup set to complete based on the parameters specified in the recovery operation.
05 Tenant Database Logical Recovery
5.1 Click the 'Settings' button on the right side of cluster2

5.2 Click on 'Logic Recovery' in the left menu bar

5.3 In the recovery type, select 'schema', in 'Target Table Cluster:' choose cluster2 (in this article it is cluster_1716780062_000001), and select the backup record and start time

5.4 Click 'Save' to start executing the schema logic recovery

5.5 After the schema is successfully restored, the prompt message is as follows

06 Tenant Database Recovery Verification
6.1 Connect to the tenant (_kunlunuser) database of Cluster2 and verify that the table testtable1 has been restored in the tenant (_kunlunuser) database of Cluster2

6.2 Check the data in the table testtable1 in the tenant (_kunlunuser) database of Cluster2, the data has been restored

07 Multi-Tenant Resource Isolation Function
The test demonstrated the resource isolation function of multi-tenancy, meaning that one tenant cannot access the data of another tenant.
7.1 First, you need to set enable_catalog_security_policy=true in the Kluscomp instance configuration file, and then restart. The result after setting it is as follows

7.2 Using tenant_kunlunuser to connect to their own database, you can view the tenant's own data information, as shown in the figure below.

7.3 Using tenant_dbuser to connect to the database accessed by another tenant_kunlunuser, tenant_dbuser cannot see the data under tenant_kunlunuser, as shown in the figure below.
_
