In the SQL world, it is an important activity to perform SQL Server installation for a database administrator. Have you ever noticed ‘SQL Server Startup Parameters’ for the SQL Service? You might not have noticed them, but these parameters are beneficial for DBAs.

在SQL世界中,对数据库管理员执行SQL Server安装是一项重要的活动。 您是否曾经注意到SQL服务的“ SQL Server启动参数”? 您可能没有注意到它们,但是这些参数对于DBA很有帮助。

Let’s say you install the SQL service database engine. After installation, services are running in the automatic mode and you can connect to the SQL instance.

假设您安装了SQL服务数据库引擎。 安装后,服务将以自动模式运行,您可以连接到SQL实例。

Let me start with a simple but logical question – What is the sequence for the SQL Service startup?

让我首先提出一个简单但合乎逻辑的问题-SQL Service启动的顺序是什么?

SQL Service启动的高级顺序 (The high-level sequence of SQL Service start-up)

It is a useful thing to know about the startup of SQL Services. The high-level steps are:

了解SQL Services的启动是很有用的。 较高级别的步骤是:

  • The request failed, or the service did not respond in a timely fashionYou can go to the event viewer and check the logs for detailed information 请求失败,或者服务没有及时响应您可以转到事件查看器并检查日志以获取详细信息
  • In the next step, it reads the SQL Server startup parameters from the registry (we will cover in detail in later part of this article) and verify the data file, log file location of the master database along with the error log path 在下一步中,它将从注册表中读取SQL Server启动参数(我们将在本文的后面部分详细介绍),并验证数据文件,master数据库的日志文件位置以及错误日志路径。
  • It allocates the memory and CPU to SQL Server as per the configuration 它根据配置将内存和CPU分配给SQL Server
  • It starts up the master database 它启动主数据库
  • The master database contains an entry for all other system databases and user databases. It reads the information of the data file and log file of the databases and starts the recovery process (Analysis, Redo and Undo phases) for the databases 主数据库包含所有其他系统数据库和用户数据库的条目。 它读取数据库的数据文件和日志文件的信息,并开始数据库的恢复过程(分析,重做和撤消阶段)
  • It creates the tempdb database file and logs files as per the initial size, number of data files etc. 它会创建tempdb数据库文件并根据初始大小,数据文件数等记录日志文件。
  • It starts the default trace audit; startup extended event sessions and records all events in the SQL Server error log 它启动默认的跟踪审核; 启动扩展事件会话并在SQL Server错误日志中记录所有事件
  • SQL Server attempts to register Service Principal Name ( SPN) to use Kerberos authentication SQL Server尝试注册服务主体名称(SPN)以使用Kerberos身份验证
  • It opens the SQL Server port and starts accepting a connection to the database. Once it is ready, you get a message in the SQL Server error logSQL Server is now ready for client connections. This is an informational message; no user action is required
  • 它打开SQL Server端口并开始接受与数据库的连接。 准备就绪后,您会在SQL Server错误日志中收到一条消息,表明SQL Server 现在已准备好进行客户端连接。 这是一条情报信息; 无需用户操作

SQL Server启动参数 (SQL Server startup parameters)

This article focuses on the startup parameters. To view the SQL Server startup parameters, right-click on the SQL Server Service and go to properties. It opens the SQL Services properties window.

本文重点介绍启动参数。 若要查看SQL Server启动参数,请右键单击“ SQL Server服务”,然后转到属性。 它打开“ SQL Services属性”窗口。

Click on the Startup Parameters. You can see the default configured SQL Server startup parameters -d, -e and -l and their values.

单击启动参数 。 您可以看到默认配置SQL Server启动参数-d,-e和-l及其值。

Let’s look at the description of each default SQL Server startup parameter.

让我们看一下每个默认SQL Server启动参数的描述。

  • -d: It is the primary data file path of the Master database -d:它是Master数据库的主要数据文件路径
  • -l: It is the transaction log file path of the Master database -l:是Master数据库的事务日志文件路径
  • -e: it is the SQL Server error log path. It is essential to know the SQL Server error log file path to investigate any issues with SQL Server. Suppose you are not familiar with the SQL instance and if you do not know the path of the error log file, you need to go through each drive to check the file. You can open the SQL Server Configuration Manager and look at the error log location -e:这是SQL Server错误日志路径。 了解SQL Server错误日志文件路径以调查SQL Server的任何问题是至关重要的。 假设您不熟悉SQL实例,并且如果您不知道错误日志文件的路径,则需要遍历每个驱动器来检查该文件。 您可以打开SQL Server配置管理器并查看错误日志位置

We can specify a few other SQL Server startup parameters in SQL Server Configuration Manager.

我们可以在SQL Server配置管理器中指定其他一些SQL Server启动参数。

-f(最低配置): (-f (Minimal Configuration):)

It starts SQL Server in a minimal configuration. Suppose we have a scenario in which SQL Service is not running due to over-committing memory. We can use this startup parameter and start SQL services in single-user mode troubleshoot further. We need to note the following in the minimal configuration startup of SQL Server.

它以最小配置启动SQL Server。 假设有一种情况,由于内存过量使用,SQL Service无法运行。 我们可以使用此启动参数,并以单用户模式启动SQL服务进一步进行故障排除。 在SQL Server的最低配置启动中,我们需要注意以下几点。

  • SQL Server remains in single-user mode SQL Server保持单用户模式
  • It does not execute the CHECKPOINT process to flush the dirty pages 它不执行CHECKPOINT进程来刷新脏页
  • It cannot run any startup stored procedures, triggers 它无法运行任何启动存储过程,触发器

Suppose after restarting the SQL Server, it does not start; in the error logs, you find out that the TempDB files could not be created because it is not pointing to the correct location. We cannot alter tempdb file paths as well because we are not connected to SQL Server. In this case, this parameter helps us to start SQL Server with minimal configuration. We can connect to SQL Server with this parameter with SQLCMD and execute an alter database command. Restart SQL Services, and you can connect to SQL Server.

假设在重新启动SQL Server之后,它没有启动; 在错误日志中,您发现无法创建TempDB文件,因为它没有指向正确的位置。 我们也无法更改tempdb文件路径,因为我们未连接到SQL Server。 在这种情况下,此参数有助于我们以最少的配置启动SQL Server。 我们可以使用带有SQLCMD的此参数连接到SQL Server并执行alter database命令。 重新启动SQL服务,您可以连接到SQL Server。

Open an administrative command prompt. Go to the binn directory of SQL Server and run the following command.

打开一个管理命令提示符。 转到SQL Server的binn目录,然后运行以下命令。

>Sqlserver.exe -s SQL2019CTP /f

> Sqlserver.exe -s SQL2019CTP / f

In this command, we specified named instance using -s parameter. If you connect with the default instance, we do not need to use this parameter.

在此命令中,我们使用-s参数指定了命名实例。 如果您使用默认实例进行连接,则无需使用此参数。

It opens the SQL Server using minimal configuration. It shows SQL Server logs as well, and you can see an entry for it.

它使用最少的配置打开SQL Server。 它还显示SQL Server日志,并且您可以看到它的条目。

If the SQL Services are already running, you cannot start SQL Server in a minimal configuration. If you try to do, you get the following error messages.

如果SQL Services已经在运行,则不能以最低配置启动SQL Server。 如果尝试这样做,则会收到以下错误消息。

Now you can open Sqlcmd and connect with the SQL Server to execute the query in minimal mode.

现在,您可以打开Sqlcmd并与SQL Server连接,以最小模式执行查询。

>sqlcmd -S kashish\sql2019ctp -E

> sqlcmd -S kashish \ sql2019ctp -E

You can press CTRL+C to move out from the minimal mode.

您可以按CTRL + C退出最小模式。

-m(单用户模式): (-m (Single user Mode):)

It is a useful SQL Server startup parameter to start SQL Server in a single user mode. We might need to use a single-user mode in SQL Server to fix certain issues. For example, suppose you have completely locked out the SQL Server, and no one can connect to the SQL Server. In this case, you can use this mode to connect to SQL and reset the admin password or create a new user with the admin permissions.

在单用户模式下启动SQL Server是有用SQL Server启动参数。 我们可能需要在SQL Server中使用单用户模式来解决某些问题。 例如,假设您已经完全锁定了SQL Server,并且没有人可以连接到SQL Server。 在这种情况下,可以使用此模式连接到SQL并重置管理员密码或创建具有管理员权限的新用户。

Go to the SQL Server Configuration Manager, right-click the SQL Server Service, and choose Properties. Go to Startup Parameters as shown below, specify the -m parameter and click on Add.

转到“ SQL Server配置管理器”,右键单击“ SQL Server服务”,然后选择“属性”。 如下所示,转到启动参数,指定-m参数,然后单击添加。

Click on Apply, and you get a warning message to restart SQL Service to activate the SQL Server startup parameter. If we do not restart SQL Server, the changes will not be active.

单击“应用”,您将收到一条警告消息,以重新启动SQL Service来激活SQL Server启动参数。 如果我们不重新启动SQL Server,则更改将无效。

Now start SQL Service and connect to SQL Server.

现在启动SQL Service并连接到SQL Server。

Only one user can connect to SQL Server in this mode; if you try to connect to more than one connection, you get the following error:

在这种模式下,只有一个用户可以连接到SQL Server。 如果您尝试连接到多个连接,则会出现以下错误:

sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login failed for user ‘kashish\Test’. Reason: Server is in single-user mode. Only one administrator can connect at this time.

sqlcmd:错误:SQL Server的Microsoft ODBC驱动程序13:用户'kashish \ Test'登录失败。 原因:服务器处于单用户模式。 此时只有一个管理员可以连接。

-客户端应用程序名称: (-Client Application Name:)

In the single-user mode, we can limit the connections from a specific application as well. For example, we might want to limit the connection for SQLCMD command-line tool or SSMS.

在单用户模式下,我们也可以限制来自特定应用程序的连接。 例如,我们可能想限制SQLCMD命令行工具或SSMS的连接。

  • Specify -m”Microsoft SQL Server Management Studio – Query” SQL Server startup parameters for SSMS 为SSMS指定-m“ Microsoft SQL Server Management Studio –查询” SQL Server启动参数
  • Specify -mSQLCMD for SQLCMD connection 为SQLCMD连接指定-mSQLCMD

We need to note that the client application name is a case sensitive string. We should not use for implementing security restrictions for all connections; we can use it with single-user mode only. You cannot use the SQL Server Configuration manager to set this startup parameter.

我们需要注意,客户端应用程序名称是区分大小写的字符串。 我们不应将所有连接用于实施安全性限制; 我们只能在单用户模式下使用它。 您不能使用SQL Server配置管理器来设置此启动参数。

-n(Windows事件日志): (-n (Windows event logs):)

You might be aware that SQL Server logs all critical events in the SQL Server error logs as well as Windows Logs. If we do not want to use windows events logs to be populated with the SQL error logs, start SQL Service with the –n parameter. We need to specify –e SQL Server startup parameter as well along with this else SQL Server error logs also do not get any entry.

您可能已经知道,SQL Server在SQL Server错误日志和Windows日志中记录了所有关键事件。 如果我们不想使用Windows事件日志填充SQL错误日志,请使用–n参数启动SQL Service。 我们还需要指定–e SQL Server启动参数,否则SQL Server错误日志也不会获得任何条目。

-s(命名实例): (-s (named instance):)

In SQL Server, we can use a default instance and multiple named instances in the same server. If we want to start a named instance in SQL Server with the command line, we need to use –s SQL Server startup parameter along with the instance name. In the SQL Server error logs also, we get an entry for this parameter.

在SQL Server中,我们可以在同一服务器中使用默认实例和多个命名实例。 如果要通过命令行在SQL Server中启动命名实例,则需要使用–s SQL Server启动参数以及实例名称。 同样在SQL Server错误日志中,我们获得了此参数的条目。

Suppose we have a named instance SQLDemo then in the error logs, you can see an entry

假设我们有一个命名实例SQLDemo,那么在错误日志中,您可以看到一个条目

Command Line Startup Parameters: -s “SQLDemo.”

命令行启动参数:-s“ SQLDemo”。

-x(禁用数据收集): (-x (Disable data collection):)

Sometimes, we might require to start SQL Services and do not capture any performance monitor parameter values, data from the dynamic management views, we can start SQL Services with the –x parameter. It does not capture the data for the following things.

有时,我们可能需要启动SQL Services,并且不捕获任何性能监视器参数值(来自动态管理视图的数据),我们可以使用–x参数启动SQL Services。 它不会捕获以下数据。

  • Performance counter data for the SQL Server SQL Server的性能计数器数据
  • Dynamic management view statistics 动态管理视图统计
  • Certain extended events data 某些扩展事件数据
  • It does not monitor CPU; Cache hit ratio data as well 它不监视CPU; 缓存命中率数据
  • Note: We should be cautious with this parameter. It is not recommended, especially for the production SQL Server instance. You will not be able to get the troubleshooting data in case of any issue.注意:我们应该谨慎使用此参数。 不建议这样做,特别是对于生产SQL Server实例。 如果出现任何问题,您将无法获取故障排除数据。

-E(范围数): (-E (Number of extents):)

We can use this SQL Server startup parameter to increase the number of extents for each data file in a filegroup. This parameter might be useful for data warehouse scenarios. We should test the impact of this parameter with the application and the database before using it for SQL Service restart.

我们可以使用此SQL Server启动参数来增加文件组中每个数据文件的扩展区数。 此参数对于数据仓库方案可能很有用。 在将其用于SQL Service重新启动之前,我们应该在应用程序和数据库中测试此参数的影响。

-k(检查点速度): (-k (Checkpoint speed):)

We can use this parameter to set the CHECKPOINT speed in IO request per second. For example, -k100 specifies to use 100 MB per second checkpoint IO speed.

我们可以使用此参数设置每秒IO请求中的CHECKPOINT速度。 例如,-k100指定使用每秒100 MB的检查点IO速度。

We should be careful in using this parameter as it might put a negative impact on the database backups, restore, recovery processes.

我们在使用此参数时应格外小心,因为它可能会对数据库备份,还原,恢复过程产生负面影响。

-T(跟踪标志): (-T (Trace Flags):)

In SQL Server, we use trace flags to change the system behavior or capture internal information. It is a useful SQL Server startup parameter and allows the SQL Server to start with the specified trace flag. Suppose we want to start SQL Service and it should start capturing any deadlock events as soon it gets user connections. We can add –T1222 trace flag in startup parameters to do this task.

在SQL Server中,我们使用跟踪标志来更改系统行为或捕获内部信息。 它是一个有用SQL Server启动参数,并允许SQL Server以指定的跟踪标志启动。 假设我们要启动SQL Service,并且它应该在获取用户连接后立即开始捕获任何死锁事件。 我们可以在启动参数中添加–T1222跟踪标志来执行此任务。

  • Note: We must use capital letter T along with the trace flag number. SQL Server also accepts small letter t, but these are internal trace flag (not available for DBA) and must be used in coordination with the Microsoft support engineers. 注意:我们必须使用大写字母T和跟踪标志号。 SQL Server还接受小写字母t,但它们是内部跟踪标志(不适用于DBA),必须与Microsoft支持工程师配合使用。

结论 (Conclusion)

In this article, we explored SQL Server Startup Parameters for Database Engine Services. You should be aware of these parameters and use them as per the requirement.

在本文中,我们探讨了数据库引擎服务SQL Server启动参数。 您应该了解这些参数,并根据要求使用它们。

翻译自: https://www.sqlshack.com/overview-of-sql-server-startup-parameters-for-the-sql-database-engine-service/

SQL数据库引擎服务SQL Server启动参数概述相关推荐

  1. 安装SQL数据库引擎失败的解决方案(SQL Server 2019)

    问题描述: 在安装到最后一步时,跳出命令,命令消失后提示安装包有问题. 最后显示SQL数据库引擎安装失败. 尝试打开SQL ServerManagement Studio 18,服务器名称为空,查询网 ...

  2. sql服务器没有及时响应或控制请求,Win7启动sql数据库提示“服务没有及时响应启动或控制请求”怎么办?...

    最近有Win7用户反映,启动sql数据库的时候出现提示"服务没有及时响应启动或控制请求",导致sql数据库启动失败,这让用户非常烦恼.那么,Win7启动sql数据库提示" ...

  3. Azure SQL 数据库:服务级别与性能问答

    ShawnBice    2014 年 5 月 5 日上午 10:00 几天前,我发表了一篇文章,并就 4 月 24 日发布的适用于Windows Azure SQL 数据库的新服务级别提供了一些预料 ...

  4. 压缩SQL数据库日志-收缩SQL数据库日志-备份SQL数据库日志-删除SQL数据库日志

    [标题]压缩SQL数据库日志-收缩SQL数据库日志-备份SQL数据库日志-删除SQL数据库日志  [内容]         清除SQL数据库日志文件        有两种方式: 一.是压缩日志,二.是 ...

  5. 使用 DMV 进行监视_监视资源使用情况(1)_针对 Azure SQL 数据库和 Azure SQL 托管实例进行手动性能优化

    本文适用:AZURE SQL数据库 AZURE SQL数据库/托管实列,由于引入PORTAL等管理工具的概念,所以在监视资源上面我们的手段就比较多样化了,在本篇以及接下来的后续篇章中会详细展开,敬请期 ...

  6. SQL数据库挂起 SQL数据库附加报错 SQL数据库824错误修复

    SQL数据库挂起 SQL数据库附加报错 SQL数据库824错误修复 数据类型 MSSQL 2012 数据大小 4.5 GB 故障检测 附加数据库提示824错误 一般是由于断电非法关机导致页面损坏. 客 ...

  7. 使用 DMV 进行监视_监视查询性能_针对 Azure SQL 数据库和 Azure SQL 托管实例进行手动性能优化

    本文适用:AZURE SQL数据库,AZURE SQL托管实例 SQL是系统和数据库交互的重要方式,日常工作中我们经常被性能糟糕的SQL所干扰.同样在AZURE数据库中,我们依旧面临相同的问题.缓慢或 ...

  8. 使用 DMV 进行监视_监视连接_针对 Azure SQL 数据库和 Azure SQL 托管实例进行手动性能优化

    本文适用:AZURE SQL数据库,AZURE SQL托管实例 可以使用 sys.dm_exec_connections 视图检索与特定服务器和托管实例建立的连接的相关信息和每个连接的详细信息. 此外 ...

  9. 详解数据库引擎与SQL语句增删改查(非常详细,带例)

    数据库系统(DBMS): 专门负责数据管理的工具.增加数据.创建索引.建立索引之间的关联关系.更新索引...... 连接器:PHP要访问MySQL,可以通过API访问,也可以通过PHP的驱动,而那个驱 ...

最新文章

  1. java 线程池 分组_JAVA面试题解惑系列(十)——话说多线程
  2. 应用程序的并行配置不正确_阿里架构师:天天高并发,达不到百万以上并发都不叫高并发...
  3. Android之Debug运行项目一直卡在Debug界面(can‘t bind to local 8066 for debug)
  4. linux 查看下挂磁盘,linux下磁盘挂载与查看
  5. 前端学习(2613):action的方法
  6. Windows 10 下基于WSL的开源飞控开发环境配置(Ardupilot/PX4)
  7. Java性能调优小技巧
  8. 用友u8 12.1服务器硬件要求,用友U8-12.1安装操作手册(服务器)
  9. 该怎么输出log?!
  10. 统计自然语言处理基础_聚类
  11. RabbitMQ 实现RPC
  12. 日期、时间、格式、补零(0、〇)操作、length、String、slice、getFullYear、getMonth、getDate、getHours、getMinutes、getSeconds
  13. 动手学深度学习之锚框
  14. swagger2 注解
  15. 快捷键切换(Linux)
  16. nabc模型_团队开发-极速蜗牛-NABC模型
  17. 人工智能写作的春天来了 除了写作, 人工智能还能写诗、画画
  18. 测试打字速度测试程序c语言,打字速度测试软件
  19. python数据分析实战之用户分析及RFM模型分析
  20. vcs -fgp 仿真加速功能

热门文章

  1. Python学习笔记(三)Python安装及设置环境变量
  2. MySQL中Checkpoint技术
  3. MyBatis(3):SQL映射
  4. 手机各种JS语法,随时更新
  5. UIViewController 之LoadView详解
  6. ucos-II 任务间同步源码分析(一)
  7. c#调用带有安全认证的java webservice
  8. 重新打包版Inno Setup 5.4.3
  9. kubernetes之一:Pod
  10. 计算机网络学习笔记(12. 计算机网络体系结构概述)