Share via


在 Azure CLI 中設定和存取適用於 MariaDB 的 Azure 資料庫的稽核記錄

重要

適用於 MariaDB 的 Azure 資料庫位於淘汰路徑上。 強烈建議您移轉至適用於 MySQL 的 Azure 資料庫。 如需移轉至適用於 MySQL 的 Azure 資料庫的詳細資訊,請參閱適用於 MariaDB 的 Azure 資料庫會發生什麼事? (部份機器翻譯)。

您可以從 Azure CLI 設定適用於 MariaDB 的 Azure 資料庫的稽核記錄

如果您沒有 Azure 訂閱,請在開始之前,先建立 Azure 免費帳戶

必要條件

若要完成本指南:

  • 本文需要 2.0 版或更新版本的 Azure CLI。 如果您是使用 Azure Cloud Shell,就已安裝最新版本。

設定稽核記錄

重要

建議只記錄稽核所需的事件類型和使用者,以確保您的伺服器效能不會受到嚴重影響。

使用下列步驟來啟用和設定稽核記錄:

  1. audit_logs_enabled 參數設定為「開啟」,以開啟稽核記錄。

    az mariadb server configuration set --name audit_log_enabled --resource-group myresourcegroup --server mydemoserver --value ON
    
  2. 更新 audit_log_events 參數,以選取要記錄的事件類型

    az mariadb server configuration set --name audit_log_events --resource-group myresourcegroup --server mydemoserver --value "ADMIN,CONNECTION"
    
  3. 更新 audit_log_exclude_users 參數,以新增要從記錄中排除的任何 MariaDB 使用者。 提供其 MariaDB 使用者名稱來指定使用者。

    az mariadb server configuration set --name audit_log_exclude_users --resource-group myresourcegroup --server mydemoserver --value "azure_superuser"
    
  4. 更新 audit_log_include_users 參數,以新增要包括以進行記錄的任何特定 MariaDB 使用者。 提供其 MariaDB 使用者名稱來指定使用者。

    az mariadb server configuration set --name audit_log_include_users --resource-group myresourcegroup --server mydemoserver --value "sampleuser"
    

下一步