Oracle 資料庫

Oracle DB 整合功能會收集 Oracle DB 指標和記錄。系統會查詢相關監控檢視表,收集指標。這項整合功能會寫入結構化追蹤記錄。

如要進一步瞭解 Oracle DB,請參閱 Oracle Database 說明文件。

必要條件

如要收集 Oracle DB 遙測資料,您必須在支援的作業系統上安裝 Ops Agent:

  • 如要使用指標,請安裝 2.22.0 以上版本。
  • 如要查看記錄,請安裝 2.22.0 以上版本。

這項整合支援在 Compute Engine 執行個體上執行的 Oracle DB 12.2、18c、19c 和 21c 版本。不支援 Oracle RAC 或 OCI 設定。

設定 Oracle 資料庫執行個體

如要收集指標,監控使用者必須具備相關檢視表的 SELECT 存取權。如果使用者具備充分權限,並以 SYSDBA 或 SYSOPER 身分連線至 Oracle DB 執行個體,則執行下列 SQL 指令碼後,應會建立監控使用者並授予適當權限。

-- Create the monitoring user "otel"
CREATE USER otel IDENTIFIED BY ;

-- Grant the "otel" user the required permissions
GRANT CONNECT TO otel;
GRANT SELECT ON SYS.GV_$DATABASE to otel;
GRANT SELECT ON SYS.GV_$INSTANCE to otel;
GRANT SELECT ON SYS.GV_$PROCESS to otel;
GRANT SELECT ON SYS.GV_$RESOURCE_LIMIT to otel;
GRANT SELECT ON SYS.GV_$SYSMETRIC to otel;
GRANT SELECT ON SYS.GV_$SYSSTAT to otel;
GRANT SELECT ON SYS.GV_$SYSTEM_EVENT to otel;
GRANT SELECT ON SYS.V_$RMAN_BACKUP_JOB_DETAILS to otel;
GRANT SELECT ON SYS.V_$SORT_SEGMENT to otel;
GRANT SELECT ON SYS.V_$TABLESPACE to otel;
GRANT SELECT ON SYS.V_$TEMPFILE to otel;
GRANT SELECT ON SYS.DBA_DATA_FILES to otel;
GRANT SELECT ON SYS.DBA_FREE_SPACE to otel;
GRANT SELECT ON SYS.DBA_TABLESPACE_USAGE_METRICS to otel;
GRANT SELECT ON SYS.DBA_TABLESPACES to otel;
GRANT SELECT ON SYS.GLOBAL_NAME to otel;

設定 Oracle DB 的 Ops Agent

按照「設定 Ops Agent」指南,新增必要元素,從 Oracle DB 執行個體收集遙測資料,並重新啟動代理程式。

範例設定

下列指令會建立設定,收集及擷取 Oracle DB 的遙測資料:

# Configures Ops Agent to collect telemetry from the app. You must restart the agent for the configuration to take effect.

set -e

# Check if the file exists
if [ ! -f /etc/google-cloud-ops-agent/config.yaml ]; then
  # Create the file if it doesn't exist.
  sudo mkdir -p /etc/google-cloud-ops-agent
  sudo touch /etc/google-cloud-ops-agent/config.yaml
fi

# Create a back up of the existing file so existing configurations are not lost.
sudo cp /etc/google-cloud-ops-agent/config.yaml /etc/google-cloud-ops-agent/config.yaml.bak

# Configure the Ops Agent.
sudo tee /etc/google-cloud-ops-agent/config.yaml > /dev/null << EOF
logging:
  receivers:
    oracledb_audit:
      type: oracledb_audit
      oracle_home: /opt/oracle
    oracledb_alert:
      type: oracledb_alert
      oracle_home: /opt/oracle
  service:
    pipelines:
      oracledb:
        receivers:
          - oracledb_audit
          - oracledb_alert
metrics:
  receivers:
    oracledb:
      type: oracledb
      username: otel
      password: ora19c
      sid: ORCLCDB
      service_name: ORCLCDB
  service:
    log_level: debug
    pipelines:
      oracledb:
        receivers:
          - oracledb
EOF

如要讓這些變更生效,請重新啟動 Ops Agent:

Linux

  1. 如要重新啟動代理程式,請在執行個體上執行下列指令:
    sudo systemctl restart google-cloud-ops-agent
    
  2. 如要確定代理程式已重新啟動,請執行下列指令,並驗證「指標代理程式」和「Logging 代理程式」元件是否已啟動:
    sudo systemctl status "google-cloud-ops-agent*"
    

Windows

  1. 使用 RDP 或類似工具連線至執行個體,然後登入 Windows。
  2. 在 PowerShell 圖示上按一下滑鼠右鍵,然後選取「Run as Administrator」(以系統管理員身分執行),開啟具有管理員權限的 PowerShell 終端機。
  3. 如要重新啟動代理程式,請執行下列 PowerShell 指令:
    Restart-Service google-cloud-ops-agent -Force
    
  4. 如要確定代理程式已重新啟動,請執行下列指令,並驗證「指標代理程式」和「Logging 代理程式」元件是否已啟動:
    Get-Service google-cloud-ops-agent*
    

設定記錄收集

如要從 Oracle DB 擷取記錄,您必須為 Oracle DB 產生的記錄建立接收器,然後為新的接收器建立管道。

如要為 oracledb_audit 記錄檔設定接收器,請指定下列欄位:

欄位 預設 說明
exclude_paths 檔案系統路徑模式清單,用於從 include_paths 比對的集合中排除。
include_paths 檔案系統路徑清單,用於讀取每個檔案的結尾。路徑中可使用萬用字元 (*)。無法與 oracle_home 欄位一併提供。
oracle_home 環境的 ORACLE_HOME 位置,提供時會將 include_paths 設為 $ORACLE_HOME/admin/*/adump/*.aud。無法與 include_paths 欄位一併提供。
record_log_file_path false 如果設為 true,則取得記錄項目的特定檔案路徑,會顯示在輸出記錄項目中,做為 agent.googleapis.com/log_file_path 標籤的值。使用萬用字元時,系統只會記錄取得記錄的檔案路徑。
type 這個值必須是 oracledb_audit。
wildcard_refresh_interval 60s include_paths 中萬用字元檔案路徑的重新整理間隔。以時間長度表示,例如 30s 或 2m。如果記錄檔的輪替速度快於預設間隔,這項屬性在記錄檔處理量較高時可能很有用。

如要為 oracledb_alert 記錄檔設定接收器,請指定下列欄位:

欄位 預設 說明
exclude_paths 檔案系統路徑模式清單,用於從 include_paths 比對的集合中排除。
include_paths 檔案系統路徑清單,用於讀取每個檔案的結尾。路徑中可使用萬用字元 (*)。無法與 oracle_home 欄位一併提供。
oracle_home 環境的 ORACLE_HOME 位置,提供後會將 include_paths 設為 $ORACLE_HOME/diag/rdbms/*/*/trace/alert_*.log。無法與 include_paths 欄位一併提供。
record_log_file_path false 如果設為 true,則取得記錄項目的特定檔案路徑,會顯示在輸出記錄項目中,做為 agent.googleapis.com/log_file_path 標籤的值。使用萬用字元時,系統只會記錄取得記錄的檔案路徑。
type 這個值必須是 oracledb_alert。
wildcard_refresh_interval 60s include_paths 中萬用字元檔案路徑的重新整理間隔。以時間長度表示,例如 30s 或 2m。如果記錄檔的輪替速度快於預設間隔,這項屬性在記錄檔處理量較高時可能很有用。

記錄內容

logName 衍生自設定中指定的接收器 ID。LogEntry 內的詳細欄位如下。

oracledb_alert 記錄在 LogEntry 中包含下列欄位:

欄位 類型 說明
jsonPayload.message 字串 記錄訊息
severity 字串 (LogSeverity) 記錄項目層級 (已翻譯)。

oracledb_audit 記錄在 LogEntry 中包含下列欄位:

欄位 類型 說明
jsonPayload.action 字串 記錄在稽核記錄中的動作
jsonPayload.action_number 數字 用於識別記錄動作類型的數字
jsonPayload.client_terminal 字串 動作來源用戶端終端機的 ID
jsonPayload.client_user 字串 執行稽核動作的用戶端使用者
jsonPayload.database_user 字串 稽核動作的資料庫使用者
jsonPayload.dbid 數字 資料庫 ID
jsonPayload.length 數字 代表記錄動作的字串長度
jsonPayload.privilege 字串 執行動作時使用的資料庫權限
jsonPayload.sessionid 數字 工作階段 ID
jsonPayload.status 字串 動作狀態
jsonPayload.user_host 字串 稽核動作的來源主機
severity 字串 (LogSeverity) 記錄項目層級 (已翻譯)。

設定指標收集

如要從 Oracle DB 擷取指標,您必須為 Oracle DB 產生的指標建立接收器,然後為新的接收器建立管道。

這個接收器不支援在設定中使用多個執行個體,例如監控多個端點。所有這類執行個體都會寫入相同的時間序列,Cloud Monitoring 無法區分。

如要為 oracledb 指標設定接收器,請指定下列欄位:

欄位 預設 說明
collection_interval 60s 時間長度值,例如 30s 或 5m。
endpoint localhost:1521 用於連線至 Oracle 資料庫執行個體的端點。這個欄位支援 host:port 或 Unix 通訊端路徑。
insecure true 設定是否要使用安全的 TLS 連線。如果設為 false,則會啟用 TLS。
insecure_skip_verify false 設定是否略過憑證驗證。如果 insecure 設為 true,則不會使用 insecure_skip_verify 值。
password 用於連線至執行個體的密碼。
service_name 受監控 Oracle 資料庫的服務名稱。請視情況使用這個欄位「或」sid 欄位。
sid 受監控 Oracle 資料庫的 SID。請視情況使用這個欄位「或」service_name 欄位。
type 這個值必須是 oracledb。
username 用於連線至執行個體的使用者名稱。
wallet 目錄路徑,內含用於驗證及保護連線的 Oracle Wallet (選用)。

監控的內容

下表列出 Ops Agent 從 Oracle DB 執行個體收集的指標。

指標類型
種類、類型
受監控資源
標籤
workload.googleapis.com/oracle.backup.latest
CUMULATIVE, INT64
gce_instance
database_id
db_system
global_name
workload.googleapis.com/oracle.buffer.cache.ratio
GAUGE, DOUBLE
gce_instance
database_id
db_system
global_name
instance_id
workload.googleapis.com/oracle.cursor.count
CUMULATIVE, INT64
gce_instance
database_id
db_system
global_name
instance_id
workload.googleapis.com/oracle.cursor.current
GAUGE, INT64
gce_instance
database_id
db_system
global_name
instance_id
workload.googleapis.com/oracle.disk.operation.count
CUMULATIVE, INT64
gce_instance
database_id
db_system
direction
global_name
instance_id
workload.googleapis.com/oracle.disk.operation.size
CUMULATIVE, INT64
gce_instance
database_id
db_system
direction
global_name
instance_id
workload.googleapis.com/oracle.logon.count
CUMULATIVE, INT64
gce_instance
database_id
db_system
global_name
instance_id
workload.googleapis.com/oracle.logon.current
GAUGE, INT64
gce_instance
database_id
db_system
global_name
instance_id
workload.googleapis.com/oracle.network.data
CUMULATIVE, INT64
gce_instance
database_id
db_system
direction
global_name
instance_id
target
workload.googleapis.com/oracle.process.count
GAUGE, INT64
gce_instance
database_id
db_system
global_name
instance_id
workload.googleapis.com/oracle.process.limit
GAUGE, INT64
gce_instance
database_id
db_system
global_name
instance_id
workload.googleapis.com/oracle.process.pga_memory.size
GAUGE, INT64
gce_instance
database_id
db_system
global_name
instance_id
program
state
workload.googleapis.com/oracle.row.cache.ratio
GAUGE, DOUBLE
gce_instance
database_id
db_system
global_name
instance_id
workload.googleapis.com/oracle.service.response_time
GAUGE, DOUBLE
gce_instance
database_id
db_system
global_name
instance_id
workload.googleapis.com/oracle.session.count
GAUGE, INT64
gce_instance
database_id
db_system
global_name
instance_id
workload.googleapis.com/oracle.session.limit
GAUGE, INT64
gce_instance
database_id
db_system
global_name
instance_id
workload.googleapis.com/oracle.sort.count
CUMULATIVE, INT64
gce_instance
database_id
db_system
global_name
instance_id
type
workload.googleapis.com/oracle.sort.row.count
CUMULATIVE, INT64
gce_instance
database_id
db_system
global_name
instance_id
workload.googleapis.com/oracle.tablespace.count
GAUGE, INT64
gce_instance
contents
database_id
db_system
global_name
status
workload.googleapis.com/oracle.tablespace.size
GAUGE, INT64
gce_instance
contents
database_id
db_system
global_name
state
tablespace_name
workload.googleapis.com/oracle.user.calls
CUMULATIVE, INT64
gce_instance
database_id
db_system
global_name
instance_id
workload.googleapis.com/oracle.user.commits
CUMULATIVE, INT64
gce_instance
database_id
db_system
global_name
instance_id
workload.googleapis.com/oracle.user.rollbacks
CUMULATIVE, INT64
gce_instance
database_id
db_system
global_name
instance_id
workload.googleapis.com/oracle.wait.count
CUMULATIVE, INT64
gce_instance
database_id
db_system
global_name
instance_id
type
wait_class
workload.googleapis.com/oracle.wait.time
CUMULATIVE, INT64
gce_instance
database_id
db_system
global_name
instance_id
type
wait_class
workload.googleapis.com/oracle.wait.timeouts
CUMULATIVE, INT64
gce_instance
database_id
db_system
global_name
instance_id
type
wait_class

驗證設定

本節說明如何確認您已正確設定 Oracle DB 接收器。Ops Agent 可能需要一兩分鐘才會開始收集遙測資料。

如要確認 Oracle DB 記錄檔是否已傳送至 Cloud Logging,請按照下列步驟操作:

  1. 前往 Google Cloud 控制台的 「Logs Explorer」頁面:

    前往「Logs Explorer」(記錄檔探索工具)

    如果您是使用搜尋列尋找這個頁面,請選取子標題為「Logging」的結果。

  2. 在編輯器中輸入下列查詢,然後點選「執行查詢」:
    resource.type="gce_instance"
    (log_id("oracledb_alert") OR log_id("oracledb_audit"))
    

如要確認 Oracle DB 指標是否已傳送至 Cloud Monitoring,請按照下列步驟操作:

  1. 前往 Google Cloud 控制台的「Metrics Explorer」頁面:

    前往「Metrics Explorer」

    如果您是使用搜尋列尋找這個頁面,請選取子標題為「Monitoring」的結果。

  2. 在查詢建立工具窗格的工具列中,選取名為 「PromQL」PromQL的按鈕。
  3. 在編輯器中輸入下列查詢,然後點選「執行查詢」:
    {"workload.googleapis.com/oracle.logon.count", monitored_resource="gce_instance"}
    

查看資訊主頁

如要查看 Oracle DB 指標,必須先設定圖表或資訊主頁。 Oracle DB 整合功能提供一或多個資訊主頁。 設定整合作業且 Ops Agent 開始收集指標資料後,系統會自動安裝所有資訊主頁。

您也可以查看資訊主頁的靜態預覽畫面,不必安裝整合項目。

如要查看已安裝的資訊主頁,請按照下列步驟操作:

  1. 在 Google Cloud 控制台中,前往「Dashboards」(資訊主頁) 頁面:

    前往「Dashboards」(資訊主頁)

    如果您是使用搜尋列尋找這個頁面,請選取子標題為「Monitoring」的結果。

  2. 選取「Dashboard List」(資訊主頁清單) 分頁標籤,然後選擇「Integrations」(整合) 類別。
  3. 按一下要查看的資訊主頁名稱。

如果您已設定整合,但尚未安裝資訊主頁,請確認 Ops Agent 是否正在執行。如果資訊主頁中的圖表沒有指標資料,資訊主頁就會安裝失敗。Ops Agent 開始收集指標後,系統就會為您安裝資訊主頁。

如要查看資訊主頁的靜態預覽畫面,請按照下列步驟操作:

  1. 在 Google Cloud 控制台中,前往「Integrations」(整合) 頁面:

    前往「Integrations」

    如果您是使用搜尋列尋找這個頁面,請選取子標題為「Monitoring」的結果。

  2. 按一下「Compute Engine」部署平台篩選器。
  3. 找出 Oracle DB 的項目,然後按一下「查看詳細資料」。
  4. 選取「資訊主頁」分頁標籤,即可查看靜態預覽畫面。如果已安裝資訊主頁,請點選「View dashboard」(查看資訊主頁) 前往該頁面。

如要進一步瞭解 Cloud Monitoring 中的資訊主頁,請參閱「資訊主頁和圖表」。

如要進一步瞭解如何使用「Integrations」(整合) 頁面,請參閱「管理整合」。

安裝警告政策

警告政策會指示 Cloud Monitoring 在發生指定情況時通知您。Oracle DB 整合項目包含一或多項警告政策,可供您使用。您可以在 Monitoring 的「Integrations」(整合) 頁面查看及安裝這些警告政策。

如要查看可用警告政策的說明並安裝,請按照下列步驟操作:

  1. 在 Google Cloud 控制台中,前往「Integrations」(整合) 頁面:

    前往「Integrations」

    如果您是使用搜尋列尋找這個頁面,請選取子標題為「Monitoring」的結果。

  2. 找出 Oracle DB 的項目,然後按一下「View Details」(查看詳細資料)。
  3. 選取「快訊」分頁標籤。這個分頁會說明可用的警告政策,並提供安裝介面。
  4. 安裝警告政策。警告政策需要知道警告觸發時應將通知傳送至何處,因此您必須提供相關資訊,才能安裝。如要安裝警告政策,請按照下列步驟操作:
    1. 從可用警告政策清單中,選取要安裝的政策。
    2. 在「Configure notifications」(設定通知) 部分,選取一或多個通知管道。您可以選擇停用通知管道,但如果這麼做,警告政策就不會傳送通知。您可以在 Monitoring 中查看狀態,但不會收到通知。

      如要進一步瞭解通知管道,請參閱「管理通知管道」。

    3. 點選「建立政策」。

如要進一步瞭解 Cloud Monitoring 的警告政策,請參閱「警告簡介」。

如要進一步瞭解如何使用「Integrations」(整合) 頁面,請參閱「管理整合」。

後續步驟

如要瞭解如何使用 Ansible 安裝 Ops Agent、設定第三方應用程式,以及安裝範例資訊主頁,請觀看安裝 Ops Agent 以排解第三方應用程式的問題影片。