Enable a SQL Server Trace Flag Globally on Linux

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.
时间: 2024-10-11 21:14:16

Enable a SQL Server Trace Flag Globally on Linux的相关文章

SQL Server on Red Hat Enterprise Linux

本文从零开始一步一步介绍如何在Red Hat Enterprise Linux上搭建SQL Server 2017,包括安装系统.安装SQL等相关步骤和方法(仅供测试学习之用,基础篇). 一.   创建RHEL系统(Create Red Hat Enterprise Linux System) 1.      前提准备 由于本文主要研究SQL Server 2017在Linux上的搭建方法,从Install SQL Server on Linux中得知当前SQL Server 2017 CTP

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

本文从零开始一步一步介绍如何在Red Hat Enterprise Linux上搭建SQL Server 2017,包括安装系统.安装SQL等相关步骤和方法(仅供测试学习之用,基础篇). 一.   创建RHEL系统(Create Red Hat Enterprise Linux System) 1.      前提准备 由于本文主要研究SQL Server 2017在Linux上的搭建方法,从Install SQL Server on Linux中得知当前SQL Server 2017 CTP

Trace Flag

Trace Flag能够影响Sql Server的行为,主要用于diagnose performance issue,官方解释是: Trace flags are used to temporarily set specific server characteristics or to switch off a particular behavior. For example, if trace flag 3205 is set when an instance of SQL Server st

RML Utilities for SQL Server工具

今天学习了一下RML Utilities工具,觉得这个工具确实比较好的跟SQL Server Profiler工具结合起来使用,确实挺好的.工具的下载地址        SQL Server 的重播标记语言 (RML) 实用程序:https://support.microsoft.com/zh-cn/kb/944837        RML Utilities for SQL Server (x86) –  https://www.microsoft.com/en-us/download/det

Configure Red Hat Enterprise Linux shared disk cluster for SQL Server

下面一步一步介绍一下如何在Red Hat Enterprise Linux系统上为SQL Server配置共享磁盘集群(Shared Disk Cluster)及其相关使用(仅供测试学习之用,基础篇) 一.      创建共享磁盘和 Cluster 微软官方配置文档:https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-shared-disk-cluster-red-hat-7-configure. Linux Cluster结构

Configure Red Hat Enterprise Linux shared disk cluster for SQL Server——RHEL上的“类”SQL Server Cluster功能

下面一步一步介绍一下如何在Red Hat Enterprise Linux系统上为SQL Server配置共享磁盘集群(Shared Disk Cluster)及其相关使用(仅供测试学习之用,基础篇) 一.      创建共享磁盘和 Cluster 微软官方配置文档:https://docs.microsoft.com/en-us/sql/linux/sql-server-linux-shared-disk-cluster-red-hat-7-configure. Linux Cluster结构

Configure Always On Availability Group for SQL Server on RHEL——Red Hat Enterprise Linux上配置SQL Server Always On Availability Group

下面简单介绍一下如何在Red Hat Enterprise Linux上一步一步创建一个SQL Server AG(Always On Availability Group),以及配置过程中遇到的坑的填充方法. 之前发表过一篇类似的文章是Configure Always On Availability Group for SQL Server on Ubuntu——Ubuntu上配置SQL Server Always On Availability Group,有对Ubuntu感兴趣的请看那一篇

SQL Server 监控 使用sp_trace_create

监控前言 上一节我们提到了MSSQL的基于SQL Event的监控,但是有些时候我们需要更加详细.适用于调优排错的监控.SQL Server内部运行的可见性是的查询调整.优化和综合排查成为可能!这一节主要和大家说说SQL Server跟踪(SQL Server Profile)的一些监控方式和途径. 使用场景     记得某次给一家公司调优的时候,负责人发给我一堆业务的T-SQL脚本,我面对海量脚本还是从容,虽然不了解内部复杂的业务,但是我们得专注问题的关键 "慢",我们根据查询的&q

CentOS7脱机安装SQL Server 2017

原文:CentOS7脱机安装SQL Server 2017 SQL Server on Linux也发布一段时间了,官方上支持Red Hat, SUSE, Ubuntu.手上没有以上Linux版本,选用了与Red Hat最接近的CentOS7.4来进行安装和测试. 1. 环境 Linux: CentOS Linux release 7.4.1708 (Core) Memory: 4 GB SQL Server: SQL Server 2017 (RC2) - 14.0.900.75 (X64)