SQL AO AG failover in cluster group and check the synchronization status

Get info from Cluster:

Failover general example, you can use Invoke-DbaAgFailover for SQL server:

DBATools makes your life happy, you can find the SQL server instances and you can failover them.

To find  all of the SQL instances in a cluster server . To Check AG before and after the failover, and failover the SQL Server AO AG :


 

if you have to wait a lot for synchronization you can check how many servers are synchronized.


 

 

What is my default backup BUFFERCOUNT and MAXTRANSFERSIZE Data Transfer Options?

Error message: BackupIoRequest::ReportIoError: write failure on backup device \\filer\sharename\.. bak Operating system error 8(Not enough memory resources are available to process this command.).

It may you want a better performance for backup (less cpu and shorter backup time, so you can tune the BUFFERCOUNT  and MAXTRANSFERSIZE

https://docs.microsoft.com/en-us/sql/t-sql/statements/backup-transact-sql?view=sql-server-ver15
–Data Transfer Options BUFFERCOUNT = { buffercount | @buffercount_variable } | MAXTRANSFERSIZE = { maxtransfersize | @maxtransfersize_variable }

Books Online gives the following definition for these two options:

BUFFERCOUNT = { buffercount | @ buffercount_variable }

Specifies the total number of I/O buffers to be used for the backup operation. You can specify any positive integer; however, large numbers of buffers might cause “out of memory” errors because of inadequate virtual address space in the Sqlservr.exe process.

Based on the values that you provide or do not provide, SQL Server specifies the size contiguous buffers that it will use to perform the backup. This is of utmost importance in 32-bit environments as large amount of contiguous memory allocation can prove to be fatal to the non-Buffer Pool region of the SQL Virtual Address Space. This can cause your backups to fail. When SQLVDI is being used, this is of utmost importance because we cannot change the MAXTRANSFERSIZE after the VDI Configuration has been completed. The amount of contiguous virtual memory is determined by the number of backup devices and by the number of volumes on which the database files reside on.

You can use Trace Flag 3213 to review your backup/restore configuration parameters while performing a backup/restore operation. I shall proceed to show you how specifying the incorrect BUFFERCOUNT values or not providing it can prove to be fatal.

So how to get the buffercount?

Sample result:

out of memory backup BUFFERCOUNT and MAXTRANSFERSIZE
out of memory backup BUFFERCOUNT and MAXTRANSFERSIZE

Monitor the active session scheduled by SQL agent service

It is very common  that you should investigate what is going on the server at a certain time and you can not find any scheduled job. Yes, the application run a big job. If you want to see current processes, you can run:

If you want to log it, you can schedule for every 1-10 minutes (you have to set the @destination_table and @destination_database, and the table will be created at the first running time):

 

 

 

DISTRIBUTED TRANSACTION: DTC in SQL server

There is two SQL servers and DTC is enabled both of them.

One SQL server is local and another one is a linked server named test.

Run a Distributed Transaction in SQL server for test purpose:

after running the T-SQL transaction you can check in the DTC report.

 

you can check the DTC connection and firewall settings:

DTC ping tool

In powershell:

If the remote server is another domain,  you will get an error:
New-CimSession : WinRM cannot process the request. The following error with errorcode 0x80090322 occurred while using Kerberos authentication: An unknown security error occurred.

In this case you can set: No Authentication Required.

 

DTC and Java

How to enable DTC in SQL server for Java:

– copy sqljdbc_xa.dll to sql server binn folder from the EXTRACTED (but not installed) jdbc driver
– enable xa transactions in component services > computerts > Distributed Transaction Coordinator > Local DTC (properties, security tab) Enable XA transactions
– restart sql server (all components to be sure)
– run script on master db. (xa_install.sql it is also in the jdbc driver, next to the .sql)
– the user that will perform distributed transactions must have the role “SqlJDBCXAUser” set on the MASTER db!

SQL server or agent or any other login can access a fileshare?

Yes, but you need to check:

 

 

Increased the default XEvent trace: system_health size and retention policy are in SQL Server

If you want to investigate a case the default trace setting can be readable for few day and after that they are overwritten.

The default setting is 10 x 100 MB files.

You can check the oldest log:

Hey , it is only 3 days! you have to backup the files. A better solution to survive a long weekend to increase the retention, for example using 30 files:

 

 

Collect Index defragmentation

I do it for registered servers:

 

Install SSMS without Azure Data Studio

Starting with SSMS 18.7, SSMS installs a system version of Azure Data Studio by default. If an equal or greater system version of Azure Data Studio stable or insiders is already present on the workstation compared to the included version of Azure Data Studio, the installation of Azure Data Studio by SSMS is skipped. The Azure Data Studio version can be found in the release notes.

If you do not want to install ADS (Azure Data Studio) use the SSMS installer with the command line flag DoNotInstallAzureDataStudio=1.

 

 

 

 

SSISDB update failed during the SQL CU or SP udpate

Reason: the cu found a SSIDB and wanted to upgrade it.
It failed because SSIS component is not installed to the server.

It needs: Cannot bulk load. The file “C:\Program Files\Microsoft SQL Server\150\DTS\Binn\Microsoft.SqlServer.IntegrationServices.Server.dll” does not exist or you don’t have file access rights.
Yes it is missing , because SSIS component installed.

Without the ssisdb the sql server was not able to start.

It recommended to reinstall the master. Do NOT reinstall the master.

My solution was:

  1. Install (add ) the Integration Service component.
  2. Start the server with 902 flag (admin command prompt)

create a missing SQL login and connect to hte SSISD

 

Reason:

If you don’t create SSISDB locally (you attach by migration), the SQL login will missing.

 

Help:

After installing Integration service it gave enough hint:

2021-07-10 14:12:47.73 spid10s     Cannot find the login ‘##MS_SSISServerCleanupJobLogin##’, because it does not exist or you do not have permission.

2021-07-10 14:12:47.73 spid10s     Error: 912, Severity: 21, State: 2.

2021-07-10 14:12:47.73 spid10s     Script level upgrade for database ‘master’ failed because upgrade step ‘ISServer_upgrade.sql’ encountered error 15151, state 1, severity 16. This is a serious error condition which might interfere with regular operation and the database will be taken offline. If the error happened during upgrade of the ‘master’ database, it will prevent the entire SQL Server instance from starting. Examine the previous errorlog entries for errors, take the appropriate corrective actions and re-start the database so that the script upgrade steps run to completion.

SUM: Please check if there is a SSIDB in the SQL server before install SP or CU.