監視 PolyBase 並進行疑難排解

適用於:SQL Server

可使用您在本主題中找到的技術,為 PolyBase 的問題疑難排解。

目錄檢視

使用此處所列的類別目錄檢視管理 PolyBase 作業。

檢視 Description
sys.external_tables (Transact-SQL) 指定外部表格。
sys.external_data_sources (Transact-SQL) 指定外部資料來源。
sys.external_file_formats (Transact-SQL) 指定外部檔案格式。

動態管理檢視

PolyBase 查詢在內 sys.dm_exec_distributed_request_steps 分成一系列步驟。 下表提供步驟名稱與相關聯 DMV 的對應。

PolyBase 步驟 相關聯的 DMV
HadoopJobOperation sys.dm_exec_external_operations
RandomIdOperation sys.dm_exec_distributed_request_steps
HadoopRoundRobinOperation sys.dm_exec_dms_workers
StreamingReturnOperation sys.dm_exec_dms_workers
OnOperation sys.dm_exec_distributed_sql_requests

使用 DMV 監視 PolyBase 查詢

使用下列 DMV 監視及為 PolyBase 查詢的問題疑難排解。 也請考慮 PolyBase for SQL Server 中的下列效能考量

  1. 尋找執行時間最長的查詢

    記錄執行時間最長之查詢的執行識別碼。

     -- Find the longest running query  
    SELECT execution_id, st.text, dr.total_elapsed_time  
    FROM sys.dm_exec_distributed_requests  dr  
          cross apply sys.dm_exec_sql_text(sql_handle) st  
    ORDER BY total_elapsed_time DESC;  
    
  2. 尋找執行時間最長的分散式查詢步驟

    使用在上個步驟記錄的執行識別碼。 記錄執行時間最長之步驟索引。

    檢查執行時間最長之步驟的 location_type

    • 前端或計算:暗示 SQL 作業。 繼續執行步驟 3a。

      • DMS:暗示 PolyBase 資料移動服務作業。 繼續執行步驟 3b。
      -- Find the longest running step of the distributed query plan  
      SELECT execution_id, step_index, operation_type, distribution_type,   
      location_type, status, total_elapsed_time, command   
      FROM sys.dm_exec_distributed_request_steps   
      WHERE execution_id = 'QID4547'   
      ORDER BY total_elapsed_time DESC;  
      
  3. 尋找執行時間最長之步驟的執行進度

    1. 尋找 SQL 步驟的執行進度

      使用先前步驟所記錄的執行識別碼與步驟索引。

      -- Find the execution progress of SQL step    
      SELECT execution_id, step_index, distribution_id, status,   
      total_elapsed_time, row_count, command   
      FROM sys.dm_exec_distributed_sql_requests   
      WHERE execution_id = 'QID4547' and step_index = 1;  
      
    2. 尋找 DMS 步驟的執行進度

      使用先前步驟所記錄的執行識別碼與步驟索引。

      -- Find the execution progress of DMS step    
      SELECT execution_id, step_index, dms_step_index, status,   
      type, bytes_processed, total_elapsed_time  
      FROM sys.dm_exec_dms_workers   
      WHERE execution_id = 'QID4547'   
      ORDER BY total_elapsed_time DESC;
      
  4. 尋找外部 DMS 作業的相關資訊

    使用先前步驟所記錄的執行識別碼與步驟索引。

    SELECT execution_id, step_index, dms_step_index, compute_node_id,   
    type, input_name, length, total_elapsed_time, status   
    FROM sys.dm_exec_external_work   
    WHERE execution_id = 'QID4547' and step_index = 7   
    ORDER BY total_elapsed_time DESC;  
    

檢視 PolyBase 查詢計畫

在 SQL Server 2019 (15.x) 中,可使用追蹤旗標 6408 檢視傳遞至外部資料來源的執行計畫。 如需詳細資訊,請參閱如何判斷是否發生外部下推

在 SQL Server 2016 (13.x) 或 SQL Server 2017 (14.x) 中,此替代策略可運作:

  1. 在 SQL Server Management Studio 中,啟用 [包括實際執行計畫] (Ctrl + M) 並執行查詢。

  2. 選取 [執行計畫] 索引標籤。

    Screenshot from SQL Server Management Studio of a PolyBase query execution plan.

  3. 在 [遠端查詢運算子] 上按一下滑鼠右鍵,然後選取 [屬性]

  4. 複製遠端查詢值,並將其貼至文字編輯器,以檢視 XML 遠端查詢計畫。 範例如下所示。

sql_operation 標籤表示作業在 SQL Server 內。 operation_types 不是 "ON" 的 dsql_operations 表示 PolyBase 資料移動服務所使用的外部運算子。

<dsql_query number_nodes="1" number_distributions="8" number_distributions_per_node="8">  
   <sql>ExecuteMemo explain query</sql>  
   <dsql_operations total_cost="0" total_number_operations="6">  
     <dsql_operation operation_type="RND_ID">  
       <identifier>TEMP_ID_74</identifier>  
     </dsql_operation>  
     <dsql_operation operation_type="ON">  
       <location permanent="false" distribution="AllDistributions" />  
       <sql_operations>  
         <sql_operation type="statement">CREATE TABLE [tempdb].[dbo].[TEMP_ID_74] ([SensorKey] INT NOT NULL, [CustomerKey] INT NOT NULL, [GeographyKey] INT, [Speed] FLOAT(53) NOT NULL, [YearMeasured] INT NOT NULL ) WITH(DATA_COMPRESSION=PAGE);</sql_operation>  
       </sql_operations>  
     </dsql_operation>  
     <dsql_operation operation_type="ON">  
       <location permanent="false" distribution="AllDistributions" />  
       <sql_operations>  
         <sql_operation type="statement">EXEC [tempdb].[sys].[sp_addextendedproperty] @name=N'IS_EXTERNAL_STREAMING_TABLE', @value=N'true', @level0type=N'SCHEMA', @level0name=N'dbo', @level1type=N'TABLE', @level1name=N'TEMP_ID_74'</sql_operation>  
       </sql_operations>  
     </dsql_operation>  
     <dsql_operation operation_type="ON">  
       <location permanent="false" distribution="AllDistributions" />  
       <sql_operations>  
         <sql_operation type="statement">UPDATE STATISTICS [tempdb].[dbo].[TEMP_ID_74] WITH ROWCOUNT = 2401, PAGECOUNT = 7</sql_operation>  
       </sql_operations>  
     </dsql_operation>  
     <dsql_operation operation_type="MULTI">  
       <dsql_operation operation_type="STREAMING_RETURN">  
         <operation_cost cost="1" accumulative_cost="1" average_rowsize="24" output_rows="5762.1" />  
         <location distribution="AllDistributions" />  
         <select>SELECT [T1_1].[SensorKey] AS [SensorKey],  
          [T1_1].[CustomerKey] AS [CustomerKey],  
          [T1_1].[GeographyKey] AS [GeographyKey],  
          [T1_1].[Speed] AS [Speed],  
          [T1_1].[YearMeasured] AS [YearMeasured]  
   FROM   (SELECT [T2_1].[SensorKey] AS [SensorKey],  
                  [T2_1].[CustomerKey] AS [CustomerKey],  
                  [T2_1].[GeographyKey] AS [GeographyKey],  
                  [T2_1].[Speed] AS [Speed],  
                  [T2_1].[YearMeasured] AS [YearMeasured]  
           FROM   [tempdb].[dbo].[TEMP_ID_74] AS T2_1  
           WHERE  ([T2_1].[Speed] > CAST (6.50000000000000000E+001 AS FLOAT))) AS T1_1</select>  
       </dsql_operation>  
       <dsql_operation operation_type="ExternalRoundRobinMove">  
         <operation_cost cost="16.594848" accumulative_cost="17.594848" average_rowsize="24" output_rows="19207" />  
         <external_uri>hdfs://<ip address>:8020/Demo/car_sensordata.tbl/</external_uri>  
         <destination_table>[TEMP_ID_74]</destination_table>  
       </dsql_operation>  
     </dsql_operation>  
     <dsql_operation operation_type="ON">  
       <location permanent="false" distribution="AllDistributions" />  
       <sql_operations>  
         <sql_operation type="statement">DROP TABLE [tempdb].[dbo].[TEMP_ID_74]</sql_operation>  
       </sql_operations>  
     </dsql_operation>  
   </dsql_operations>  
</dsql_query>  

監視 PolyBase 群組中的節點

設定 PolyBase 相應放大群組中的電腦之後,即可監視這些電腦的狀態。 如需建立相應放大群組的詳細資料,請參閱 PolyBase 相應放大群組

  1. 連接到群組前端節點上的 SQL Server。

  2. 執行 DMV sys.dm_exec_compute_nodes (Transact-SQL),以檢視 PolyBase 群組中的所有節點。

  3. 執行 DMV sys.dm_exec_compute_node_status (Transact-SQL),以檢視 PolyBase 群組中所有節點的狀態。

Hadoop 名稱節點的高可用性

PolyBase 不會與名稱節點 HA 服務互動,例如目前的 Zookeeper 或 Knox。 不過,有一個經證實有效的因應措施可以提供這項功能。

因應措施:使用 DNS 名稱,將連線重新路由到作用中的名稱節點。 若要這樣做,您必須確認外部資料來源是使用 DNS 名稱來與名稱節點通訊。 發生名稱節點容錯移轉時,您必須變更與外部資料來源定義中所用的 DNS 名稱建立關聯的 IP 位址。 如此即會將所有新的連線重新路由至正確的名稱節點。 發生容錯移轉時,現有的連線將會失敗。 若要自動化此程序,「活動訊號」可 Ping 到作用中的名稱節點。 如果活動訊號失敗,我們就可以假設發生過容錯移轉,並自動切換至次要的 IP 位址。

記錄檔位置

在 Windows 伺服器中,記錄檔預設位於安裝目錄路徑中:c:\Program Files\Microsoft SQL Server\MSSQLnn.InstanceName\MSSQL\Log\PolyBase\

在 Linux 伺服器中,記錄預設位於 /var/opt/mssql/log/polybase

PolyBase 資料移動記錄檔:

  • <INSTANCENAME>_<SERVERNAME>_Dms_errors.log
  • <INSTANCENAME>_<SERVERNAME>_Dms_movement.log

PolyBase 引擎服務記錄檔:

  • <INSTANCENAME>_<SERVERNAME>_DWEngine_errors.log
  • <INSTANCENAME>_<SERVERNAME>_DWEngine_movement.log
  • <INSTANCENAME>_<SERVERNAME>_DWEngine_server.log

在 Windows ,PolyBase JAVA 的記錄檔:

  • <SERVERNAME> Dms polybase.log
  • <SERVERNAME>_DWEngine_polybase.log

在 Linux ,PolyBase JAVA 的記錄檔:

  • /var/opt/mssql-extensibility/hdfs_bridge/log/hdfs_bridge_pdw.log
  • /var/opt/mssql-extensibility/hdfs_bridge/log/hdfs_bridge_dms.log

錯誤訊息與可能的解決方案

如需常見的疑難排解案例,請參閱 PolyBase 錯誤與可能的解決方案