SSAS:如何查看服务器会话并且有选择性地终止某些会话
在SSAS的管理维护工作中,我们经常需要查看服务器当前的会话信息,并且根据实际情况有选择性进行终止某些会话。例如某些会话的时间过长,或者异常情况。
1. 如何查看会话列表
<Discover xmlns="urn:schemas-microsoft-com:xml-analysis">
<RequestType>DISCOVER_SESSIONS</RequestType>
<Restrictions>
<RestrictionList>
</RestrictionList>
</Restrictions>
<Properties>
<PropertyList>
</PropertyList>
</Properties>
</Discover>
这个语句看到的结果大致如下
<return xmlns="urn:schemas-microsoft-com:xml-analysis">
<root xmlns="urn:schemas-microsoft-com:xml-analysis:rowset" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<xsd:schema targetNamespace="urn:schemas-microsoft-com:xml-analysis:rowset" xmlns:sql="urn:schemas-microsoft-com:xml-sql" elementFormDefault="qualified">
<xsd:element name="root">
<xsd:complexType>
<xsd:sequence minOccurs="0" maxOccurs="unbounded">
<xsd:element name="row" type="row" />
</xsd:sequence>
</xsd:complexType>
</xsd:element>
<xsd:simpleType name="uuid">
<xsd:restriction base="xsd:string">
<xsd:pattern value="[0-9a-zA-Z]{8}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{12}" />
</xsd:restriction>
</xsd:simpleType>
<xsd:complexType name="xmlDocument">
<xsd:sequence>
<xsd:any />
</xsd:sequence>
</xsd:complexType>
<xsd:complexType name="row">
<xsd:sequence>
<xsd:element sql:field="SESSION_ID" name="SESSION_ID" type="xsd:string" minOccurs="0" />
<xsd:element sql:field="SESSION_SPID" name="SESSION_SPID" type="xsd:int" minOccurs="0" />
<xsd:element sql:field="SESSION_CONNECTION_ID" name="SESSION_CONNECTION_ID" type="xsd:int" minOccurs="0" />
<xsd:element sql:field="SESSION_USER_NAME" name="SESSION_USER_NAME" type="xsd:string" minOccurs="0" />
<xsd:element sql:field="SESSION_CURRENT_DATABASE" name="SESSION_CURRENT_DATABASE" type="xsd:string" minOccurs="0" />
<xsd:element sql:field="SESSION_USED_MEMORY" name="SESSION_USED_MEMORY" type="xsd:int" minOccurs="0" />
<xsd:element sql:field="SESSION_PROPERTIES" name="SESSION_PROPERTIES" type="xsd:string" minOccurs="0" />
<xsd:element sql:field="SESSION_START_TIME" name="SESSION_START_TIME" type="xsd:dateTime" minOccurs="0" />
<xsd:element sql:field="SESSION_ELAPSED_TIME_MS" name="SESSION_ELAPSED_TIME_MS" type="xsd:unsignedLong" minOccurs="0" />
<xsd:element sql:field="SESSION_LAST_COMMAND_START_TIME" name="SESSION_LAST_COMMAND_START_TIME" type="xsd:dateTime" minOccurs="0" />
<xsd:element sql:field="SESSION_LAST_COMMAND_END_TIME" name="SESSION_LAST_COMMAND_END_TIME" type="xsd:dateTime" minOccurs="0" />
<xsd:element sql:field="SESSION_LAST_COMMAND_ELAPSED_TIME_MS" name="SESSION_LAST_COMMAND_ELAPSED_TIME_MS" type="xsd:unsignedLong" minOccurs="0" />
<xsd:element sql:field="SESSION_IDLE_TIME_MS" name="SESSION_IDLE_TIME_MS" type="xsd:unsignedLong" minOccurs="0" />
<xsd:element sql:field="SESSION_CPU_TIME_MS" name="SESSION_CPU_TIME_MS" type="xsd:unsignedLong" minOccurs="0" />
<xsd:element sql:field="SESSION_LAST_COMMAND" name="SESSION_LAST_COMMAND" type="xsd:string" minOccurs="0" />
<xsd:element sql:field="SESSION_LAST_COMMAND_CPU_TIME_MS" name="SESSION_LAST_COMMAND_CPU_TIME_MS" type="xsd:unsignedLong" minOccurs="0" />
</xsd:sequence>
</xsd:complexType>
</xsd:schema>
<row>
<SESSION_ID>F9D1506A-C3B0-41B6-8D0A-E82770677A79</SESSION_ID>
<SESSION_SPID>1673</SESSION_SPID>
<SESSION_CONNECTION_ID>39</SESSION_CONNECTION_ID>
<SESSION_USER_NAME>THINKER\ChenXizhang</SESSION_USER_NAME>
<SESSION_CURRENT_DATABASE>Adventureworks</SESSION_CURRENT_DATABASE>
<SESSION_START_TIME>2009-06-25T12:01:06</SESSION_START_TIME>
<SESSION_ELAPSED_TIME_MS>546</SESSION_ELAPSED_TIME_MS>
<SESSION_LAST_COMMAND_START_TIME>2009-06-25T12:01:06</SESSION_LAST_COMMAND_START_TIME>
<SESSION_LAST_COMMAND_END_TIME>2009-06-25T12:01:06</SESSION_LAST_COMMAND_END_TIME>
<SESSION_LAST_COMMAND_ELAPSED_TIME_MS>0</SESSION_LAST_COMMAND_ELAPSED_TIME_MS>
<SESSION_IDLE_TIME_MS>0</SESSION_IDLE_TIME_MS>
<SESSION_CPU_TIME_MS>15</SESSION_CPU_TIME_MS>
<SESSION_LAST_COMMAND>DISCOVER_SESSIONS</SESSION_LAST_COMMAND>
<SESSION_LAST_COMMAND_CPU_TIME_MS>0</SESSION_LAST_COMMAND_CPU_TIME_MS>
</row>
<row>
<SESSION_ID>5E136A25-77B4-4893-BD01-BD918AB9AA5C</SESSION_ID>
<SESSION_SPID>1614</SESSION_SPID>
<SESSION_CONNECTION_ID>27</SESSION_CONNECTION_ID>
<SESSION_USER_NAME>THINKER\ChenXizhang</SESSION_USER_NAME>
<SESSION_CURRENT_DATABASE>Adventureworks</SESSION_CURRENT_DATABASE>
<SESSION_START_TIME>2009-06-25T11:58:46</SESSION_START_TIME>
<SESSION_ELAPSED_TIME_MS>140140</SESSION_ELAPSED_TIME_MS>
<SESSION_LAST_COMMAND_START_TIME>2009-06-25T12:00:52</SESSION_LAST_COMMAND_START_TIME>
<SESSION_LAST_COMMAND_END_TIME>2009-06-25T12:00:52</SESSION_LAST_COMMAND_END_TIME>
<SESSION_LAST_COMMAND_ELAPSED_TIME_MS>0</SESSION_LAST_COMMAND_ELAPSED_TIME_MS>
<SESSION_IDLE_TIME_MS>0</SESSION_IDLE_TIME_MS>
<SESSION_CPU_TIME_MS>0</SESSION_CPU_TIME_MS>
<SESSION_LAST_COMMAND>DISCOVER_PROPERTIES</SESSION_LAST_COMMAND>
<SESSION_LAST_COMMAND_CPU_TIME_MS>0</SESSION_LAST_COMMAND_CPU_TIME_MS>
</row>
<row>
<SESSION_ID>35CECB1C-090B-418C-B493-04D709E6E399</SESSION_ID>
<SESSION_SPID>1670</SESSION_SPID>
<SESSION_CONNECTION_ID>37</SESSION_CONNECTION_ID>
<SESSION_USER_NAME>THINKER\ChenXizhang</SESSION_USER_NAME>
<SESSION_CURRENT_DATABASE>Adventureworks</SESSION_CURRENT_DATABASE>
<SESSION_START_TIME>2009-06-25T12:01:04</SESSION_START_TIME>
<SESSION_ELAPSED_TIME_MS>2562</SESSION_ELAPSED_TIME_MS>
<SESSION_LAST_COMMAND_START_TIME>2009-06-25T12:01:06</SESSION_LAST_COMMAND_START_TIME>
<SESSION_LAST_COMMAND_END_TIME>2009-06-25T12:01:06</SESSION_LAST_COMMAND_END_TIME>
<SESSION_LAST_COMMAND_ELAPSED_TIME_MS>0</SESSION_LAST_COMMAND_ELAPSED_TIME_MS>
<SESSION_IDLE_TIME_MS>0</SESSION_IDLE_TIME_MS>
<SESSION_CPU_TIME_MS>0</SESSION_CPU_TIME_MS>
<SESSION_LAST_COMMAND>DISCOVER_PROPERTIES</SESSION_LAST_COMMAND>
<SESSION_LAST_COMMAND_CPU_TIME_MS>0</SESSION_LAST_COMMAND_CPU_TIME_MS>
</row>
</root>
</return>
2. 如何终止某个会话,使用Cancel命令即可
<Cancel xmlns="http://schemas.microsoft.com/analysisservices/2003/engine">
<SessionID>A8D16CE6-8472-4186-BBBD-7A3CB60C4DD3</SessionID>
</Cancel>