Skip to content

Commit fa7704f

Browse files
author
Ajay Dwivedi
committed
Added few more scripts
Added few more scripts
1 parent f43d6eb commit fa7704f

19 files changed

+323
-12
lines changed
5 KB
Binary file not shown.

Backup-Restore/Backup-Restore.ssmssqlproj

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
2828
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
2929
</ConnectionNode>
30+
<ConnectionNode Name="sqla:sa">
31+
<Created>2020-04-19T14:05:17.5205144+05:30</Created>
32+
<Type>SQL</Type>
33+
<Server>sqla</Server>
34+
<UserName>sa</UserName>
35+
<Authentication>SQL</Authentication>
36+
<InitialDB>master</InitialDB>
37+
<LoginTimeout>30</LoginTimeout>
38+
<ExecutionTimeout>0</ExecutionTimeout>
39+
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
40+
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
41+
</ConnectionNode>
3042
</Items>
3143
</LogicalFolder>
3244
<LogicalFolder Name="Queries" Type="0" Sorted="true">
@@ -122,9 +134,9 @@
122134
<FullPath>Query - Restore History.sql</FullPath>
123135
</FileNode>
124136
<FileNode Name="RevLogin-Script.sql">
125-
<AssociatedConnectionMoniker />
126-
<AssociatedConnSrvName />
127-
<AssociatedConnUserName />
137+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:sqla:False:sa</AssociatedConnectionMoniker>
138+
<AssociatedConnSrvName>sqla</AssociatedConnSrvName>
139+
<AssociatedConnUserName>sa</AssociatedConnUserName>
128140
<FullPath>RevLogin-Script.sql</FullPath>
129141
</FileNode>
130142
<FileNode Name="ScriptOut - RESTORE With REPLACE - Multiple Dbs.sql">

Mail-Replies/Bob-01.sql

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Seems like we should consider putting the old message archive service back and get a yardstick for performance? Do we have reason to believe it should be doing 100 msgs/sec?
2+
3+
Also, I think it’s probably better if we give DBAs suggestions on something to look at? What servers are we taking about? CMP DB servers? The publisher? Do we have specific metrics from other environments we can compare to? Certain queries we should be monitoring? Any reporting available in the app? If the SQL Server doesn’t show any obvious problems like maxed cpu or long disk queue lengths, can we give them some direction? I’m still an old school believer that most of the time performance issues originate within the application behavior. Sometimes we can compensate for that with DB tuning or throwing hardware at it, sometimes not.

Mail-Replies/Mail-Replies.ssmssqlproj

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
<?xml version="1.0"?>
2+
<SqlWorkbenchSqlProject xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" Name="Mail-Replies">
3+
<Items>
4+
<LogicalFolder Name="Connections" Type="2" Sorted="true">
5+
<Items>
6+
<ConnectionNode Name="(local):CORPORATE\adwivedi">
7+
<Created>2020-04-17T22:02:44.8081495+05:30</Created>
8+
<Type>SQL</Type>
9+
<Server>(local)</Server>
10+
<UserName />
11+
<Authentication>Windows Authentication</Authentication>
12+
<InitialDB>master</InitialDB>
13+
<LoginTimeout>30</LoginTimeout>
14+
<ExecutionTimeout>0</ExecutionTimeout>
15+
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
16+
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
17+
</ConnectionNode>
18+
</Items>
19+
</LogicalFolder>
20+
<LogicalFolder Name="Queries" Type="0" Sorted="true">
21+
<Items>
22+
<FileNode Name="Bob-01.sql">
23+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
24+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
25+
<AssociatedConnUserName />
26+
<FullPath>Bob-01.sql</FullPath>
27+
</FileNode>
28+
</Items>
29+
</LogicalFolder>
30+
<LogicalFolder Name="Miscellaneous" Type="3" Sorted="true">
31+
<Items />
32+
</LogicalFolder>
33+
</Items>
34+
</SqlWorkbenchSqlProject>

Misscellaneous Queries/Misscellaneous Queries.ssmssqlproj

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
2828
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
2929
</ConnectionNode>
30+
<ConnectionNode Name="sqla:sa">
31+
<Created>2020-04-20T18:41:08.1726728+05:30</Created>
32+
<Type>SQL</Type>
33+
<Server>sqla</Server>
34+
<UserName>sa</UserName>
35+
<Authentication>SQL</Authentication>
36+
<InitialDB />
37+
<LoginTimeout>30</LoginTimeout>
38+
<ExecutionTimeout>0</ExecutionTimeout>
39+
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
40+
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
41+
</ConnectionNode>
3042
</Items>
3143
</LogicalFolder>
3244
<LogicalFolder Name="Queries" Type="0" Sorted="true">
@@ -200,9 +212,9 @@
200212
<FullPath>SQL Server Error Logs.sql</FullPath>
201213
</FileNode>
202214
<FileNode Name="SqlCluster-Troubleshooting.sql">
203-
<AssociatedConnectionMoniker />
204-
<AssociatedConnSrvName />
205-
<AssociatedConnUserName />
215+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:sqla:False:sa</AssociatedConnectionMoniker>
216+
<AssociatedConnSrvName>sqla</AssociatedConnSrvName>
217+
<AssociatedConnUserName>sa</AssociatedConnUserName>
206218
<FullPath>SqlCluster-Troubleshooting.sql</FullPath>
207219
</FileNode>
208220
<FileNode Name="Sql-Installation-Hosts.sql">
Lines changed: 32 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,34 @@
11
Get-ClusterLog -Cluster sqlclusteradmin -TimeSpan 30 -UseLocalTime -Destination 'c:\temp\clusterLogs'
22

3-
select * from sys.dm_os_cluster_nodes
3+
select * from sys.dm_os_cluster_nodes
4+
5+
/* Force Start Cluster without Quorum */
6+
7+
/* Re-configure Quorum configuration, and remove vote for cluster nodes that are down */
8+
9+
/* Perform Manual Forced Failover
10+
Should be executed on Node that will become Primary */
11+
ALTER AVAILABILITY GROUP [SqlAg] FORCE_FAILOVER_ALLOW_DATA_LOSS;
12+
GO
13+
14+
/* Query to Resume databases on Secondary Replicas after Forced Manual Failover */
15+
declare @dbName varchar(500);
16+
declare @tsqlQuery nvarchar(max);
17+
declare cur_dbs cursor for
18+
select database_name from sys.availability_databases_cluster
19+
20+
open cur_dbs
21+
fetch cur_dbs into @dbName
22+
23+
while @@FETCH_STATUS = 0
24+
begin
25+
print @dbName
26+
27+
set @tsqlQuery = 'alter database '+QUOTENAME(@dbName)+' set hadr resume;'
28+
exec(@tsqlQuery);
29+
30+
fetch cur_dbs into @dbName
31+
end
32+
close cur_dbs
33+
deallocate cur_dbs
34+
go

OlaHallengren.com/OlaHallengren.com.ssmssqlproj

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,18 @@
2727
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
2828
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
2929
</ConnectionNode>
30+
<ConnectionNode Name="sqla:sa">
31+
<Created>2020-04-19T13:34:14.5452416+05:30</Created>
32+
<Type>SQL</Type>
33+
<Server>sqla</Server>
34+
<UserName>sa</UserName>
35+
<Authentication>SQL</Authentication>
36+
<InitialDB>master</InitialDB>
37+
<LoginTimeout>30</LoginTimeout>
38+
<ExecutionTimeout>0</ExecutionTimeout>
39+
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
40+
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
41+
</ConnectionNode>
3042
<ConnectionNode Name="TUL1CIPCNPDB1:CORPORATE\adwivedi">
3143
<Created>2019-10-31T21:51:37.4157116+05:30</Created>
3244
<Type>SQL</Type>
@@ -86,9 +98,9 @@
8698
<FullPath>[IndexOptimize_Modified].sql</FullPath>
8799
</FileNode>
88100
<FileNode Name="DatabaseBackup.sql">
89-
<AssociatedConnectionMoniker />
90-
<AssociatedConnSrvName />
91-
<AssociatedConnUserName />
101+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:sqla:False:sa</AssociatedConnectionMoniker>
102+
<AssociatedConnSrvName>sqla</AssociatedConnSrvName>
103+
<AssociatedConnUserName>sa</AssociatedConnUserName>
92104
<FullPath>DatabaseBackup.sql</FullPath>
93105
</FileNode>
94106
<FileNode Name="Get-Log-File-Size-Used.sql">

SQL-Lab/FireWall-Rules.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
New-NetFirewallRule -DisplayName "Sql Server HADR (TCP/5022)" -Direction Inbound -LocalPort 5022 -Protocol TCP -Action Allow -Profile Any
2+
New-NetFirewallRule -DisplayName "Sql Server HADR (TCP/5022)" -Direction Outbound -LocalPort 5022 -Protocol TCP -Action Allow -Profile Any
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- https://computingforgeeks.com/join-centos-rhel-system-to-active-directory-domain/
2+
3+
-- Step 1: Install required packages
4+
dnf install realmd sssd oddjob oddjob-mkhomedir adcli samba-common samba-common-tools krb5-workstation
5+
6+
-- Step 2: Discover Active Directory domain on CentOS 8 / RHEL 8
7+
-- 2.1 - Verify DNS settings
8+
cat /etc/resolv.conf
9+
-- 2.2 - Check if AD domain discovery is successful
10+
realm discover contso.com
11+
-- 2.3 - If 2.2 does not resolve, then add dc.contso.com & contso.com in /etc/hosts
12+
vim /etc/hosts
13+
14+
-- Step 3: Join CentOS 8 / RHEL 8 Linux machine in Active Directory domain
15+
-- 3.1 - Join to domain
16+
realm join contso.com -U Administrator
17+
-- 3.2 - Confirm that join was successful
18+
realm list
19+
20+
-- Step 4:
21+
realm permit -g 'SQLDBAs'
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
-- https://www.youtube.com/watch?v=4jh6VwEaRt8
2+
3+
# Installing realmd package
4+
5+
yum install sssd realmd oddjob oddjob-mkhomedir adcli samba-common samba-common-tools krb5-workstation openldap-clients policycoreutils-python
6+
7+
# Edit Host File to add DNS IP address and Server Information
8+
9+
vi /etc/hosts
10+
11+
# View File /etc/resolv.conf
12+
13+
It should resolve Domain name and IP address
14+
15+
# Join with Windows Domain
16+
realm join --user=clusteradmin tbsdc.Techbrothers.local
17+
18+
# Verify domain Join
19+
realm list
20+
# id clusteradmin@Techbrothers.local
21+
22+
# Turning off Fully Qualified Name requirement of AD user
23+
24+
vi /etc/sssd/sssd.conf
25+
26+
systemctl restart sssd
27+
systemctl daemon-reload
28+
29+
# adding user to sudo or admin - Where "wheel" is group and cluster admin is active directory user
30+
31+
sudo usermod -a -G wheel clusteradmin

0 commit comments

Comments
 (0)