This topic describes the tenant command group of obshell, which is used to create and manage tenants. This command group requires that the OceanBase cluster has been initialized. You can use the -h or --help option in the command to view the help information of the command, and use the -v or --verbose option to view the detailed execution process when the task execution fails.
obshell tenant create
You can use this command to create a business tenant.
${home_path}/bin/obshell tenant create <tenant_name> [-z] [-u] [--unit_num] [--replica_type] [--primary_zone] [--charset] [--collation] [--info] [--read_only]
[--parameters] [--variables] [--whitelist] [--scenario] [--root_password]
# example
# Create a tenant named t1 and specify that the tenant has a full replica in each zone of the cluster and uses the resource pool of the s1 specification.
/home/admin/oceanbase/bin/obshell tenant create t1 -u s1
home_path is the installation directory of OceanBase Database, and the default value of obshell is the bin directory under the installation directory of OceanBase Database. tenant_name is the name of the tenant to be created.
The following table describes the options:
| Option | Required | Type | Default value | Description |
|---|---|---|---|---|
| -z/--zone | No | string | N/A | The zones where the tenant is distributed. If this option is not specified, the tenant is distributed to all zones in the cluster. |
| -u/--unit | No | string | N/A | The resource specifications of the tenant's resource pool.
NoteIf you specify the resource specifications of a zone by using |
| --unit_num | No | int | 1 | The number of units of the tenant in the target zone. The value must be smaller than the number of nodes in the target zone. |
| --replica_type | No | string | FULL | The replica type of the tenant in the target zone. Valid values include FULL (full-featured replica) and READONLY (read-only replica).
NoteIf you specify the replica type of a zone by using |
| --primary_zone | No | string | RANDOM | The primary zone of the tenant, which specifies the priority of the zones that provide read and write services for the tenant. For example, primary_zone ='zone1;zone2,zone3' indicates that the tenant is prioritized to be provided with read and write services by zone1, which has a higher priority than zone2 and zone3, which have the same priority. |
| --scenario | No | string | N/A | The tenant load type. Valid values include:
NoteThis option is supported only in OceanBase clusters of V4.3.0 or later. |
| --variables | No | string | N/A | The system variables of the tenant. The format is max_connections=1000,ob_query_time=1000000. |
| --parameters | No | string | N/A | The configurations of the tenant. The format is backup_data_file_size=2G,arbitration_timeout=10s. |
| --whitelist | No | string | N/A | The access whitelist of the tenant. |
| --root_password | No | string | N/A | The root user password of the tenant. |
| --read_only | No | N/A | N/A | Specifies whether the tenant is readable. |
| --charset | No | string | N/A | The character set of the tenant. |
| --collate | No | string | N/A | The collation of the tenant. |
| --info | No | string | N/A | The information of the tenant. |
obshell tenant drop
You can use this command to drop a tenant.
${home_path}/bin/obshell tenant drop <tenant_name> [--recycle] [-y]
# example
/home/admin/oceanbase/bin/obshell tenant drop t1
home_path is the installation directory of OceanBase Database, and the default value of obshell is the bin directory under the installation directory of OceanBase Database. tenant_name is the name of the tenant to be dropped.
The following table describes the options:
| Option | Required | Type | Default value | Description |
|---|---|---|---|---|
| --recycle | No | N/A | N/A | No value needs to be specified. If this option is specified, the dropped tenant is moved to the recycle bin. |
| -y/--yes | No | N/A | N/A | Specifies whether to skip the confirmation prompt. No value needs to be specified. |
obshell tenant modify
You can use this command to modify the primary zone and access whitelist of a tenant.
${home_path}/bin/obshell tenant modify <tenant_name> [--primary_zone] [--whitelist] [--password] [--old_password] [--new_password]
# example
/home/admin/oceanbase/bin/obshell tenant modify t1 --primary_zone RANDOM --whitelist '%'
home_path is the installation directory of OceanBase Database, and the default value of obshell is the bin directory under the installation directory of OceanBase Database. tenant_name is the name of the tenant to be modified.
The following table describes the options:
| Option | Required | Type | Default value | Description |
|---|---|---|---|---|
| --primary_zone | No | string | N/A | The primary zone of the tenant, which specifies the priority of the zones that provide read and write services for the tenant. For example, primary_zone ='zone1;zone2,zone3' indicates that the tenant is prioritized to be provided with read and write services by zone1, which has a higher priority than zone2 and zone3, which have the same priority. |
| --whitelist | No | string | N/A | The access whitelist of the tenant. |
| --password | No | N/A | N/A | Specifies whether to modify the root user password interactively. No value needs to be specified.
NoteThis option is mutually exclusive with |
| --old_password | No | string | N/A | The current password of the root user. |
| --new_password | No | string | N/A | The new password of the root user. |
obshell tenant lock
You can use this command to lock a tenant. A locked tenant cannot be accessed by users.
${home_path}/bin/obshell tenant lock <tenant_name>
# example
/home/admin/oceanbase/bin/obshell tenant lock t1
home_path is the installation directory of OceanBase Database, and the default value of obshell is the bin directory under the installation directory of OceanBase Database. tenant_name is the name of the tenant to be locked.
obshell tenant unlock
You can use this command to unlock a tenant.
${home_path}/bin/obshell tenant unlock <tenant_name>
# example
/home/admin/oceanbase/bin/obshell tenant unlock t1
home_path is the installation directory of OceanBase Database, and the default value of obshell is the bin directory under the installation directory of OceanBase Database. tenant_name is the name of the tenant to be unlocked.
obshell tenant rename
You can use this command to rename a tenant.
${home_path}/bin/obshell tenant rename <tenant_name> <new_name>
# example
/home/damin/oceanbase/bin/obshell tenant rename t1 t2
home_path is the installation directory of OceanBase Database, and the default value of obshell is the bin directory under the installation directory of OceanBase Database. tenant_name is the name of the tenant to be renamed, and new_name is the new name of the tenant.
obshell tenant replica
You can use this command group to manage tenant replicas.
obshell tenant replica add
You can use this command group to add tenant replicas in batches.
${home_path}/bin/obshell tenant replica add <tenant_name> -z [-u] [--replica_type]
# example
/home/admin/oceanbase/bin/obshell tenant replica add t1 -z zone4,zone5 -u s1
home_path is the installation directory of OceanBase Database. obshell is located in the bin directory of the OceanBase Database installation directory by default. tenant_name is the name of the tenant to add replicas for.
The options are described as follows:
| Option | Required | Data type | Default value | Description |
|---|---|---|---|---|
| -z/--zone | Yes | string | N/A | The zone where the replica to be added is located. Separate multiple zones with commas (,). |
| -u/--unit | No | string | N/A | The resource specifications of the tenant resource pool.
NoteYou can specify the resource specifications of a zone by using |
| --replica_type | No | string | N/A | The replica type of the tenant in the target zone. Valid values include FULL (full-featured replica) and READONLY (read-only replica).
NoteYou can specify the replica type of a zone by using |
obshell tenant replica delete
You can use this command to delete tenant replicas in batches.
${home_path}/bin/obshell tenant replica delete <tenant_name> -z
# example
/home/admin/oceanbase/bin/obshell tenant replica delete t1 -z zone3
home_path is the installation directory of OceanBase Database. obshell is located in the bin directory of the OceanBase Database installation directory by default. tenant_name is the name of the tenant to delete replicas for.
You can specify the -z/--zone option to specify the zones where the replicas to be deleted are located. This option is required. Separate multiple zones with commas (,).
obshell tenant replica modify
You can use this command to modify replica attributes in batches.
${home_path}/bin/obshell tenant replica modify <tenant_name> [-z] [-u] [--unit_num] [--replica_type]
# example
/home/admin/oceanbase/bin/obshell tenant replica modify t1 --unit s2 --unit_num 2
home_path is the installation directory of OceanBase Database. obshell is located in the bin directory of the OceanBase Database installation directory by default. tenant_name is the name of the tenant to modify replica attributes for.
The options are described as follows:
| Option | Required | Data type | Default value | Description |
|---|---|---|---|---|
| -z/--zone | No | string | N/A | The zones where the replicas to be modified are located. Separate multiple zones with commas (,). If this option is not specified, replicas in all zones will be modified. |
| -u/--unit | No | string | N/A | The resource specifications of the tenant resource pool.
NoteYou can specify the resource specifications of a zone by using |
| --unit_num | No | string | N/A | The number of units of the tenant in the target zone. The value must be smaller than the number of nodes in the target zone. |
| --replica_type | No | string | N/A | The replica type of the tenant in the target zone. Valid values include FULL (full-featured replica) and READONLY (read-only replica).
NoteYou can specify the replica type of a zone by using |
obshell tenant parameter
You can use this command group to manage tenant parameters.
obshell tenant parameter set
You can use this command to set tenant parameters.
${home_path}/bin/obshell tenant parameter set <tenant_name> <name=value>
# example
/home/admin/oceanbase/bin/obshell tenant parameter set t1 cpu_quota_concurrency=10,_rowsets_enabled=true
home_path is the installation directory of OceanBase Database. obshell is located in the bin directory of the OceanBase Database installation directory by default; tenant_name is the name of the tenant to configure; parameters are specified in the <name=value> format. Separate multiple parameters with commas (,).
In the example, t1 is the name of the tenant to set parameters for, and cpu_quota_concurrency=10,_rowsets_enabled=true are the parameters for t1.
obshell tenant parameter show
You can use this command to query tenant parameters. Fuzzy queries are supported.
${home_path}/bin/obshell tenant parameter show <tenant_name> <parameter>
# example
/home/admin/oceanbase/bin/obshell tenant parameter show t1 cpu_quota_concurrency
home_path is the installation directory of OceanBase Database. obshell is located in the bin directory of the OceanBase Database installation directory by default; tenant_name is the name of the tenant to query; parameter is the name of the parameter to query. Fuzzy queries are supported.
obshell tenant variable
You can use this command group to manage tenant system variables.
obshell tenant variable set
You can use this command to set tenant global system variables.
${home_path}/bin/obshell tenant variable set <tenant_name> <name=value>
# example
/home/admin/oceanbase/bin/obshell tenant variable set t1 max_connections=10000,recyclebin=true
home_path is the installation directory of OceanBase Database. obshell is located in the bin directory of the OceanBase Database installation directory by default; tenant_name is the name of the tenant to set system variables for; system variables are specified in the <name=value> format. Separate multiple system variables with commas (,).
obshell tenant variable show
You can use this command to query tenant system variables. Fuzzy queries are supported.
${home_path}/bin/obshell tenant variable show <tenant_name> <variable>
# example
/home/admin/oceanbase/bin/obshell tenant variable show t1 max_connections
home_path is the installation directory of OceanBase Database. obshell is located in the bin directory of the OceanBase Database installation directory by default; tenant_name is the name of the tenant to query; variable is the name of the system variable to query. Fuzzy queries are supported.
obshell tenant show
You can use this command to query tenant information.
${home_path}/bin/obshell tenant show [tenant_name] [-d]
# example
/home/admin/oceanbase/bin/obshell tenant show t1
home_path is the installation directory of OceanBase Database. obshell is located in the bin directory of the OceanBase Database installation directory by default. tenant_name is the name of the tenant to query. If this parameter is not specified, information about all tenants in the cluster will be displayed.
You can specify the -d/--show_detail option to specify whether to display the detailed information of tenants. This option does not require a value.
obshell tenant backup
This command is used to set backup configurations for a specified tenant and perform a backup.
${home_path}/bin/obshell tenant backup <tenant_name> [flags]
# example
/home/admin/oceanbase/bin/obshell tenant backup t1 -d /path/to/backup/data --backup_mode incremental --encryption MySecretPassword
home_path is the installation directory of OceanBase Database. obshell is located in the bin directory of the installation directory of OceanBase Database. tenant_name is the name of the tenant to be backed up.
The following table describes the options:
| Option | Required | Type | Default value | Description |
|---|---|---|---|---|
| -d/--data_backup_uri | No | string | None | The destination for backing up the tenant data. If you have set a backup destination before, you can leave this option unspecified. Otherwise, this option is left unspecified. |
| -a/--archive_log_uri | No | string | None | The destination for archiving the tenant logs. If you have set an archive log destination before, you can leave this option unspecified. Otherwise, this option is left unspecified. |
| -m/--backup_mode | No | string | full | The data backup mode. Valid values include full and incremental, indicating full backup and incremental backup, respectively. |
| -c/--log_archive_concurrency | No | int | None | The total number of worker threads for log archiving. |
| -b/--binding | No | string | Optional | The priority mode for archiving and business. Valid values include Optional (business takes priority) and Mandatory (archiving takes priority). If this option is not specified, the Optional mode is used. |
| -i/--piece_switch_interval | No | string | None | The piece switching cycle. Valid values are in the range of [1d, 7d]. |
| -e/--encryption | No | string | None | The password for the backup set after the backup. If this option is specified, you must enter the password when restoring the backup set, and the password cannot be deleted. |
| -l/--archive_lag_target | No | string | None | The maximum allowed latency for log archiving. You must configure the log archive destination before you modify this parameter. |
| -D/--delete_policy | No | string | default | The cleanup strategy. A tenant with a cleanup strategy is automatically cleaned up every hour. The only supported value is default, indicating that only backups in the -d/--data_backup_uri and -a/--archive_log_uri values are cleaned up. |
| -r/--delete_recovery_window | No | string | None | The time window for data recovery. The value must be specified with a time unit. For more information about this parameter, see Parameters for cleaning up backup data. |
| -s/--ha_low_thread_score | No | int | None | The number of worker threads for low-priority HA tasks. Valid values are in the range of [0, 100]. |
| -P/--plus_archive | No | N/A | N/A | Specifies whether to back up archive logs during data backup. No value needs to be specified. If this option is specified, a complete data set containing archive logs will be generated in the final backup directory. |
obshell tenant restore
This command is used to restore a specified tenant.
${home_path}/bin/obshell tenant restore <tenant_name> [flags]
# example
/home/admin/oceanbase/bin/obshell tenant restore mytenant --timestamp "2021-01-01T00:00:00.000+08:00" -z "zone1,zone2,zone3" -d '/path/to/backup/data' -a '/path/to/backup/clog' -u unit1
home_path is the installation directory of OceanBase Database. obshell is located in the bin directory of the installation directory of OceanBase Database. tenant_name is the name of the tenant to be restored.
The following table describes the options:
| Option | Required | Type | Default value | Description |
|---|---|---|---|---|
| -d/--data_backup_uri | Yes | string | None | The data backup path of the source tenant. |
| -z/--zone | No | string | None | The zone distribution of the tenant. If this option is not specified, all zones in the cluster are used. |
| --unit_num | No | int | 1 | The number of units of the tenant in the target zone. The value must be smaller than the number of nodes in the target zone. |
| -u/--unit | No | string | None | The resource specifications of the tenant's resource pool.
NoteYou can specify the resource specifications for a zone by using |
| --replica_type | No | string | FULL | The replica type of the tenant in the target zone. Valid values include FULL (full-featured replica) and READONLY (read-only replica).
NoteYou can specify the replica type for a zone by using |
| --primary_zone | No | string | RANDOM | The primary zone of the tenant, which indicates the priority of the zone that provides read and write services for the tenant. For example, primary_zone ='zone1;zone2,zone3' indicates that the tenant is provided with read and write services by zone1 with the highest priority, followed by zone2 and zone3, which are of the same priority. |
| -T/--timestamp | No | string | None | The timestamp to which the data is restored. The value must be in the format of "2006-01-02T15:04:05.000Z07:00". |
| -S/--scn | No | int | None | The SCN to which the data is restored. |
| -a/--archive_log_uri | No | string | ${data_backup_uri} | The log archive path of the source tenant. If this option is not specified, the value of -d/--data_backup_uri is used. |
| -s/--ha_high_thread_score | No | int | None | The number of worker threads for high-priority HA tasks. Valid values are in the range of [0,100]. |
| -c/--concurrency | No | int | None | The concurrency for data restoration. If this option is not specified, the number of MAX_CPUs allocated to the tenant is used. |
| -D/--decryption | No | string | None | The password for restoring the backup. This option is required only when a password is specified during data backup. |
| -k/--kms_encrypt_info | No | string | None | The encryption information. This option is required only when the data is encrypted or the original key management service can be accessed during restoration. |