Verifying OceanBase
After OceanBase is deployed, verify whether OceanBase is available. Before the verification, create a tenant.
OceanBase supports multiple tenants. OceanBase database tenant is a logical concept and resource allocation unit. The data of each tenant is completely isolated from each other and each tenant is similar to a traditional database instance.
OceanBase database tenants are classified into system tenant and common tenant. This section describes how to verify OceanBase by creating a common tenant. By default, OceanBase Database automatically creates a system tenant. The system tenant partly manages the OceanBase database and has access to system metadata tables. OceanBase automatically reserves a specific amount of resources for the system tenant. OceanBase automatically reserves a specific amount of resources for the system tenant.
Follow the steps to create a common tenant and a database:
- Use OBClient to connect to OceanBase as the root user.
obclient -h127.0.0.1 -P2883 -uroot -Doceanbase -A
Modify the following parameters as required:
- 127.0.0.1 and 2883 are the IP address and port number of the OceanBase server respectively.
- root is the database user.
- oceanbase is the name of the OceanBase database.
- Create a resource unit.
- OceanBase 3.1.5:
CREATE RESOURCE UNIT sysbench_unit max_cpu = 122, max_memory = '200G', min_memory = '200G', max_iops = 102400, max_session_num = 30000, max_disk_size = '120G';
Modify the following parameters as required:
- sysbench_unit is the name of the resource unit to be created.
- max_cpu and max_memory indicate the upper limits of the CPU and memory that can be provided by the resource unit using the resource configuration.
- The value range of max_memory is [1073741824, +∞), in bytes. The minimum value is 1 GB.
- The value range of max_iops is [128, +∞).
- The value range of max_session_num is [64, +∞).
- OceanBase 4.2.1:
CREATE RESOURCE UNIT sysbench_unit MEMORY_SIZE='200g',LOG_DISK_SIZE='120g',MIN_CPU=122,MAX_CPU=122,MAX_IOPS=102400,MIN_IOPS=102400;
Modify the following parameters as required:
- sysbench_unit is the name of the resource unit to be created.
- The MEMORY_SIZE field specifies the memory capacity. The minimum value is 1 GB.
- MIN_CPU and min_memory indicate the lower limits of the CPU and memory that can be provided by the resource unit using the resource configuration.
- The LOG_DISK_SIZE field specifies the size of the log drive of a tenant unit. The default value is three times the memory specification. The minimum value is 2 GB.
- The MIN_CPU field specifies the minimum number of CPUs (optional). The default value is the same as MAX_CPU. The minimum value is 1 C.
- The MAX_CPU field specifies the maximum number of CPUs. The minimum value is 1 C.
- The MAX_IOPS field specifies the maximum number of IOPS (optional). The minimum value is 1024.
- The MIN_IOPS field specifies the minimum number of IOPS (optional). The minimum value is 1024.
- OceanBase 3.1.5:
- Create a resource pool.
CREATE RESOURCE POOL sysbench_pool unit = 'sysbench_unit', unit_num = 1, zone_list=('zone1','zone2','zone3');
Modify the following parameters as required:
- sysbench_pool is the name of the resource pool to be created in this example.
- sysbench_unit is the name of the resource unit created in step 2.
- The unit_num field specifies the number of units in a zone to be created. Each unit automatically selects a server load from each zone based on the current cluster load. However, multiple units in the same resource pool cannot be allocated to the same server. That is, the number of units in a resource pool cannot exceed the number of servers in a zone. Specifies the number of units in a zone to be created. Each unit automatically selects a server load from each zone based on the current cluster load. However, multiple units in the same resource pool cannot be allocated to the same server. That is, the number of units in a resource pool cannot exceed the number of servers in a zone.
- The zone_list field specifies the zone to which the to-be-created resource pool belongs. Specifies the zone to which the resource pool to be created belongs. You can query the oceanbase.DBA_OB_ZONES view to obtain the zone information in the cluster. The procedure is as follows:
- Log in to the system tenant of the cluster as the root user. The following is an example. Connect to the database based on the actual requirements.
obclient -h127.0.0.1 -P2883 -uroot -Doceanbase -A
- Query the oceanbase.DBA_OB_ZONES view in the database to obtain zone information in the cluster.
SELECT * FROM oceanbase.DBA_OB_ZONES;
- Log in to the system tenant of the cluster as the root user. The following is an example. Connect to the database based on the actual requirements.
- Create a common tenant.
create tenant sysbench_tenant resource_pool_list=('sysbench_pool'), charset=utf8mb4, replica_num=3, zone_list('zone1', 'zone2', 'zone3'), primary_zone=RANDOM, locality='F@zone1,F@zone2,F@zone3' set variables ob_compatibility_mode='mysql', ob_tcp_invited_nodes='%';
Modify the following parameters as required:
- sysbench_tenant is the name of the tenant to be created in this example.
- sysbench_pool is the resource pool name.
- The charset field specifies the character set.
- The replica_num field specifies the number of replicas. Generally, the value of this parameter is the same as the number of zones and cannot exceed the number of zones.
- The zone_list field specifies the zone to which the to-be-created resource pool belongs.
- The primary_zone field specifies the name of the primary zone where the tenant resides.
- The locality field describes the distribution of replicas in the zones.
- The ob_compatibility_mode field specifies the compatibility mode (MySQL or Oracle) of the tenant upon the tenant creation. If not configured, the default compatibility mode is MySQL.
- Log in to the default system database of the created tenant as the root user.
obclient -h127.0.0.1 -P2883 -uroot@sysbench_tenant -Doceanbase -A
Modify the following parameters as required:
- 127.0.0.1 and 2883 are the IP address and port number of the OceanBase server respectively.
- root is the database user, and sysbench_tenant is the database tenant.
- oceanbase is the name of the OceanBase database.
- Create a database of the sysbench_tenant tenant.