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. idea 将工程项目打包成war

    1.File--Project structure ---- Artifacts ----- + -----web Application :Archive ---for ' **:war explo ...

  2. [bzoj3226][Sdoi2008]校门外的区间——线段树

    题目 略 题解 直接套黄学长模板. Orz 代码 #include <bits/stdc++.h> using namespace std; #define ll long long #d ...

  3. django-crontab

    django-cromtab实现定时任务 参考:https://www.jianshu.com/p/1def9226158d ''' 首先安装插件:pip install django-crontab ...

  4. Django【进阶】

    FBV和CBV http://www.cnblogs.com/lucaq/p/7565560.html 中间件 http://www.cnblogs.com/lucaq/p/7581234.html ...

  5. 手把手教你最简单的开源项目托管GitHub入门教程

    自从google code关闭了下载服务了之后,GitHub作为了目前最好用的免费开源项目托管站点,众多开源项目都托管在github,其中不乏著名的播放器MPC-HC. 不习惯于英文的朋友,难免少不了 ...

  6. 关于EINTR错误的理解【转】

    转自:http://www.xuebuyuan.com/1470645.html 最近在工作中遇到了EINTR错误,感到比较困惑,几番研究之后,颇有心得和收获,特记录如下,便于以后查询,也给有同样困惑 ...

  7. linux中的阻塞机制及等待队列【转】

    转自:http://www.cnblogs.com/gdk-0078/p/5172941.html 阻塞与非阻塞是设备访问的两种方式.驱动程序需要提供阻塞(等待队列,中断)和非阻塞方式(轮询,异步通知 ...

  8. Make recursive

    folder structure: Makefile t1/Makefile t1/t1.c t2/Makefile t2/t2.c Makefile SUBDIRS = t1 t2 all: for ...

  9. platform型设备在/dev目录下自动创建设备节点的分析【转】

    转自:http://blog.csdn.net/rockrockwu/article/details/7357648 系统启动过程中platform设备.驱动注册完毕,为什么在/dev目录下就自动创建 ...

  10. Javascript传参参考

    可参考的细节: <!doctype html> <html lang="en"> <head> <meta charset="U ...