Before you use OceanBase Migration Service (OMS) to migrate databases, ensure that a database user has been created for migration or synchronization on all data sources. This user must have the required privileges on both the source and target data sources.
User privileges required when a MySQL database serves as the source
The database user must have read privileges on the database to be migrated. For MySQL databases V5.7 and V8.0, grant the
SHOW VIEWprivilege as well.GRANT SELECT ON <database_name>.* TO '<user_name>';During incremental synchronization from a MySQL database, the database user must have the
REPLICATION CLIENT,REPLICATION SLAVE, andSELECT *.*privileges.GRANT REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO '<user_name>' [WITH GRANT OPTION]; GRANT SELECT ON *.* TO '<user_name>';Note
During incremental synchronization, lacking read privileges on all tables at the source may cause the task to interrupt abnormally.
WITH GRANT OPTIONis an optional parameter.
If you selected Allow OMS to automatically write heartbeat data to this instance during incremental synchronization to resolve high latency issues at the source in scenarios without business writes when adding the MySQL data source, OMS will create and update the
drc.heartbeattable for the corresponding MySQL database. In this case, the MySQL database user must have the privileges to create and write to the table. For more information, see Create and update a heartbeat table.When migrating data from a MySQL database to the MySQL-compatible mode of OceanBase Database, if reverse incremental migration is involved, the migration user must also have the
CREATE,SELECT,INSERT,UPDATE, andDELETEprivileges on the source'stestdatabase.GRANT CREATE,SELECT,INSERT,UPDATE,DELETE ON test.* TO '<user_name>';
User privileges required when a MySQL database serves as the destination
The database user must have the
CREATE,CREATE VIEW,INSERT,UPDATE, andDELETEprivileges on the destination database.GRANT <privilege_type> ON <database_name>.<table_name> TO '<user_name>'@'<host_name>' [WITH GRANT OPTION];ParameterDescriptionprivilege_type Grants operation privileges such as CREATE,INSERT, andUPDATEto the account. To grant all privileges to the account, use ALL.database_name The name of the database. To grant operation privileges on all databases to the account, use an asterisk (*). table_name The name of the table. To grant operation privileges on all tables to the account, use an asterisk (*). user_name The account to be authorized. host_name The host from which the account is allowed to log in. To allow the account to log in from any host, use a percent sign (%). WITH GRANT OPTION Grants the account the privilege to use the GRANTcommand. This parameter is optional.For schema migration, the following privileges are required for migrating views and indexes respectively.
To migrate views, the database user must have the
SELECTprivilege.GRANT SELECT ON <database_name>.* TO '<user_name>';To migrate indexes, the database user must have the
INDEXprivilege.GRANT INDEX ON <database_name>.* TO '<user_name>';
The database user must have trigger privileges.
This privilege is used to check whether triggers exist at the destination. If triggers exist, data inconsistency may occur.
GRANT TRIGGER ON *.* TO '<user_name>';or
GRANT TRIGGER ON <database_name>.* TO '<user_name>';For bidirectional synchronization tasks between the MySQL-compatible mode of OceanBase Database and a MySQL database, the destination must have the
SELECT,CREATE,INSERT, andUPDATEprivileges on theomsdatabase.GRANT SELECT, CREATE, INSERT, UPDATE ON oms.* TO '<user_name>';When creating an incremental verification task, the database user must have the
REPLICATION CLIENTandREPLICATION SLAVEprivileges.GRANT REPLICATION CLIENT, REPLICATION SLAVE ON *.* TO '<user_name>' [WITH GRANT OPTION];
User privileges required when OceanBase Database in MySQL-compatible mode serves as the source
When OceanBase Database in MySQL-compatible mode serves as the source, the migration/sync user must have the following privileges:
If the destination is a message queue such as Kafka, DataHub, or RocketMQ, the user must have the
SELECTprivilege on the source database to be synchronized.If the destination is a database such as MySQL Database or OceanBase Database in MySQL-compatible mode, the user must have the
SELECTprivilege on the source database to be migrated and on theoceanbasedatabase.GRANT SELECT ON <database_name>.* TO '<user_name>'; GRANT SELECT ON oceanbase.* TO '<user_name>';Note
The
SELECTprivilege on theoceanbasedatabase is required only for OceanBase Database in MySQL-compatible mode V4.0.0 and later.For OceanBase Database in MySQL-compatible mode versions earlier than V4.0.0, if you do not grant the
oceanbase.*privilege, you must grant theSELECTprivilege onoceanbase.gv$table.
For incremental data synchronization scenarios, where you need to read incremental log data and database object structure information, create a user under the source sys tenant and grant it the
SELECT ON *.*privilege.GRANT SELECT ON *.* TO <drc_user>;During data migration between instances of OceanBase Database in MySQL-compatible mode, if reverse incremental migration is involved, the migration user must also have the
CREATE,SELECT,INSERT,UPDATE, andDELETEprivileges on the sourcetestdatabase.GRANT CREATE,SELECT,INSERT,UPDATE,DELETE ON test.* TO '<user_name>';
User privileges required when the target database is OceanBase Database in MySQL-compatible mode
When OceanBase Database in MySQL-compatible mode serves as the target, the migration user must have the following privileges:
The
CREATE,CREATE VIEW,DROP VIEW,SELECT,INSERT,UPDATE,ALTER,INDEX, andDELETEprivileges on the target database.GRANT CREATE, SELECT, INSERT, UPDATE, ALTER, INDEX, DELETE, DROP ON *.* TO '<user_name>'; GRANT CREATE VIEW ON *.* TO '<user_name>';The
SELECTprivilege on the entire tenant.GRANT SELECT ON *.* TO '<user_name>';For OceanBase Database in MySQL-compatible mode, when the version is from V4.2.4 to V4.3.0 or from V4.3.3 onwards, serving as the target:
The migration user must have trigger privileges to check whether triggers exist in the target. If triggers exist, data inconsistency may occur.
If you select schema migration when creating a data migration task and the database table structure contains foreign key constraints, the migration user must also have the
REFERENCESprivilege on the database where the tables dependent on foreign keys are located.
You can grant the corresponding database trigger and
REFERENCESprivileges, or global trigger andREFERENCESprivileges.Grant the corresponding database privileges
GRANT TRIGGER,REFERENCES ON <database_name>.* TO '<user_name>';Grant global privileges
GRANT TRIGGER,REFERENCES ON *.* TO '<user_name>';
User privileges required when an Oracle database serves as the source or target
The user privileges required for forward migration when an Oracle database serves as the source and for reverse migration when it serves as the target are the same. After creating a migration user, first select an authorization scheme, then grant additional privileges based on the migration scenario.
Select an authorization scheme
Minimal privileges
When an Oracle database serves as the source, to grant minimal privileges, see Minimal privileges for an Oracle database source.
Non-minimal privileges
Choose an authorization scheme from the following table based on the Oracle database version and whether the environment allows granting the DBA role.
For Oracle Database 12c and later, further confirm whether the database to connect is a pluggable database (PDB), and refer to the corresponding authorization steps for PDB or non-PDB in the selected scheme.
Oracle database versionAllows granting DBA roleDoes not allow granting DBA roleBefore 12c User privileges required for DBA users in Oracle databases earlier than 12c User privileges required for non-DBA users in Oracle databases earlier than 12c 12c and later User privileges required for a DBA user in Oracle Database 12c and later User privileges required for a non-DBA user in Oracle Database 12c and later After completing the above authorization, see Supplemental privileges by scenario to grant the required privileges for the migration scenario.
Procedure for non-minimum authorization
User privileges required for DBA users in Oracle databases earlier than 12c
If your environment allows granting the DBA role to the migration user and the Oracle database version is earlier than 12c, execute the following statement to grant DBA privileges to the migration user:
GRANT DBA TO <user_name>;
User privileges required for non-DBA users in Oracle databases earlier than 12c
If your environment requires more restrictive user authorization and the Oracle database version is earlier than 12c, perform the following operations:
Grant the CONNECT privilege.
GRANT CONNECT TO <user_name>;Grant the migration user the
CREATE SESSION,ALTER SESSION,SELECT ANY TRANSACTION,SELECT ANY TABLE, andSELECT ANY DICTIONARYprivileges.GRANT CREATE SESSION, ALTER SESSION, SELECT ANY TRANSACTION, SELECT ANY TABLE, SELECT ANY DICTIONARY TO <user_name>;Grant the migration user the
LOGMINERprivilege.Note
If the Oracle data source is configured with Obtain incremental data through Kafka, you do not need to grant the
LOGMINERprivilege.GRANT EXECUTE ON SYS.DBMS_LOGMNR TO <user_name>;Grant the migration user the
CREATE TABLEandUNLIMITED TABLESPACEprivileges.GRANT CREATE TABLE, UNLIMITED TABLESPACE TO <user_name>;If the name of the schema to be migrated is the same as
user_name, execute the following statement:GRANT CREATE SEQUENCE,CREATE VIEW TO <user_name>;If the name of the schema to be migrated is different from
user_name, execute the following statement:GRANT CREATE ANY TABLE,CREATE ANY INDEX,DROP ANY TABLE,ALTER ANY TABLE,COMMENT ANY TABLE, DROP ANY INDEX,ALTER ANY INDEX,CREATE ANY SEQUENCE,ALTER ANY SEQUENCE,DROP ANY SEQUENCE, CREATE ANY VIEW,DROP ANY VIEW,INSERT ANY TABLE,DELETE ANY TABLE,UPDATE ANY TABLE TO <user_name>;You can also execute the following statement:
GRANT CREATE ANY TABLE,CREATE ANY INDEX,DROP ANY TABLE,ALTER ANY TABLE,COMMENT ANY TABLE, DROP ANY INDEX,ALTER ANY INDEX,CREATE ANY SEQUENCE,ALTER ANY SEQUENCE,DROP ANY SEQUENCE, CREATE ANY VIEW,DROP ANY VIEW TO <user_name>; # Add the specific table to be migrated to the Oracle database. GRANT DELETE, INSERT, UPDATE ON <database_name>.<table_name> TO <user_name>;
User privileges required for a DBA user in Oracle Database 12c and later
If your environment allows granting the database administrator (DBA) role to the migration user and the Oracle database version is 12c or later, you must determine whether a pluggable database (PDB) of 12c, 18c, or 19c is used.
Non-PDB
Execute the following statement to grant DBA privileges to the migration user:
GRANT DBA TO <user_name>;Execute the following statement to grant the migration user read permission on the
SYS.USER$table:GRANT SELECT ON SYS.USER$ TO <user_name>;
PDB
When migrating from an Oracle database to an OceanBase Oracle database, if the source is a pluggable database (PDB) of 12c, 18c, or 19c, the account used to pull data from the PDB must be a common user.
Execute the following statement to switch to CDB$ROOT:
ALTER SESSION SET CONTAINER=CDB$ROOT;Every common user can connect to the root container (named
CDB$ROOT) and any PDB for which they have connection permissions, and perform related operations.Execute the following statement to grant DBA privileges to the migration user:
GRANT DBA TO C##XXX CONTAINER=ALL;Execute the following statement to grant the migration user read permission on the
SYS.USER$table:GRANT SELECT ON SYS.USER$ TO C##XXX CONTAINER=ALL;
User privileges required for a non-DBA user in Oracle Database 12c and later
If your environment requires strict user authorization and the Oracle database version is 12c or later, perform the following operations:
Non-PDB
Grant the CONNECT privilege.
GRANT CONNECT TO <user_name>;Execute the following statement to grant the migration user read permission on the
SYS.USER$table.GRANT SELECT ON SYS.USER$ TO <user_name>;Grant the migration user the
CREATE SESSION,ALTER SESSION,SELECT ANY TRANSACTION,SELECT ANY TABLE, andSELECT ANY DICTIONARYprivileges.GRANT CREATE SESSION, ALTER SESSION, SELECT ANY TRANSACTION, SELECT ANY TABLE, SELECT ANY DICTIONARY TO <user_name>;Grant the migration user the
LOGMINERprivileges.Note
If the Oracle data source is configured with Obtain incremental data via Kafka, you do not need to grant the
LOGMINERprivileges.GRANT LOGMINING TO <user_name>; GRANT EXECUTE ON SYS.DBMS_LOGMNR TO <user_name>;Grant the migration user the
CREATE TABLEandUNLIMITED TABLESPACEprivileges.GRANT CREATE TABLE, UNLIMITED TABLESPACE TO <user_name>;If the name of the schema to be migrated matches
user_name, execute the following statement.GRANT CREATE SEQUENCE,CREATE VIEW TO <user_name>;If the name of the schema to be migrated does not match
user_name, execute the following statement.GRANT CREATE ANY TABLE,CREATE ANY INDEX,DROP ANY TABLE,ALTER ANY TABLE,COMMENT ANY TABLE, DROP ANY INDEX,ALTER ANY INDEX,CREATE ANY SEQUENCE,ALTER ANY SEQUENCE,DROP ANY SEQUENCE, CREATE ANY VIEW,DROP ANY VIEW,INSERT ANY TABLE,DELETE ANY TABLE,UPDATE ANY TABLE TO <user_name>;
PDB
When migrating from an Oracle database to an OceanBase Oracle database, if the source is a pluggable database (PDB) of version 12c, 18c, or 19c, the account used to pull data from the PDB must be a common user.
Grant the CONNECT privilege.
GRANT CONNECT TO <C##XXX> CONTAINER=ALL;Execute the following statement to grant the migration user read permission on the
SYS.USER$table.GRANT SELECT ON SYS.USER$ TO <C##XXX> CONTAINER=ALL;Grant the migration user the
CREATE SESSION,ALTER SESSION,SELECT ANY TRANSACTION,SELECT ANY TABLE, andSELECT ANY DICTIONARYprivileges.GRANT CREATE SESSION, ALTER SESSION, SELECT ANY TRANSACTION, SELECT ANY TABLE, SELECT ANY DICTIONARY TO <C##XXX> CONTAINER=ALL;Grant the migration user the
LOGMINERprivileges.Note
If the Oracle data source is configured with Obtain incremental data via Kafka, you do not need to grant the
LOGMINERprivileges.GRANT LOGMINING TO <C##XXX> CONTAINER=ALL; GRANT EXECUTE ON SYS.DBMS_LOGMNR TO <C##XXX> CONTAINER=ALL;Grant the migration user the
CREATE TABLEandUNLIMITED TABLESPACEprivileges.GRANT CREATE TABLE, UNLIMITED TABLESPACE TO <C##XXX> CONTAINER=ALL;If the name of the schema to be migrated matches
C##XXX, execute the following statement.GRANT CREATE SEQUENCE, CREATE VIEW TO <C##XXX> CONTAINER=ALL;If the name of the schema to be migrated does not match
C##XXX, execute the following statement.GRANT CREATE ANY TABLE, CREATE ANY INDEX, DROP ANY TABLE, ALTER ANY TABLE, COMMENT ANY TABLE, DROP ANY INDEX, ALTER ANY INDEX,CREATE ANY SEQUENCE,ALTER ANY SEQUENCE, DROP ANY SEQUENCE, CREATE ANY VIEW, DROP ANY VIEW, INSERT ANY TABLE, DELETE ANY TABLE, UPDATE ANY TABLE TO <C##XXX> CONTAINER=ALL;
Supplemental privileges by scenario
Grant the following corresponding privileges based on whether the Oracle database serves as the source or target, and the operations to be performed.
Notice
For an ADG standby database, granted privileges may sometimes fail to take effect. In this case, you need to execute the command ALTER SYSTEM FLUSH SHARED_POOL; on the standby database to flush the Shared Pool.
Source Oracle database DDL query privilege description
When an Oracle database serves as the source, if you use the DBMS_METADATA.GET_DDL package function to query DDL, the following privileges are required.
GRANT SELECT_CATALOG_ROLE TO <user_name>;
An example statement for querying DDL using the DBMS_METADATA.GET_DDL package function is shown below.
SELECT DBMS_METADATA.GET_DDL('TABLE', '<table_name>', '<schema_name>') FROM DUAL;
Source Oracle database PL object privilege description
When migrating PL objects from an Oracle database to the Oracle compatible mode of OceanBase Database, the source PL objects require the following privileges.
GRANT CREATE ANY PROCEDURE TO <user_name>;
GRANT CREATE ANY TYPE TO <user_name>;
GRANT SELECT ANY SEQUENCE TO <user_name>;
GRANT CREATE ANY TRIGGER TO <user_name>;
Target Oracle database trigger privilege description
When an Oracle database serves as the target, in addition to granting the corresponding privileges based on different versions, the CREATE ANY TRIGGER privilege is also required.
GRANT CREATE ANY TRIGGER TO <user_name>;
Target Oracle database sequence privilege description
When an Oracle database serves as the target, if schema migration is required and the tables to be migrated contain identity columns, the SELECT and CREATE privileges on sequences are also required.
GRANT SELECT ANY SEQUENCE TO <user_name>;
GRANT CREATE ANY SEQUENCE TO <user_name>;
User privileges required when OceanBase Database in Oracle compatible mode serves as the source
When OceanBase Database in Oracle compatible mode serves as the source, the migration/sync user must have the following privileges:
For OceanBase Database in Oracle compatible mode versions earlier than V2.2.70, the required privilege for the source migration user is
GRANT SELECT ON *.* TO '<user_name>';.For OceanBase Database in Oracle compatible mode V2.2.70 and later, the required privilege for the source migration user is
GRANT DBA TO '<user_name>';.For OceanBase Database in Oracle compatible mode V4.0.0 and later, the source migration user must also have the
SELECTprivilege on theDBA_OB_ARCHIVELOGrole.GRANT SELECT ON DBA_OB_ARCHIVELOG TO '<user_name>';For OceanBase Database in Oracle compatible mode V4.2.0 and later, the source migration user must also have the
SELECTprivilege on theDBA_OB_TABLE_LOCATIONSrole.GRANT SELECT ON DBA_OB_TABLE_LOCATIONS TO '<user_name>';
User privileges required for migrating PL objects from the source
When migrating PL objects such as sequences, types, stored procedures, functions, packages, triggers, and synonyms from OceanBase Database in Oracle compatible mode, if the migration user is not granted the DBA role, the source user must also have the following privileges.
GRANT SELECT ON SYS.DBA_OBJECTS TO '<user_name>';
GRANT SELECT ON SYS.DBA_SOURCE TO '<user_name>';
GRANT SELECT ON SYS.DBA_SEQUENCES TO '<user_name>';
When reading triggers across schemas, the source user must also have the CREATE ANY TRIGGER privilege.
GRANT CREATE ANY TRIGGER TO '<user_name>';
User privileges required when the target is an OceanBase Database in Oracle compatible mode
The user privileges required vary depending on the version of the OceanBase Database in Oracle compatible mode.
User privileges required for OceanBase Database in Oracle compatible mode V2.2.5 or V2.2.3
You can grant privileges to the migration user by using one of the following two methods:
Method 1
Execute the following statement to grant all privileges to the migration user. This method is simpler but grants higher-level privileges.
GRANT ALL PRIVILEGES ON *.* TO '<user_name>';
Method 2
Grant the
SELECTprivilege on system views under SYS to the migration user.GRANT SELECT ON SYS.* TO '<user_name>';Grant various privileges on business database tables to the migration user. If multiple business databases exist, grant the privileges separately.
GRANT SELECT, UPDATE, DELETE ON <db_name>.* TO '<user_name>'; GRANT CREATE, INDEX, ALTER ON <db_name>.* TO '<user_name>';
User privileges required for OceanBase Database in Oracle compatible mode V2.2.7 and later
You can grant privileges to the migration user by using one of the following two methods:
Method 1
Execute the following statement. This method is simpler but grants higher-level privileges to the user.
GRANT DBA TO '<user_name>';Method 2
Grant various privileges on business database tables to the user. If multiple business databases exist, grant the privileges separately.
GRANT CONNECT TO '<user_name>'; GRANT CREATE SESSION, ALTER SESSION, SELECT ANY TABLE, SELECT ANY DICTIONARY TO '<user_name>'; GRANT CREATE ANY TABLE, CREATE ANY INDEX, CREATE ANY VIEW, INSERT ANY TABLE, UPDATE ANY TABLE, ALTER ANY TABLE, DELETE ANY TABLE, DROP ANY INDEX TO '<user_name>';
User privileges required when migrating source PL objects to the target
When migrating PL objects from an Oracle database to an OceanBase Database in Oracle compatible mode, the target OceanBase Database in Oracle compatible mode must have the following privileges:
GRANT CREATE ANY PROCEDURE TO '<user_name>';
GRANT CREATE ANY SYNONYM TO '<user_name>';
GRANT CREATE ANY SEQUENCE TO '<user_name>';
GRANT CREATE ANY TRIGGER TO '<user_name>';
GRANT CREATE ANY TYPE TO '<user_name>';
Note
When an OceanBase Database in Oracle compatible mode V3.0.0 or later serves as the target, the CREATE ANY TRIGGER privilege is required.
User privileges required when a DB2 LUW database serves as the source or destination
When a DB2 LUW database serves as the source or destination, the migration user must have administrator (DBADM) privileges.
Connect to the target database.
db2 CONNECT TO <database_name>Grant database administrator privileges to the migration user.
db2 GRANT DBADM ON DATABASE TO USER <user_name>;
User privileges required when a PostgreSQL database serves as the source
During schema migration from a PostgreSQL database to an OceanBase Database instance in MySQL or Oracle compatible mode, you must grant the SELECT privilege on tables and views to the migration user.
During incremental synchronization from a PostgreSQL database to an OceanBase Database instance in MySQL or Oracle compatible mode, the following privileges are required for the migration user:
To avoid potential data loss in scenarios such as adding new tables, rebuilding tables, or table name conflicts, and to reduce the maintenance overhead of multiple publications, OMS subscribes to all tables in the specified database. Therefore, the migration user must have the superuser privilege.
The migration user must have the REPLICATION and LOGIN roles and the CREATE PUBLICATION privilege.
CREATE USER <user_name> REPLICATION LOGIN ENCRYPTED PASSWORD '<password>';GRANT CREATE ON DATABASE <database_name> TO <user_name>;
The migration user must be the owner of the tables to be migrated.
// Create a role named replication_group. CREATE ROLE <replication_group>; // Add the original owner of the tables to be migrated to the replication_group role. GRANT <replication_group> TO <original_owner>; // Add the migration account to replication_group as well. GRANT <replication_group> TO <replication_user>; // Change the owner of the tables to be migrated to the replication_group role. ALTER TABLE <table_name> OWNER TO <replication_group>;If you selected Allow OMS to automatically write heartbeat data to this instance during incremental synchronization to resolve high latency issues at the source when no business data is being written when adding the PostgreSQL data source, OMS creates and updates the
oms_postgres_heartbeattable in the corresponding PostgreSQL database. In this case, the PostgreSQL database user must have the privileges to create and write to this table. For more information, see Create and update a heartbeat table.
User privileges required when a DM database serves as the source or the destination for reverse incremental data flow
Before using OceanBase Migration Service (OMS) to migrate data from a DM database, create a database user for migration or synchronization and grant the appropriate privileges based on your actual migration scenario.
This section applies to DM8 in standalone, DW, and DSC modes. When DM serves as the source, it supports migration to the MySQL-compatible mode or Oracle-compatible mode of OceanBase Database. The description for DM as the write destination applies only to the reverse incremental data flow of the original migration link.
Basic read privileges
The following privilege baseline can be used for schema migration, full migration, or data verification. Execute the statements below by an authorized administrator, replacing <user_name> with the actual migration account.
GRANT CREATE SESSION TO <user_name>;
GRANT SOI TO <user_name>;
GRANT VTI TO <user_name>;
GRANT SELECT ANY DICTIONARY TO <user_name>;
GRANT SELECT ANY TABLE TO <user_name>;
GRANT SELECT ANY VIEW TO <user_name>;
GRANT SELECT ANY SEQUENCE TO <user_name>;
Permission or role |
Purpose |
|---|---|
CREATE SESSION |
Connect to the DM database. |
SOI |
Query system tables and database object metadata. |
VTI |
Query dynamic management views. |
SELECT ANY DICTIONARY |
Query the system dictionary. |
SELECT ANY TABLE |
Read the business tables to be migrated. |
SELECT ANY VIEW |
Query view-related objects. |
SELECT ANY SEQUENCE |
Query sequence-related objects. |
Note
The preceding solution is a unified privilege baseline, not a least-privilege-per-object approach.
The current schema and full read pre-check pass if the effective privilege set includes
ADMIN. Other accounts must meet the four SELECT system privilege requirements; even if the migrated objects belong to the connecting account itself, this does not automatically exempt them.ADMINrefers to the effectively queried privileges. You cannot assume exemption just because the account has a role namedDBA. After passing this check, other actual query capability requirements must still be met.If only source-side reading is performed without enabling heartbeat or reverse incremental data flow, the migration account does not require business data write privileges.
Additional privileges by scenario
Incremental synchronization privileges
For full + incremental or incremental-only synchronization, you must configure incremental read privileges. If incremental heartbeat is enabled, you must also grant the privileges to create and read from/write to the heartbeat table. Full migration only requires enabling heartbeat for full reads.
Incremental read privileges
During incremental synchronization, the migration account must also have execute privileges on the SYS.DBMS_LOGMNR package.
GRANT EXECUTE ON SYS.DBMS_LOGMNR TO <user_name>;
The SYS.DBMS_LOGMNR package and its contents must be visible and in the VALID state. The migration account should also be able to read the following information:
- Metadata of database objects, table columns, constraints, and indexes.
- Log-mining views such as
V$LOGMNR_CONTENTSandV$LOGMNR_LOGS. - Parameter, instance, version, and archiving information such as
V$DM_INI,V$INSTANCE,V$VERSION,V$RLOG, andV$ARCHIVED_LOG. - Cluster member and archiving information such as
V$DSC_EP_INFO,V$DM_ARCH_INI, andV$ARCH_FILEin DSC mode.
Note
The SOI, VTI, and dictionary read privileges in basic authorization provide the corresponding access capabilities. Please use the actual migration account to perform a pre-check to confirm that the privileges are effective and that key archival information and the metadata of the selected tables are visible.
Additional privileges when incremental heartbeat is enabled
If heartbeat is enabled for incremental synchronization, OMS manages the heartbeat table in the schema of the data source connection account itself. When heartbeat is not enabled, no additional privileges to create the table or write to it are required for the heartbeat table.
When registering a data source or testing a connection, privileges and existing objects are primarily checked; the heartbeat table is not created immediately as a result. Actual table creation and record initialization occur during the heartbeat initialization phase, which precedes incremental log pull.
If the heartbeat table has not yet been created, the migration account must have the privilege to create the table:
GRANT CREATE TABLE TO <user_name>;
The migration account must also have the capability to initialize, read from, and update the heartbeat table. The account obtains the corresponding operation privileges through object ownership.
Note
If the heartbeat table already exists and meets OMS requirements, the account must have the
SELECTandUPDATEprivileges on that table.The heartbeat table name is determined by the system parameter
dm.heartbeat.table-name, with a default value ofOMS_HEARTBEAT_DEFAULT. Existing data sources use the heartbeat table they are bound to.In standalone mode, the heartbeat is written to one node; in DW mode, it is written to the current primary node; in DSC mode, it is written to each node in sequence.
The schema of the connection account itself must already exist and have sufficient table creation space.
Reverse incremental privileges
When reverse incremental migration is enabled for a migration link, the original DM source will serve as the data write-back endpoint. The migration account must have:
- The ability to create transaction tables in its own schema and clean up their indexes.
- The privilege to query, insert, and delete records from transaction tables for transaction deduplication and cleanup of expired records.
- The
SELECT,INSERT,UPDATE, andDELETEprivileges on the write-back business tables.
Regular accounts can use the following baseline authorization for creating tables and indexes:
GRANT CREATE TABLE TO <user_name>;
GRANT CREATE INDEX TO <user_name>;
Transaction tables and their indexes are located in the connecting account's own schema. If an account already has the required ownership or equivalent authorization for object operations, no duplicate authorization is needed, nor is it necessary to grant cross-schema privileges such as CREATE ANY INDEX.
If the write-back business table does not belong to the migration account, grant the appropriate privileges on the actual objects:
GRANT SELECT, INSERT, UPDATE, DELETE
ON <schema_name>.<table_name> TO <user_name>;
If the business table belongs to the migration account itself, no duplicate object privileges need to be granted for that table.
Note
Reverse incremental migration follows the same switching process as the migration link. Forward and reverse incremental migrations cannot run simultaneously.
Writer checks the transaction tables and indexes during initialization; missing objects are automatically created. Even if the transaction tables exist, the account must have the capability to create any missing indexes for initialization to succeed.
Cleanup indexes are built on the
GMT_CREATEcolumn of the transaction tables. Being unable to create a missing index will cause initialization to fail.Transaction markers are appended in INSERT mode. During recovery, deduplication is performed via SELECT, and expired records are cleaned up in batches via DELETE. Shutting down Writer will not delete the transaction tables or indexes.
Adequate tablespace and storage capacity should be reserved for the transaction tables and indexes.
Archiving and logging configuration for incremental synchronization
In addition to account permissions, the DM source also needs to meet the following requirements:
Parameter |
Requirements |
|---|---|
| Archive | Enable archiving,ARCH_INI=1and configure the available archive destinations. |
| Logical Log | SettingsRLOG_APPEND_LOGIC=2. |
| Log Recording Scope | You can use theRLOG_IGNORE_TABLE_SET=1Enabled globally. DM also supports setting it to be0When enabling it for the table to be collected.ADD LOGIC LOGHowever, the complete connection procedure for this table-level method to automatically initialize the heartbeat with OMS has not been verified. Therefore, it cannot be used as a verified out-of-the-box solution in this section. |
| Retention Period | The archiving should be continuous and cover the incremental start point, the backlog of tasks, and the window required for fault recovery. |
| Current Architecture Scope | DPC_MODE=0、MPP_INI=0. |
You can execute the following read-only statement to check related parameters:
SELECT PARA_NAME, PARA_VALUE
FROM V$DM_INI
WHERE PARA_NAME IN (
'ARCH_INI',
'RLOG_APPEND_LOGIC',
'RLOG_IGNORE_TABLE_SET',
'DPC_MODE',
'MPP_INI'
);
Note
Archiving or LogMiner is not required to be enabled for full read operations.
After configuring parameters, ensure that the required logs have actually been generated. Configuration changes cannot retrospectively capture previously unrecorded logical logs.
When using table-level logical logs, you must also overwrite the heartbeat tables relied on by incremental collection. Currently, when OMS automatically creates heartbeat tables, it does not append the
ADD LOGIC LOGstatement and proceeds directly to initialize records. The timing of supplementing table-level settings after automatic table creation to match the first heartbeat and the start point of collection has not been verified.In DSC mode, you need to overwrite all visible nodes and confirm the relevant configurations and access capabilities node by node.
When
RLOG_LLOG_COMPRESS,DSC_TRX_CMT_LSN_SYNC, orDSC_TRX_VIEW_SYNCare different from the validated baseline, OMS will provide related observation information and will not block the process directly due to numerical differences.Even after passing the pre-check, the incremental collection component will continue to check archive minability and recovery conditions.
User privileges required when a TiDB database serves as the source
The migration user for a TiDB database must have full SELECT privileges.
GRANT SELECT ON *.* TO '<user_name>';
User privileges required when a SQL Server database serves as the source
For a data migration task from a SQL Server database to an OceanBase database in MySQL or Oracle compatible mode, the following user privileges are required for the migration user:
During schema migration and full migration, the migration user must have read permission on the database to be migrated and the privilege to view object definitions, that is, the
db_datareaderrole and theVIEW DEFINITIONprivilege.During incremental synchronization, the migration user must have permission to read incremental logs, that is, the
sysadminordb_ownerrole.Note
To enable CDC for a database for the first time (
EXECUTE sys.sp_cdc_enable_db), you must use an account with thesysadminprivilege. For details, see the "Prerequisites" section in the corresponding migration topic documentation.If you keep the default checked option Allow OMS to write heartbeat data during data synchronization when adding the SQL Server data source, OMS creates and updates the heartbeat table in the source SQL Server database. In this case, the migration user must have the privileges to create objects and update data, that is, the
db_ddladminanddb_datawriterroles.When configuring reverse incremental synchronization, the migration user must also have the
db_ddladminanddb_datawriterroles.
Examples of granting these privileges are shown below.
-- Grant database read permission.
USE <database_name>;
GO
ALTER ROLE db_datareader ADD MEMBER <user_name>;
-- Grant the privilege to view object definitions.
GRANT VIEW DEFINITION TO <user_name>;
GO
Note
The ALTER ROLE … ADD MEMBER statement is supported starting with SQL Server 2012. For SQL Server 2008 and 2008 R2, use sp_addrolemember instead:
USE <database_name>;
GO
EXECUTE sp_addrolemember 'db_datareader', <user_name>;
GO
User privileges required when DataHub serves as the destination
DataHub performs authentication based on endpoints, access keys, and secret keys. For more information, see DataHub privilege control.
A DataHub user must have the GetProject, CreateTopic, ListTopic, GetTopic, ListShard, PutRecords, GetRecords, and GetCursor privileges.
User privileges required when Kafka serves as the destination
If authentication is enabled for Kafka, see Create a Kafka data source.
When Kafka serves as the destination, the synchronization user must have privileges to perform the following operations:
Create and view topics
View topic partition information
Write records
Read records
User privileges required when RocketMQ serves as the destination
When RocketMQ serves as the destination, the synchronization user must have the privileges to perform the following operations:
Create and view topics.
View topic message queue information.
Write records.
Read records.
User privileges required when DM database serves as the source
In this scenario, DM database acts as the source. During schema migration, full data migration, or data verification, OMS only performs read operations at the source. If you allow OMS to write heartbeat data when creating the DM data source, OMS creates and updates the heartbeat table in the DM database. If Reverse Incremental is selected for the migration link, OMS also writes back changes generated at the target after business switchover to the DM database. Therefore, read-only authorization applies only to scenarios where heartbeat writing is disabled and reverse incremental migration is not selected. For other scenarios, grant the additional table creation, write, and update privileges on the basis of the following privileges. It is recommended that you create a dedicated migration user for OMS. Have an authorized administrator execute the following statements, replacing <user_name> with the actual migration username.
GRANT CREATE SESSION TO <user_name>;
GRANT SOI TO <user_name>;
GRANT VTI TO <user_name>;
GRANT SELECT ANY DICTIONARY TO <user_name>;
GRANT SELECT ANY TABLE TO <user_name>;
GRANT SELECT ANY VIEW TO <user_name>;
GRANT SELECT ANY SEQUENCE TO <user_name>;
The purpose of each privilege is as follows:
Permission |
Purpose |
|---|---|
CREATE SESSION |
Establish a database connection. |
SOI |
Read directly accessed by OMSSYS.*System tables, as well as metadata for objects such as tables, stored procedures, functions, packages, triggers, and types. |
VTI |
readV$INSTANCE、V$DM_INIand other dynamic management views. |
SELECT ANY DICTIONARY |
OverwriteALL_*、DBA_*、CTISYS.*and access to other system dictionaries. This permission is related toSOIThere is some overlap between them. Retaining all of them can reduce the permission gaps caused by different security baselines of DM. |
SELECT ANY TABLE |
Read data from business tables across schemas for full migration. Schema migration is performed additionally only on auto-increment columns.SELECT MAX(column). |
SELECT ANY VIEW |
Ensure that cross-schema views areALL_VIEWSIt is visible and readable. |
SELECT ANY SEQUENCE |
Ensure that cross-schema sequences areALL_SEQUENCESThe sequence attributes can be viewed and read. |
Note
The precheck for data migration verifies whether the migration user has the SOI and VTI roles, as well as the SELECT ANY TABLE, SELECT ANY DICTIONARY, SELECT ANY VIEW, and SELECT ANY SEQUENCE privileges. Lacking any of these will result in a failed precheck.
If you allow OMS to write heartbeat data when creating the DM data source, OMS creates and updates the heartbeat table in the DM database (the table name is determined by the system parameter
dm.heartbeat.table-name, with a default value ofOMS_HEARTBEAT_DEFAULT). The migration user must also have the privileges to create this table and to query and update it. No additional authorization is required for full data migration only. For details, see Create and update the heartbeat table.If Reverse Incremental is selected for the migration link, DM database serves as the write-back endpoint to receive changes generated at the target after business switchover. The migration user must also have the
INSERT,UPDATE, andDELETEprivileges on the write-back objects.
User privileges required when Elasticsearch is the source
When Elasticsearch serves as the source, OMS needs to read the index's mapping, settings, and document data. You can create the following role using Kibana's Dev Tools or Elasticsearch's Security API, and assign it to the OMS migration user:
POST /_security/role/oms_migration_role
{
"cluster": ["monitor"],
"indices": [
{
"names": ["*"],
"privileges": ["view_index_metadata", "read"]
}
]
}
The purpose of each privilege is as follows:
view_index_metadata: reads the index's mapping and settings for schema migration.read: reads documents from the index for full migration, incremental synchronization, and data verification.monitor(cluster-level): retrieves index statistics for scenarios such as row count verification.
Note
If the indexes to be migrated have a common prefix, you can configure names with a matching pattern for those indexes to narrow down the scope of privileges.
User privileges required when Elasticsearch is the destination
After you select Reverse Incremental for a data migration task, OMS needs to write the changes generated by OceanBase Database back to Elasticsearch. In this case, the migration user must also have the following privileges:
POST /_security/role/oms_reverse_role
{
"cluster": ["monitor"],
"indices": [
{
"names": ["*"],
"privileges": ["write", "view_index_metadata"]
}
]
}
write: Writes, updates, and deletes documents in the original index bound to the migration task. OMS does not automatically create indexes, so thecreate_indexprivilege is not required.view_index_metadata: Validates the index structure.
Notice
Reverse incremental migration only writes back to the original index bound to the migration task. OMS verifies the index UUID. If the original index has been deleted, it cannot be rebuilt with the same name to continue writing. Therefore, keep the original source index during migration and reverse incremental migration.