Auditing a Self-built Database on ECS
Database audit is deployed in bypass mode. The database audit agent is deployed on the database or application server to obtain access traffic, upload traffic data to the audit system, receive audit system configuration commands, and report database monitoring results, implementing security audit on self-built databases on ECS and BMS.
Scenario
Assume you have created a database on HUAWEI CLOUD Elastic Cloud Server (ECS). Table 1 describes its details. You need to locate and track internal violations and improper operations in the database to meet compliance requirements. This section describes how to install an agent on the database, enable the database audit function, and check audit results.
Limitations and Constraints
- Disable SSL for a database before auditing it.
- The database audit instance and the database to be audited must be in the same region.
- For connection purposes, ensure the VPC of the database audit instance is the same as that of the agent node.
For details about how to choose the node, see How Do I Determine Where to Install an Agent?
Step 1: Purchase Database Audit
Configure and purchase the database audit service. For details, see Purchasing Database Audit.
For connection purposes, ensure the VPC of the database audit instance is the same as that of the agent node.
For details about how to choose the node, see How Do I Determine Where to Install an Agent?
Step 2: Add a Database and Enable Audit
After purchasing database audit, add the example database to the database audit instance and enable the database audit function for the database.
- Log in to the management console.
- Go to the database addition page. Figure 2 Accessing the database addition page
- In the displayed dialog box, set database parameters described in Table 1, as shown in Figure 3.
- Click OK. The database is added to the database list and its audit status is Disabled.
- Locate the row that contains the database and click Enable in the Operation column to enable audit.
Step 3: Add an Agent
- In the Agent column of the database, click Add, as shown in Figure 4.
- In the displayed dialog box, select an addition mode. Figure 5 Adding an agent to a database
- Click OK.
Step 4: Add a Security Group Rule
- If the inbound rules of the security group have been configured for the installing node, go to Step 5: Install an Agent.
- If no inbound rule has been configured, perform the following operations.
You can configure security group rules before or after installing an agent.
- Obtain the IP address of the agent node.
- Click Add Security Group.
- In the displayed dialog box, record the security group name (for example, default) of the database audit instance, as shown in Figure 6.
- Click Go to VPC.
- Enter the security group name default in the search box in the upper right corner of the list, and click
or press Enter. The group information is displayed in the list. - Click the group name default.
- On the Inbound Rules tab, click Add Rule. See Figure 7.
- In the Add Inbound Rule dialog box, add TCP (port number 8000) and UDP protocols (port number from 7000 to 7100) for the installing node IP address in Figure 8.
Step 5: Install an Agent
Each agent has a unique ID, which is used as the key for connecting to a database audit instance. If you delete an agent and add it back, you need to download and install the agent again.
- Log in to the DBSS console.
- In the navigation tree on the left, choose Database Audit > Databases.
- Select an instance in the Instance drop-down list.
- Click
next to the database to view details of its agent. In the Operation column of the agent, click Download Agent, as shown in Figure 9. - Use a cross-platform transmission tool (for example, WinSCP) to upload the downloaded agent installation package xxx.tar to the node specified by Installing Node IP Address in Figure 9.
- Log in to the node as user root by using a cross-platform remote access tool (for example, PuTTY) via SSH.
- Run the following command to access the directory where the agent installation package xxx.tar is stored:
- cd Agent_installation_package_directory
- Run the following command to decompress the installation package xxx.tar:
- tar -xvf xxx.tar
- Run the following command to go to the directory in which the install.sh script is stored:
- cd install.sh_script_directory
- Run the following command to install the agent:
- sh install.sh
- If the following information is displayed, the agent has been installed successfully:
1 2 3 4 5
start agent starting audit agent audit agent started start success install dbss audit agent done!
Step 6: Verify the Communication Between the Agent and the Database Audit Instance
Check to ensure the communication between the agent and the database audit instance is normal.
- Run an SQL statement or perform an operation on the database (for example, Select 1;) on the node where the agent is installed.
- Go to the SQL statement list, as shown in Figure 10.
- The SQL statement list displays the record of database login, as shown in Figure 11.
If no SQL statement is displayed, check your network connection. For details, see What Should I Do If the Communication Between the Agent and Database Audit Instance Is Abnormal?
Step 7: View Audit Results
You can check audit results on the Dashboard page, or generate, preview, or download reports.
- Check overview information.
Go to the Dashboard page, as shown in Figure 12.
The Dashboard page displays the audit duration, total number of SQL statements and risks, statements and risks today, and today's sessions of an instance.
- Generate, download, or preview reports.
- Go to the report management page, as shown in Figure 13.
- In the row containing the desired report template, click Generate Report in the Operation column.
- In the displayed dialog box, click
to set the start time and end time of the report, and select the database for which you want to generate a report. - Click OK.
The Reports page is displayed. You can view the report status on this page. After a report is generated, you can preview or download it, as shown in Figure 14.
To preview a report online, use Google Chrome or Mozilla FireFox.
Last Article: Database Audit Best Practices
Next Article: Auditing an RDS DB Instance












Did this article solve your problem?
Thank you for your score!Your feedback would help us improve the website.