Title : Can SQL server run on Kuberentes?
https://passdatacommunitysummit.com/sessions/268901

Posted by Simon Cho on 11/04/2021
Posted in Common | Leave a Comment »
Posted by Simon Cho on 07/31/2021
/***********************************************************************************************
**Object Name: AG_Monitor
**
**Description: Check AG Status
**
**Input Parameters:
**
**Return Value: N/A
**
**Return Result Set: AG Monitoring result
**
**Creator: Simon Cho
**
*************************************************************************************************/
--<ReplicaLevel>
SELECT replica_server_name
, d.role_desc
, d.connected_state_desc
, d.replica_id
, d.role_desc
--, endpoint_url
--, availability_mode_desc
--, failover_mode_desc
--, session_timeout
--, backup_priority
--, secondary_role_allow_connections_desc AS Secondary_Readable
, Pri_Check.pri_Status
--, Pri_Check.Sec_Status
--, Pri_Check.Sync_Status
, d.operational_state_desc
, d.recovery_health_desc
, d.synchronization_health_desc AS Sync_Status
, d.last_connect_error_description AS ErrorMsg
, DATEADD(hh, DATEDIFF(hh, GETUTCDATE(), GETDATE()), d.last_connect_error_timestamp) AS ErrorDateTime
FROM sys.availability_replicas r
OUTER APPLY (
SELECT 1 AS IsPrimary
, c.ip_address AS listnerIP
, c.state_desc AS listnerStatus
, a.primary_recovery_health_desc AS pri_Status
, a.secondary_recovery_health_desc AS Sec_Status
, a.synchronization_health_desc AS Sync_Status
FROM sys.dm_hadr_availability_group_states a
JOIN sys.availability_group_listeners B
ON A.group_id = B.group_id
JOIN sys.availability_group_listener_ip_addresses c
ON b.listener_id = c.listener_id
WHERE primary_replica = r.replica_server_name
) Pri_Check
JOIN sys.dm_hadr_availability_replica_states d
ON r.replica_id = d.replica_id
--WHERE d.role NOT IN (1,2) -- 1:Primary, 2:Secondary, 0:Resolving
-- OR d.operational_state <> 2 --0 = Pending failover, 1 = Pending, 2 = Online, 3 = Offline, 4 = Failed, 5 = Failed, no quorum
--OR d.recovery_health <> 1 --0:In progress. At least one joined database has a database state other than ONLINE ( database_state is not 0).1- Online. All the joined databases have a database state of ONLINE ( database_state is 0).
--OR d.synchronization_health <>2 -- 0 = Not healthy. At least one joined database is in the NOT SYNCHRONIZING state.
-- -- 1 = Partially healthy. Some replicas are not in the target synchronization state: synchronous-commit replicas should be synchronized, and asynchronous-commit replicas should be synchronizing.
-- -- 2= Healthy. All replicas are in the target synchronization state: synchronous-commit replicas are synchronized, and asynchronous-commit replicas are synchronizing.
-- OR d.connected_state <> 1 --0 Disconnected. The response of an availability replica to the DISCONNECTED state depends on its role, as follows:
-- -- On the primary replica, if a secondary replica is disconnected, its secondary databases are marked as NOT SYNCHRONIZED on the primary replica, which waits for the secondary to reconnect.
-- -- On a secondary replica, upon detecting that it is disconnected, the secondary replica attempts to reconnect to the primary replica.
-- -- 1 Connected
-- OR d.last_connect_error_number IS NOT NULL
--<DBLevel>
SELECT r.replica_server_name
, r.replica_id
, DB_NAME(DRS.database_id)
, DRS.is_primary_replica
, drs.synchronization_state
, drs.synchronization_state_desc
, drs.synchronization_health_desc
, drs.database_state_desc
, drs.suspend_reason_desc
--, drs.is_suspended
--, DRS.suspend_reason_desc
--, drs.suspend_reason
, drs.last_sent_time
, drs.last_received_time
, drs.log_send_queue_size
, drs.log_send_rate
, drs.redo_queue_size
, drs.redo_rate
--, drcs.is_failover_ready
--, drcs.is_pending_secondary_suspend
--, drcs.recovery_lsn
, DATEDIFF(ss, drs.last_sent_time, DRS.last_received_time) AS Last_Log_commit_Duration_sec
FROM sys.availability_replicas r
JOIN sys.dm_hadr_database_replica_states DRS
ON r.replica_id = DRS.replica_id
--WHERE r.replica_id ='E0CCAF57-F7B8-46D0-BDE4-0EDF1FECE310'
WHERE drs.synchronization_state NOT IN (2)
--WHERE 1=1
--and DB_NAME(DRS.database_id)='abce'
-- OR drs.synchronization_health <> 2
--OR DRS.is_suspended=1
--OR drs.suspend_reason IS NOT NULL
--OR DATEDIFF(ss, drs.last_sent_time, DRS.last_received_time)>30 -- longer than 30 sec.
/*
<synchronization_state>
0 Not synchronizing.
For a primary database, indicates that the database is not ready to synchronize its transaction log with the corresponding secondary databases.
For a secondary database, indicates that the database has not started log synchronization because of a connection issue, is being suspended
, or is going through transition states during startup or a role switch.
1 Synchronizing.
For a primary database, indicates that the database is ready to accept a scan request from a secondary database.
For a secondary database, indicates that active data movement is occurring for the database.
2 Synchronized.
A primary database shows SYNCHRONIZED in place of SYNCHRONIZING.
A synchronous-commit secondary database shows synchronized when the local cache says the database is failover ready and is synchronizing.
3 Reverting.
Indicates the phase in the undo process when a secondary database is actively getting pages from the primary database.Caution noteCaution
When a database on a secondary replica is in the REVERTING state, forcing failover to the secondary replica leaves the database in a state in which it cannot be started as a primary database.
Either the database will need to reconnect as a secondary database, or you will need to apply new log records from a log backup.
4 Initializing.
Indicates the phase of undo when the transaction log required for a secondary database to catch up to the undo LSN is being shipped and hardened on a secondary replica. Caution noteCaution
When a database on a secondary replica is in the INITIALIZING state, forcing failover to the secondary replica leaves the database in a state in which it be started as a primary database.
Either the database will need to reconnect as a secondary database, or you will need to apply new log records from a log backup.
<database_state>
0 Not healthy.
The synchronization_state of the database is 0 (NOT SYNCHRONIZING).
1 Partially healthy.
A database on a synchronous-commit availability replica is considered partially healthy if synchronization_state is 1 (SYNCHRONIZING).
2 Healthy.
A database on an synchronous-commit availability replica is considered healthy if synchronization_state is 2 (SYNCHRONIZED)
, and a database on an asynchronous-commit availability replica is considered healthy if synchronization_state is 1 (SYNCHRONIZING).
*/
Posted in Common | Leave a Comment »
Posted by Simon Cho on 11/08/2019
This is honor to speak at SQL PASS Summit 2019
Please come in the session at 11AM, 11/8 Fri. Room: 608
Here are the detail information.
https://www.pass.org/summit/2019/Learn/SessionDetails.aspx?sid=92365
Presentation download is here.
Git Repository : https://dev.azure.com/xcloudapp/_git/PASS2019
10 years ago, DBAs typically maintained a few critical databases. These days, it’s not strange anymore that a DBA maintains several hundred databases. Without automation CICD pipeline, a DBA would be the bottleneck for the faster deployment. Industry pretty much required who has the ability to automation of database deployment and operation. This session will delivery the automation of database operation including deployment and design and architecture of environment.Prerequisites: Who has Database deployment experience.
Simon Cho is one of the founders of SQLAngeles.com, which is a Los Angeles Korean Tech PASS community group. As a Local Group leader, he is a Microsoft SQL community speaker. He has presented many times at SQLSaturdays and to PASS Local Groups. In the past, he lead a database team and managed hundreds of SQL Servers and DWs on VM environment in the gaming industry in Nexon America. He moved his passion to VISA Inc, the largest credit card provider in the world, where he used database technology to build a strong solution and a secure environment, with new strategies and features to maintain thousands of SQL Servers. He has now joined the Nowcom Corp, as a Director of DevOps, where he leads the DevOps team and DBA team.
General Session (75 minutes):
Posted in Common | 1 Comment »
Posted by Simon Cho on 04/04/2019
Date : Apr 13 2019
Location :
Golden West College, 15744 Goldenwest St, Orange County, California, 92647, United States
Presentation file download here.
Posted in Common | Leave a Comment »
Posted by Simon Cho on 04/04/2019
https://sqlla.pass.org/?EventID=13089
Presentation file download here
We will do another one at SQL Saturday.
Posted in Common | Leave a Comment »
Posted by Simon Cho on 04/16/2018
Thank you for joining the SQL Saturday #740 – Orange County meeting.
Here is the Presentation file for “[StepbyStep] SQL server Index operation for beginner to expert”.
Posted in Common | Tagged: SQL Saturday #740, SQLSat740 | Leave a Comment »
Posted by Simon Cho on 03/08/2018
Initial unique clustered index on a view is exclusive from Online Index operation.
However, unique clustered index is very required for indexed view.
Posted in Common | Tagged: Indexed View, Online Index | Leave a Comment »
Posted by Simon Cho on 02/11/2018
I uploaded the presentation file on SQL Sat website.
Please check the below link.
Posted in Common | Leave a Comment »
Posted by Simon Cho on 01/19/2018
A couple of cases for this error message.
https://sqlperformance.com/2013/11/system-configuration/ag-connectivity
https://blogs.msdn.microsoft.com/docast/2017/07/27/sql-connectivity-troubleshooting-checklist/
https://technet.microsoft.com/en-us/library/ms187005(v=sql.105).aspx
http://sirsql.net/content/2016/11/09/availability-groups-issue-with-2016-cu2/
Posted in Common | Tagged: An existing connection was forcibly closed | Leave a Comment »
Posted by Simon Cho on 01/18/2018
Finally, MS release new service pack update for SQL 2012 and SQL 2014.
Please follow the below link for guidance for SQL server.
All official links keep updating in the same article.
SQL Server – https://support.microsoft.com/en-us/help/4073225/guidance-for-sql-server
Windows Server – https://support.microsoft.com/en-us/help/4072698/windows-server-guidance-to-protect-against-the-speculative-execution
Here is the recent update for SQL 2012 and SQL 2014.
4057117 Description of the security update for SQL Server 2014 SP2 CU: January 16, 2018
4057120 Description of the security update for SQL Server 2014 SP2 GDR: January 16, 2018
4057116 Description of the security update for SQL Server 2012 SP4 GDR: January 12, 2018
Here are all supported versions’ link.
SQL Server 2017 GDR
SQL Server 2016 SP1 CU7*
SQL Server 2016 SP1 GDR
SQL Server 2016 RTM CU
SQL Server 2016 RTM GDR
SQL Server 2008 SP4
SQL Server 2008 R2 SP3
SQL Server 2012 SP4 GDR
SQL Server 2012 SP3 CU
SQL Server 2012 SP3 GDR
SQL Server 2014 SP2 CU*
SQL Server 2014 SP2 GDR
Posted in Common | Tagged: Intel CPU, Meltdown, Spectre, SQL 2012, SQL 2014 | Leave a Comment »
Posted by Simon Cho on 01/10/2018
<Google Prject Zero>
It started from “Google Project Zero”.
https://googleprojectzero.blogspot.com/
Variants of this issue are known to affect many modern processors, including certain processors by Intel, AMD and ARM. For a few Intel and AMD CPU models, we have exploits that work against real software. We reported this issue to Intel, AMD and ARM on 2017-06-01.
Here is the guide line for SQL Server and Windows Server.
SQL Server – https://support.microsoft.com/en-us/help/4073225/guidance-for-sql-server
Windows Server – https://support.microsoft.com/en-us/help/4072698/windows-server-guidance-to-protect-against-the-speculative-execution
SQL Server Patch available for below version.
SQL 2012 and SQL 2014 should release soon.
SQL Server 2017 CU3*
SQL Server 2017 GDR
SQL Server 2016 SP1 CU7*
SQL Server 2016 SP1 GDR
SQL Server 2016 RTM CU
SQL Server 2016 RTM GDR
SQL Server 2008 SP4 (This is new version of SP4. Version number is slightly different.)
SQL Server 2008 R2 SP3(This is new version of SP3. Version number is slightly different.)
It seems like not that many articles reported SQL 2008 SP4 and SQL Server 2008 R2 SP3 with this patch.
<Here is the related blogs and articles>
https://www.brentozar.com/archive/2018/01/sql-server-patches-meltdown-spectre-attacks/
Perfermance
ploited Vulnerability | CVE | Exploit Name |
Public Vulnerability Name | Windows Changes | Silicon Microcode Update ALSO Required on Host |
Spectre | 2017-5753 | Variant 1 | Bounds Check Bypass | Compiler change; recompiled binaries now part of Windows Updates
Edge & IE11 hardened to prevent exploit from JavaScript |
No |
Spectre | 2017-5715 | Variant 2 | Branch Target Injection | Calling new CPU instructions to eliminate branch speculation in risky situations | Yes |
Meltdown | 2017-5754 | Variant 3 | Rogue Data Cache Load | Isolate kernel and user mode page tables | No |
In general, our experience is that Variant 1 and Variant 3 mitigations have minimal performance impact, while Variant 2 remediation, including OS and microcode, has a performance impact.
Posted in Common | Tagged: Intel CPU, Meltdown, Spectre, SQL Server Meltdown | Leave a Comment »
Posted by Simon Cho on 01/10/2018
SQL Compression backup wasn’t work before SQL 2016.
<SQL Server 2014 and below>
https://msdn.microsoft.com/library/bb934049(SQL.120).aspx
Encrypted data compresses significantly less than equivalent unencrypted data. If TDE is used to encrypt a database, backup compression will not be able to significantly compress the backup storage. Therefore, using TDE and backup compression together is not recommended.
<After SQL server 2016 and above>
It could work with special command.!
It is important to know that while backing up a TDE-enable database, the compression will kick in ONLY if MAXTRANSFERSIZE is specified in the BACKUP command. Moreover, the value of MAXTRANSFERSIZE must be greater than 65536 (64 KB). The minimum value of the MAXTRANSFERSIZE parameter is 65536, and if you specify MAXTRANSFERSIZE = 65536 in the BACKUP command, then compression will not kick in. It must be “greater than” 65536. In fact, 65537 will do just good. It is recommended that you determine your optimum MAXTRANSFERSIZE through testing, based on your workload and storage subsystem. The default value of MAXTRANSFERSIZE for most devices is 1 MB, however, if you rely on the default, and skip specifying MAXTRANSFERSIZE explicitly in your BACKUP command, compression will be skipped.
Please Note :
Update April 6th, 2017
We have recently discovered some issues related to the use of TDE and backup compression in SQL Server 2016. While we fix them, here are some tips to help you avoid running into those known issues:
Posted in Common | Tagged: Backup, Compression, TDE | Leave a Comment »
Posted by Simon Cho on 11/30/2017
Update statistics is known as online operation.
Detail lock mode is in below blog.
https://www.mssqltips.com/sqlservertip/4608/does-updating-sql-server-statistics-cause-blocking/
However, update statistics could create seriouly blocking issue such as “SCH-M” in certain case.
Here is detail lock mode in certain case.
<Database name="TEST"> <Locks> <Lock request_mode="S" request_status="GRANT" request_count="1" /> </Locks> <Objects> <Object name="Tbl_cdc1" schema_name="dbo"> <Locks> <Lock resource_type="METADATA.INDEXSTATS" index_name="PK_Tbl_cdc1" request_mode="Sch-S" request_status="GRANT" request_count="2" /> <Lock resource_type="METADATA.STATS" request_mode="Sch-M" request_status="CONVERT" request_count="1" /> <Lock resource_type="METADATA.STATS" request_mode="Sch-S" request_status="GRANT" request_count="1" /> <Lock resource_type="OBJECT" request_mode="Sch-S" request_status="GRANT" request_count="2" /> <Lock resource_type="OBJECT.UPDSTATS" request_mode="X" request_status="GRANT" request_count="1" /> </Locks> </Object> </Objects> </Database>
Please check that “request_mode=“Sch-M” request_status=”CONVERT“”.
I’m currently investigating detail.
I’ll share later in Part2.
Simon
Posted in Common | Tagged: blocking, Update Statistics | Leave a Comment »
Posted by Simon Cho on 10/23/2017
Get-WmiObject -namespace "root\mscluster" -class MSCluster_Resource Get-WmiObject : Invalid namespace mofcomp C:\Windows\System32\wbem\ClusWMI.mof
PS C:\Windows\system32> mofcomp C:\Windows\System32\wbem\ClusWMI.mof
Microsoft (R) MOF Compiler Version 6.2.9200.16398
Copyright (c) Microsoft Corp. 1997-2006. All rights reserved.
Parsing MOF file: C:\Windows\System32\wbem\ClusWMI.mof
MOF file has been successfully parsed
Storing data in the repository…
Done!
Here is for SQL Server WMI issue.
Expected error message when WMI doesn’t registered properly.
The following exception occurred while trying to enumerate the collection: "An exception occurred in SMO while trying to manage a service.". At line:xx char:xxx + $wmi.xxxx + ~~~~~~~~~~~~~~~~~~~~ + CategoryInfo : NotSpecified: (:) [], ExtendedTypeSystemException + FullyQualifiedErrorId : ExceptionInGetEnumerator
Another error message when open SQL configuration manage.
<Solution>
Please check path and Version number in below script.
//SQL 2008 mofcomp "%programfiles(x86)%\Microsoft SQL Server\100\Shared\sqlmgmproviderxpsp2up.mof" //SQL 2012 mofcomp "%programfiles(x86)%\Microsoft SQL Server\110\Shared\sqlmgmproviderxpsp2up.mof" //SQL 2014 mofcomp "%programfiles(x86)%\Microsoft SQL Server\120\Shared\sqlmgmproviderxpsp2up.mof" //SQL 2016 mofcomp "%programfiles(x86)%\Microsoft SQL Server\130\Shared\sqlmgmproviderxpsp2up.mof" //SQL 2017 mofcomp "%programfiles(x86)%\Microsoft SQL Server\140\Shared\sqlmgmproviderxpsp2up.mof"
Posted in Common | Tagged: FCI, SQL server, WMI | Leave a Comment »
Posted by Simon Cho on 10/23/2017
Posted in Common | Leave a Comment »
Posted by Simon Cho on 06/21/2017
Please download Presentation and Demo script.
Auto DB deployment basic
(Free DBA work from DB deployment, just put the click button to DevOps.)
SQL server Deployment /배포/패치/점검 자동화 기초
부제 – DBA 잠좀 자게 해주세요. F5 클릭은 컴터가 알아서
아직도 DB 서버 배포를 손으로 하나요?
SQL package 를 이용해서 수십대의 DB에 자동으로 빠르게 배포하는방법에 대해서 살펴보겠습니다.
날짜
06/21/2017 03:00~05:00 (UTC)
06/21/2017 00:00~02:00 (EDT)
06/21/2017 22:00~24:00 (CDT)
06/20/2017 20:00 ~ 22:00 (PDT)
06/21/2017 12:00 ~ 14:00 (KOR)
장소 : 222 N Sepuveda Blvd, El Segundo, CA, 90245
온라인 링크 : https://meet.lync.com/sqlpass365-sqlpass/sqlangeles/MMGM08Y1 (이어폰 준비)
페에스북 라이브 방송 : https://www.facebook.com/sqlmvp (스터디 시간에 맞춰서 방송합니다.)
카카오톡 오픈 채팅 : SQL Angeles 로 검색해서 채팅 참여 가능 합니다.
주의 사항 : 스피커로 청취시 반드시 마이크는 음소거로 설정.
Simon Cho
Database Engineer\DevOps Engineer
VISA DBA
SQL Saturday Speaker
SQL Angeles Co-founder
Email : simon@simonsql.com
Blog : https://simonsql.com/
LinkedIn : https://www.linkedin.com/in/simonsql/
[주차 안내]
길건너 해빗 버거 주차 후 도보로 이동 (약 3분 거리)
[Sponsored]
Posted in Common | Tagged: SQLAngeles.com, sqlangeles.pass.org | Leave a Comment »
Posted by Simon Cho on 05/31/2017
We are quickly approaching 6/10.
http://www.sqlsaturday.com/640/eventhome.aspx
Top 5 reasons why you have to attend SQL Saturday in LA event
Excellent panel of 40+ Speakers:
2 x Past PASS Presidents + 1 PASS Regional Mentor
2 x Microsoft Certified Masters (MCM)
5 x Microsoft Certified Trainers (MCT)
6 x PASS Speakers
7 x Microsoft Most Valuable Professionals (MVP)
9 x Microsoft Certified Solutions Experts (MCSE)
6 x Microsoft Certified Solutions Associate (MCSA)
Free education – Please see schedule for more details
Free food – we will have coffee, orange juice and pastries for breakfast; pizza, beverages and fresh fruit for lunch
Two beautiful venues with enough room for 300 attendees
A chance to win great prizes
P.S. One more reason to attend a SQL Saturday in LA – attend and get a FREE e-book by O’Reilly Media!
Posted in Common | Tagged: #SQLSatLA | Leave a Comment »
Posted by Simon Cho on 04/15/2017
Today is the first day I visit the Microsoft Headquarters in Redmond.
Thank you for coming in SQL Saturday in Redmond.
Here are my presentation file and the demo script.
Posted in Common | Tagged: SQL Saturday #613 | Leave a Comment »
Posted by Simon Cho on 04/03/2017
Finally, I’ve completed my presentations at SQL Saturday – Orange County!
There were only 3 audiences when I did the 2nd presentation at Orange county 3 years ago.
Today, I got full audiences.
I really appreciated who came to my session and SQL Saturday.
It really encourages me and I get lots of comments from people.
Here is the presentation file and Demo file.
Thank you for attending.
http://www.sqlsaturday.com/611/Sessions/Schedule.aspx
Posted in Common | Tagged: SQL Saturday, SQL Saturday #611 | Leave a Comment »