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的更多相关文章

  1. Microsoft SQL Server Trace Flags

    Complete list of Microsoft SQL Server trace flags (585 trace flags) REMEMBER: Be extremely careful w ...

  2. sql server trace 和 Profiler

    MS SQL Server Profiler概述:       MS SQL Server Profiler是SQL Trace的GUI接口,提供对SQL Server Database Engine ...

  3. Sql Server trace flags

    Tace flag number Description -T1205 每次deadlock算法运行时,都收集相关的信息 -T1204 当deadlock算法发现死锁时才收集相关信息 -T3604 把 ...

  4. SQL Server on Red Hat Enterprise Linux——RHEL上的SQL Server(全截图)

    本文从零开始一步一步介绍如何在Red Hat Enterprise Linux上搭建SQL Server 2017,包括安装系统.安装SQL等相关步骤和方法(仅供测试学习之用,基础篇). 一.   创 ...

  5. SQL Server on Red Hat Enterprise Linux

    本文从零开始一步一步介绍如何在Red Hat Enterprise Linux上搭建SQL Server 2017,包括安装系统.安装SQL等相关步骤和方法(仅供测试学习之用,基础篇). 一.   创 ...

  6. sql server trace

    http://www.cnblogs.com/zhijianliutang/p/4113911.html http://www.cnblogs.com/studyzy/archive/2009/01/ ...

  7. RML Utilities for SQL Server

    很早以前有看到过关于使用RML Utilities工具分析SQL Trace(.trc)的文章,但一直没有具体实践.最近接管一台数据库服务器,跟踪出一批高消耗的语句,老大需要跟踪分析报表,罗列出过程( ...

  8. SQL Server On Linux:基于实际项目案例,总结功能支持情况及相关问题解决方案,讲如何快速完成迁移

    上个月,有个朋友问我说Sql Sever向Mysql迁移有什么好的经验分享,他们公司客户明确提出不再提供Windows服务器,现在计划Mysql迁移.我说Mysql迁移成本太高了,不妨可以了解一下SQ ...

  9. SQL Server 监控 使用sp_trace_create

    监控前言 上一节我们提到了MSSQL的基于SQL Event的监控,但是有些时候我们需要更加详细.适用于调优排错的监控.SQL Server内部运行的可见性是的查询调整.优化和综合排查成为可能!这一节 ...

随机推荐

  1. Ubuntu gnome 16.04下的一些个人配置

    虽说并没有改什么,但还是花了我很长时间去搞明白…… 最开始要看下这里,调下比如系统时间等东西 UPD:安装时千万不要对主目录进行加密 1.登录前调整一下触控板和打开小键盘 先打开/etc/gdm3/I ...

  2. 【CodeForces】841D. Leha and another game about graph(Codeforces Round #429 (Div. 2))

    [题意]给定n个点和m条无向边(有重边无自环),每个点有权值di=-1,0,1,要求仅保留一些边使得所有点i满足:di=-1或degree%2=di,输出任意方案. [算法]数学+搜索 [题解] 最关 ...

  3. 【洛谷 P1653】 猴子 (并查集)

    题目链接 没删除调试输出,原地炸裂,\(80\)->\(0\).如果你要问剩下的\(20\)呢?答:数组开小了. 这题正向删边判连通性是很不好做的,因为我们并不会并查集的逆操作.于是可以考虑把断 ...

  4. bugscan泄露代码解密

    #{文件名:decode key} dekey_dict= {'expback_64pyc_dis.py': 'ef632082c7620cf54876da74a1660bfb9c06eb94549b ...

  5. Django【进阶】缓存

    Django缓存 由于Django是动态网站,所有每次请求均会去数据进行相应的操作,当程序访问量大时,耗时必然会更加明显,最简单解决方式是使用:缓存,缓存将一个某个views的返回值保存至内存或者me ...

  6. 僵尸进程(zombie process)

    僵尸进程(zombie process) http://blog.csdn.net/crfoxzl/article/details/2124718 杀死Linux中的defunct进程(僵尸进程)的方 ...

  7. 最简单的DLL

    静态链接库与动态链接库都是共享代码的方式,如果采用静态链接库,则无论你愿不愿意,lib 中的指令都全部被直接包含在最终生成的 EXE 文件中了.但是若使用 DLL,该 DLL 不必被包含在最终 EXE ...

  8. onchange监听input值变化及input隐藏后change事件不触发的原因与解决方法(设置readonly后onchange不起作用的解决方案)

    转自:https://www.cnblogs.com/white0710/p/7338456.html 1. onchange事件监听input值变化的使用方法: <input id=" ...

  9. js实现双指缩放图片 手机端双指缩放图片

    首先引入js文件,需要jq,pinchzoom.js.pinchzoom.js需要在jq环境下使用,可以 <meta name="viewport" content=&quo ...

  10. Newtonsoft.Json 序列化和反序列化 以及时间格式

    1.JSON序列化 string JsonStr= JsonConvert.SerializeObject(Entity); eg:   A a=new A(); a.Name="Elain ...