This topic describes how to enable security audit and set the storage location for audit records.
The audit operations in OceanBase Database are generally performed by ORAAUDITOR, whose password and privileges are specified by the sys user.
Limitations
Currently, only the Oracle mode of OceanBase Database supports the security audit feature.
Procedure
Log on to an Oracle tenant as the
sysuser and unlock theORAAUDITORuser.obclient> ALTER USER ORAAUDITOR ACCOUNT UNLOCK;Note
OceanBase Database automatically creates the
ORAAUDITORuser. This user is locked by default and needs to be unlocked before you enable security audit.Change the logon password of the
ORAAUDITORuser.For security purposes, the logon password of the
ORAAUDITORuser needs to be specified by thesysuser. If you need to change the password later, simply specify a new password.obclient> ALTER USER ORAAUDITOR IDENTIFIED BY ******;Grant privileges to the
ORAAUDITORuser.By default, the
ORAAUDITORuser has no privileges. To perform security audit operations, this user needs to be granted theCREATE SESSIONprivilege using theGRANTstatement. If you want theORAAUDITORuser to be able to view audit records, you also need to grant theSELECT ANY DICTIONARYprivilege to the user.obclient> GRANT CREATE SESSION, SELECT ANY DICTIONARY TO ORAAUDITOR;Enable security audit and set the storage location for audit records.
The security audit feature is controlled by the
audit_trailparameter. The configuration takes effect immediately after this parameter is set. The valid values of this parameter are as follows:NONE: disables security audit. This is the default value.OS: writes audit records to local disk files.DB: writes audit records to internal tables.DB,EXTENDED / DB_EXTENDED: writes audit records (including executed SQL statements) to internal tables.
Here is an example:
obclient> ALTER SYSTEM SET audit_trail = 'DB,EXTENDED';For more information about the
audit_trailparameter, see audit_trail.Note
Audit records support two methods of storage:
- Writing to local disk files: Audit records are asynchronously written to
, by default located at/audit/ /home/admin/oceanbase/audit/observer_xx_xxxxxx.aud. - Writing to internal tables: Audit records are directly written to system tables. The internal table
__all_tenant_security_audit_recordstores the audit records, while the internal table__all_virtual_audit_operationor__all_virtual_audit_actionstores the mappings of audit-relatedIDsandNames.
What to do next
Set audit rules after you enable security audit. For information about how to set audit rules, see Set and view audit rules.
Note
Auditing starts only after the ORAAUDITOR user sets audit rules.
References
For more information about audit operations, see the following topics: