This topic explains the essential steps required before you start development with OBKV-Table. Before you use the OBKV-Table client to access a cluster, you need to create a tenant, database, table, and user. OBKV-Table supports two connection modes: direct connection and OceanBase Database Proxy (ODP). Additional setup requirements vary depending on the connection mode you choose.
Notice
OBKV-Table supports only Java clients.
General preparations
Create a tenant
For more information, see Create a tenant.
Create a database
For more information, see Create a database.
Create a table
For more information, see Create a table.
Create a user
For more information, see Create a user.
Additional preparations for direct connection mode
Create a system tenant user and grant access privileges to the routing table
In direct connection mode, the OBKV-Table client retrieves partition routing information for user tables by accessing the routing table. In OceanBase, only users under the SYS tenant have privileges to access the routing table. You need to create a user under the SYS tenant and grant this user the necessary privileges. The root user has routing table access by default.
Create a user
For more information, see Create a user.
Here is an example of how to create a user named test_sys_user with minimal database privileges.
Use the root user to connect to the SYS tenant by using obclient.
-h specifies the host address. -u specifies the username. -P specifies the port. -p specifies the password. -c specifies not to use the auto-completion feature, which can improve the connection speed and reduce unnecessary system resource consumption. -A specifies to connect to the cluster. -D specifies to connect to the SYS tenant. obclient -h10.10.10.1 -uroot@$obkvcluster -P2883 -p****** -c -A -D SYSCreate a user.
CREATE USER 'test_sys_user'@'%' IDENTIFIED BY 'test_sys_password';
Grant access privileges to the routing table
The user needs SELECT privilege on the following routing tables:
- __all_virtual_table
- __all_virtual_proxy_schema
- __all_tenant
- __all_virtual_proxy_partition_info
- __all_virtual_proxy_partition
- __all_server
- __all_virtual_proxy_sub_partition
- __all_virtual_proxy_server_stat
- DBA_OB_SERVERS
- DBA_OB_ZONES
- CDB_OB_TABLEGROUP_TABLES
- DBA_OB_TENANTS
- CDB_OB_TABLET_TO_LS
After you connect to the database as the SYS tenant, grant the SELECT privilege on the specified routing tables to the test_sys_user user.
GRANT SELECT ON oceanbase.__all_virtual_table TO test_sys_user;
GRANT SELECT ON oceanbase.__all_virtual_proxy_schema TO test_sys_user;
GRANT SELECT ON oceanbase.__all_tenant TO test_sys_user;
GRANT SELECT ON oceanbase.__all_virtual_proxy_partition_info TO test_sys_user;
GRANT SELECT ON oceanbase.__all_virtual_proxy_partition TO test_sys_user;
GRANT SELECT ON oceanbase.__all_server TO test_sys_user;
GRANT SELECT ON oceanbase.__all_virtual_proxy_sub_partition TO test_sys_user;
GRANT SELECT ON oceanbase.__all_virtual_proxy_server_stat TO test_sys_user;
GRANT SELECT ON oceanbase.DBA_OB_SERVERS TO test_sys_user;
GRANT SELECT ON oceanbase.DBA_OB_ZONES TO test_sys_user;
GRANT SELECT ON oceanbase.CDB_OB_TABLEGROUP_TABLES TO test_sys_user;
GRANT SELECT ON oceanbase.DBA_OB_TENANTS TO test_sys_user;
GRANT SELECT ON oceanbase.CDB_OB_TABLET_TO_LS TO test_sys_user;