转储sql文件_在Linux上SQL Server中更改SQL转储文件位置
转储sql文件
In this article, we will talk about SQL Dump files and the process to change the dump directory in Linux SQL Server.
在本文中,我们将讨论SQL Dump文件以及在Linux SQL Server中更改转储目录的过程。
Dumps in SQL Server help to investigate system crashes or other exceptions in SQL Server instances. You might have experienced a Microsoft CSS asking to upload the dumps while working on troubleshooting on an issue. We can do the analysis, ourselves, based on the dumps which will give you information about the things running during that time. We have seen below types of dumps in the SQL Server.
SQL Server中的转储有助于调查SQL Server实例中的系统崩溃或其他异常。 在解决问题时,您可能会遇到Microsoft CSS要求上传转储的问题。 我们可以根据转储自己进行分析,这将为您提供有关这段时间运行的信息。 我们已经在SQL Server中看到以下类型的转储。
- Mini Dump: this gives the basic information on the SQL Server stack. We do not get information about the data pages or the index pages. This dump is enabled by default in SQL Server 小型转储:提供有关SQL Server堆栈的基本信息。 我们没有获得有关数据页或索引页的信息。 默认情况下,在SQL Server中启用此转储
- Full Dump: In the full dump, SQL Server captures the entire process memory dump. We get information about the hashed and the stolen pages as well. We need to enable this using trace flag 2544 (DBCC TraceOn 2544, -1) 完全转储:在完全转储中,SQL Server捕获整个进程内存转储。 我们还获得有关散列页面和被盗页面的信息。 我们需要使用跟踪标志2544(DBCC TraceOn 2544,-1)启用此功能
- Filtered Dump: in the filtered dump, we get information about all structures and the stolen buffers. We need to enable this using trace flag 2551 (DBCC TraceOn 2551, -1) 过滤的转储:在过滤的转储中,我们获取有关所有结构和被盗缓冲区的信息。 我们需要使用跟踪标志2551(DBCC TraceOn 2551,-1)启用它
- Exception Dumps: if there is an exception in the SQL Server processes, we get this dump. You can use the undocumented command DBCC DUMPTRIGGER to create a dump on any particular error 异常转储:如果SQL Server进程中存在异常,则得到此转储。 您可以使用未记录的命令DBCC DUMPTRIGGER创建针对任何特定错误的转储
You might find multiple dump files in the log folder in the extension of *.mdmp,*.txt, and *.log files.
您可能会在* .mdmp,*。txt和* .log文件扩展名的日志文件夹中找到多个转储文件。
- Memory Dump: We get memory dump files with the format of SQLDump<nnnn>.mdmp. It is the memory dump of the SQL Server process generated during an issue. Microsoft requires these dump files to investigate the issue 内存转储:我们以SQLDump <nnnn> .mdmp的格式获取内存转储文件。 它是问题期间生成SQL Server进程的内存转储。 Microsoft需要这些转储文件来调查问题
- Dump file: We these files in the format of SQLDump<nnnn>.txt that contains environmental information 转储文件:这些文件采用SQLDump <nnnn> .txt格式,包含环境信息
- Error log file: Another file is generated in the format of SQLDump<nnnn>.txt, which contains a snapshot of the error log when the dump was generated. We can look at the information in the error log as well however if the error log is recycled, this snap can help to troubleshoot the issue 错误日志文件:另一个文件以SQLDump <nnnn> .txt格式生成,其中包含生成转储时错误日志的快照。 我们也可以查看错误日志中的信息,但是,如果错误日志被回收,此快照可以帮助解决问题
Below are the few conditions in which we can see a minidump generated by the SQL Server.
下面是几个可以查看由SQL Server生成的小型转储的情况。
- Non-Yielding scheduler 非收益调度器
- Non-yielding resource monitor 非收益资源监控器
- Non-yielding IOCP listener 不屈服的IOCP侦听器
- Latch Timeout 锁存超时
- Deadlocks Schedulers 死锁调度程序
- DB Corruption 数据库腐败
- Process exceptions 流程例外
In SQL Server on a Windows environment, we can go to SQL Server Configuration Manager. In the SQL Server service properties, we can look and change the path the dump directory in the advanced section as shown below.
在Windows环境中SQL Server中,我们可以转到SQL Server配置管理器。 在SQL Server服务属性中,我们可以在高级部分中查找并更改转储目录的路径,如下所示。
By default, Dump directory is ‘C:\Microsoft SQL Server\MSSQL10_50.MSSQLSERVER\MSSQL\LOG\’ in Windows system.
默认情况下,在Windows系统中,转储目录为“ C:\ Microsoft SQL Server \ MSSQL10_50.MSSQLSERVER \ MSSQL \ LOG \”。
![转储sql文件_在Linux上SQL Server中更改SQL转储文件位置 转储sql文件_在Linux上SQL Server中更改SQL转储文件位置](/wp-content/uploads/2018/12/word-image-563.png)
You can set up SQL Server 2019 on Ubuntu Linux by following up the article, SQL Server 2019 installation on Ubuntu without a Docker Container.
您可以通过遵循文章在没有Docker Container的Ubuntu上安装SQL Server 2019的文章来在Ubuntu Linux上设置SQL Server 2019。
在Linux上SQL Server中转储文件位置 (Dump files location in SQL Server on Linux)
I will assume that you have installed SQL Server 2019 on Ubuntu Operating system. First, check the status of the SQL Server services using the below command.
我将假定您已在Ubuntu操作系统上安装了SQL Server 2019。 首先,使用以下命令检查SQL Server服务的状态。
Command:
命令:
$ sudo systemctl status mssql-server
$ sudo systemctl状态mssql-server
![转储sql文件_在Linux上SQL Server中更改SQL转储文件位置 转储sql文件_在Linux上SQL Server中更改SQL转储文件位置](/wp-content/uploads/2018/12/word-image-564.png)
We can see that SQL Service is in running (active) state and process id is assigned to the SQL Server service.
我们可以看到SQL服务处于运行(活动)状态,并且进程ID已分配给SQL Server服务。
As stated above, by default memory dump files are generated in the .log folder however it is for windows. In Linux, default path for the memory dump files are /var/opt/mssql/log.
如上所述,默认情况下,.log文件夹中会生成内存转储文件,但它适用于Windows。 在Linux中,内存转储文件的默认路径为/ var / opt / mssql / log。
Let us check the content of this path using the ls –lrt command.
让我们使用ls –lrt命令检查此路径的内容。
$ sudo su
$ sudo su
$ cd /var/opt/mssql/log
$ cd / var / opt / mssql / log
# ls –lrt
#ls –lrt
![转储sql文件_在Linux上SQL Server中更改SQL转储文件位置 转储sql文件_在Linux上SQL Server中更改SQL转储文件位置](/wp-content/uploads/2018/12/word-image-565.png)
In the above screenshot, you can see there are multiple files for example trace files (*.trc), *.xel (extended event session files), SQL agent logs file (SQLagent.out), the error log file (error log). You cannot see any memory dump files currently because memory dumps are created in case of any exception or the system crash or the conditions specified above.
在上面的屏幕截图中,您可以看到有多个文件,例如跟踪文件(* .trc),*。xel(扩展事件会话文件),SQL代理日志文件(SQLagent.out),错误日志文件(错误日志) 。 当前看不到任何内存转储文件,因为在发生任何异常,系统崩溃或上述情况时会创建内存转储。
Now let us move back from the /var/opt/mssql/log folder using the exit command. This brings you back to $ prompt.
现在,让我们使用exit命令从/ var / opt / mssql / log文件夹移回。 这使您回到$提示符。
![转储sql文件_在Linux上SQL Server中更改SQL转储文件位置 转储sql文件_在Linux上SQL Server中更改SQL转储文件位置](/wp-content/uploads/2018/12/word-image-566.png)
Let us create a directory in which we want to capture the memory dumps. You can create the directory using the mkdir command.
让我们创建一个要在其中捕获内存转储的目录。 您可以使用mkdir命令创建目录。
$ sudo mkdir /SQLDumps
$ sudo mkdir / SQLDumps
![转储sql文件_在Linux上SQL Server中更改SQL转储文件位置 转储sql文件_在Linux上SQL Server中更改SQL转储文件位置](/wp-content/uploads/2018/12/word-image-567.png)
Currently, this directory will be empty. You can verify this as shown below.
当前,该目录为空。 您可以如下所示进行验证。
![转储sql文件_在Linux上SQL Server中更改SQL转储文件位置 转储sql文件_在Linux上SQL Server中更改SQL转储文件位置](/wp-content/uploads/2018/12/word-image-568.png)
We also need to check the permissions for this directory. If we list out the directory and their permissions, we can see that ‘SQLDumps’ is having permissions for the root user.
我们还需要检查该目录的权限。 如果我们列出目录及其权限,则可以看到“ SQLDumps”具有root用户的权限。
![转储sql文件_在Linux上SQL Server中更改SQL转储文件位置 转储sql文件_在Linux上SQL Server中更改SQL转储文件位置](/wp-content/uploads/2018/12/word-image-569.png)
In the next step, we need to change the owner and group of SQLDumps directory from root to mssql. This will enable SQL Server to access this particular directory.
下一步,我们需要将SQLDumps目录的所有者和组从根目录更改为mssql。 这将使SQL Server可以访问此特定目录。
Run the below commands
运行以下命令
$ sudo chown mssql SQLDumps
$ sudo chown mssql SQLDumps
$ sudo chgrp mssql SQLDumps
$ sudo chgrp mssql SQLDumps
![转储sql文件_在Linux上SQL Server中更改SQL转储文件位置 转储sql文件_在Linux上SQL Server中更改SQL转储文件位置](/wp-content/uploads/2018/12/word-image-570.png)
Let me explain, briefly, about the chown and chgrp command here.
让我在这里简要介绍一下chown和chgrp命令。
Chown command: It modifies the user ownership of for the specified file or directory. Below is the syntax for the chown command.
Chown命令:修改指定文件或目录的用户所有权。 以下是chown命令的语法。
chown owner directory
chown所有者目录
Chgrp command: It changes the group ownership of a file or files. Below is the syntax for the chgrp command.
Chgrp命令:它更改一个或多个文件的组 所有权 。 以下是chgrp命令的语法。
Chgrp user directory
Chgrp用户目录
Once we have executed the chown and chgrp commands, let us verify the ownership of the SQLDumps folder again.
一旦执行了chown和chgrp命令,让我们再次验证SQLDumps文件夹的所有权。
![转储sql文件_在Linux上SQL Server中更改SQL转储文件位置 转储sql文件_在Linux上SQL Server中更改SQL转储文件位置](/wp-content/uploads/2018/12/word-image-571.png)
In the above screenshot, we can see that the owner and group are changed to mssql.
在上面的屏幕截图中,我们可以看到所有者和组已更改为mssql。
Now we will change the default dump folder in the Linux using the mssql-conf utility. We can do the configuration of SQL Server running on Ubuntu, Linux, and SUSE Linux using this utility. The utility is installed in the /opt/mssql/bin directory. We can do below important configurations using this utility.
现在,我们将使用mssql-conf实用程序更改Linux中的默认转储文件夹。 我们可以使用此实用程序来配置在Ubuntu,Linux和SUSE Linux上运行SQL Server。 该实用程序安装在/ opt / mssql / bin目录中。 我们可以使用此实用工具在重要配置下面进行操作。
- Enable SQL Server Agent 启用SQL Server代理
- Change SQL Server collation 更改SQL Server排序规则
- Set default mail profile 设置默认邮件配置文件
- Set default data or log file directory 设置默认数据或日志文件目录
- Set default dump directory 设置默认转储目录
- Set default error log directory 设置默认错误日志目录
- Set default backup directory 设置默认备份目录
- Change default SQL Server Linux port 更改默认SQL Server Linux端口
- Set Local audit directory 设置本地审核目录
- Set memory configuration in SQL Server on Linux 在Linux上SQL Server中设置内存配置
- Enable HA 启用高可用性
- Configure TLS 配置TLS
- Set trace flags 设置跟踪标志
To get the complete list of the configurations, go to the directory /opt/mssql/bin and run the command with list parameter as shown here.
要获取配置的完整列表,请转到目录/ opt / mssql / bin并运行带有list参数的命令,如下所示。
$ cd /opt/mssql/bin
$ cd / opt / mssql / bin
$sudo ./mssql-conf list
$ sudo ./mssql-conf列表
Below is the complete list of the configurations.
以下是配置的完整列表。
Run the below command in terminal to change the default dump directory to SQLDumps directory.
在终端中运行以下命令,将默认转储目录更改为SQLDumps目录。
$ sudo /opt/mssql/bin/mssql-conf set filelocation.defaultdumpdir /SQLDumps
$ sudo / opt / mssql / bin / mssql-conf设置文件位置。defaultdumpdir / SQLDumps
![转储sql文件_在Linux上SQL Server中更改SQL转储文件位置 转储sql文件_在Linux上SQL Server中更改SQL转储文件位置](/wp-content/uploads/2018/12/word-image-574.png)
We need to restart the SQL Server to make this change effective. Run the below command to restart the SQL Server.
我们需要重新启动SQL Server才能使此更改生效。 运行以下命令以重新启动SQL Server。
Command:
命令:
Sudo systemctl restart mssql-server
Sudo systemctl重新启动mssql-server
![转储sql文件_在Linux上SQL Server中更改SQL转储文件位置 转储sql文件_在Linux上SQL Server中更改SQL转储文件位置](/wp-content/uploads/2018/12/word-image-575.png)
Verify the status of SQL Server service again and make sure it is in running status.
再次验证SQL Server服务的状态,并确保它处于运行状态。
![转储sql文件_在Linux上SQL Server中更改SQL转储文件位置 转储sql文件_在Linux上SQL Server中更改SQL转储文件位置](/wp-content/uploads/2018/12/word-image-576.png)
翻译自: https://www.sqlshack.com/changing-sql-dump-file-locations-in-sql-server-on-linux/
转储sql文件