Enable a SQL Server Trace Flag Globally on Linux

來源:互聯網
上載者:User

標籤:dbcc   lin   images   not   cmd   space   recently   image   erp   

 https://www.mssqltips.com/sql-server-tip-category/226/sql-server-on-linux//

Microsoft has recently released SQL Server to run on Linux servers. Sometimes we need to enable a trace flag globally on SQL Server and in this tip I will demonstrate how to enable a SQL Server trace flag globally on Linux.

Solution

In SQL Server on Windows, if we want to enable a trace flag globally we can do it using one of two ways:

  • DBCC Traceon (traceflag, -1)
  • SQL Server Configuration Manager

In this tip we will see how to enable or disable trace flags in SQL Server running on Linux to use it globally.

To enable or disable a SQL Server trace flag on SQL Server on Linux, we need to use the SQL Server configuration manager utility called mssql-conf.

mssql-conf is a configuration script that installs with SQL Server vNext CTP 1.3 for Red Hat Enterprise Linux, SUSE Linux Enterprise Server and Ubuntu.

Enable a SQL Server Trace Flag Globally on Linux

First let‘s connect to SQL Server with sqlcmd and get all enabled trace flag information using DBCC tracestatus(-1).

To enable a trace flag on Linux we need to use the following command:

sudo /opt/mssql/bin/mssql-conf traceflag <TRACEFLAG_NO>on

Suppose we want to enable traceflag 1222 to run globally to capture deadlocks.

sudo /opt/mssql/bin/mssql-conf traceflag 1222 on

 

Now we need to restart the mssql service.

systemctl restart mssql-server.service

 

Now let‘s check the trace flag again to see if traceflag 1222 is enabled.

We can see here that the traceflag 1222 is enabled globally.

Enable Multiple SQL Server Trace Flags in Linux

Suppose we want to enable multiple trace flags i.e. 1204, 3205 at once.  We can do so as shown in this script:

sudo /opt/mssql/bin/mssql-conf traceflag 1204 3205 on

 

Now let‘s check the trace flags again to see if these traceflags are enabled.

Disable SQL Server Trace Flags Globally in Linux

Suppose we want to disable a trace flag.  We need to use the below command.

sudo /opt/mssql/bin/mssql-conf traceflag <TRACEFLAG_NO>Off

If we want to disable trace flag 3205, run the command as:

sudo /opt/mssql/bin/mssql-conf traceflag 3205 Off

 

Once we have restarted the SQL Server service, verify the trace flag is disabled. We cannot see the disabled trace flag 3205 here since it has been disabled.

Next Steps
  • Enable and disable a traceflag as per your requirements, but do not perform these steps directly on production systems without proper testing.
  • Read more about SQL Server on Linux Tips.

Enable a SQL Server Trace Flag Globally on Linux

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.