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

SQL-Lab/SQL-Lab.ssmssqlproj

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,82 @@
1515
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
1616
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
1717
</ConnectionNode>
18+
<ConnectionNode Name="sqla:sa">
19+
<Created>2020-04-19T19:25:47.9586456+05:30</Created>
20+
<Type>SQL</Type>
21+
<Server>sqla</Server>
22+
<UserName>sa</UserName>
23+
<Authentication>SQL</Authentication>
24+
<InitialDB />
25+
<LoginTimeout>30</LoginTimeout>
26+
<ExecutionTimeout>0</ExecutionTimeout>
27+
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
28+
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
29+
</ConnectionNode>
1830
</Items>
1931
</LogicalFolder>
2032
<LogicalFolder Name="Queries" Type="0" Sorted="true">
2133
<Items>
34+
<FileNode Name="FireWall-Rules.sql">
35+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:sqla:False:sa</AssociatedConnectionMoniker>
36+
<AssociatedConnSrvName>sqla</AssociatedConnSrvName>
37+
<AssociatedConnUserName>sa</AssociatedConnUserName>
38+
<FullPath>FireWall-Rules.sql</FullPath>
39+
</FileNode>
2240
<FileNode Name="hosts-file-content.sql">
2341
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
2442
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
2543
<AssociatedConnUserName />
2644
<FullPath>hosts-file-content.sql</FullPath>
2745
</FileNode>
46+
<FileNode Name="hosts-file-dc.sql">
47+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
48+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
49+
<AssociatedConnUserName />
50+
<FullPath>hosts-file-dc.sql</FullPath>
51+
</FileNode>
52+
<FileNode Name="hosts-file-linux.sql">
53+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
54+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
55+
<AssociatedConnUserName />
56+
<FullPath>hosts-file-linux.sql</FullPath>
57+
</FileNode>
58+
<FileNode Name="hosts-file-vmhost.sql">
59+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
60+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
61+
<AssociatedConnUserName />
62+
<FullPath>hosts-file-vmhost.sql</FullPath>
63+
</FileNode>
64+
<FileNode Name="Join-CentOS-2-Windows-Domain.sql">
65+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
66+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
67+
<AssociatedConnUserName />
68+
<FullPath>Join-CentOS-2-Windows-Domain.sql</FullPath>
69+
</FileNode>
70+
<FileNode Name="Join-CentOS-2-Windows-Domain-02.sql">
71+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
72+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
73+
<AssociatedConnUserName />
74+
<FullPath>Join-CentOS-2-Windows-Domain-02.sql</FullPath>
75+
</FileNode>
2876
<FileNode Name="Powershell-hosts-content-2-IP-HOSTNAME-Splitting.sql">
2977
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
3078
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
3179
<AssociatedConnUserName />
3280
<FullPath>Powershell-hosts-content-2-IP-HOSTNAME-Splitting.sql</FullPath>
3381
</FileNode>
82+
<FileNode Name="Setup-Email-Server.sql">
83+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
84+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
85+
<AssociatedConnUserName />
86+
<FullPath>Setup-Email-Server.sql</FullPath>
87+
</FileNode>
88+
<FileNode Name="Setup-VPN-Windows-Server.sql">
89+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
90+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
91+
<AssociatedConnUserName />
92+
<FullPath>Setup-VPN-Windows-Server.sql</FullPath>
93+
</FileNode>
3494
</Items>
3595
</LogicalFolder>
3696
<LogicalFolder Name="Miscellaneous" Type="3" Sorted="true">

SQL-Lab/Setup-Email-Server.sql

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
-- https://helpdeskgeek.com/how-to/how-to-set-up-your-own-email-server/
2+
-- https://www.youtube.com/watch?v=vDQxsiln6pk
3+
4+
Add CNAME record with below names
5+
---------------------------------
6+
contso.com
7+
mail.contso.com
8+
smtp.mail.contso.com
9+
pop3.mail.contso.com
10+
11+
Add firewall Inbuid rules
12+
--------------------------
13+
%ProgramFiles% (x86)\hMailServer\Bin\hMailServer.exe
14+
15+
hMailServer (TCP/ 25,110,143,587)
16+
hMailServer (UDP/ 25,110,143,587)
17+
18+
Configure Mail Client
19+
-----
20+
Incoming - IMAP - mail.contso.com - 143
21+
Outgoing - SMTP - mail.contso.com - 587

SQL-Lab/Setup-VPN-Windows-Server.sql

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
https://www.accuwebhosting.com/blog/install-vpn-rras-remote-routing-access/
2+
https://www.snel.com/support/how-to-set-up-a-vpn-with-windows-server/

SQL-Lab/hosts-file-dc.sql

Whitespace-only changes.

SQL-Lab/hosts-file-linux.sql

Whitespace-only changes.

SQL-Lab/hosts-file-vmhost.sql

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
2+
192.168.178.100 host
3+
192.168.178.102 workstation
4+
192.168.178.103 servera
5+
192.168.178.104 serverb
6+
192.168.178.110 serverc
7+
192.168.178.106 ubuntu
8+
192.168.178.111 fedora
9+
192.168.178.112 mate
10+
11+
192.168.0.100 vmhost
12+
192.168.0.101 msi
13+
192.168.0.102 workstation
14+
192.168.0.103 servera
15+
192.168.0.104 serverb
16+
192.168.0.105 win10
17+
192.168.0.106 ubuntu
18+
192.168.0.107 workstation.msi
19+
192.168.0.108 servera.msi
20+
192.168.0.109 serverb.msi
21+
192.168.0.110 serverc
22+
192.168.0.111 fedora
23+
192.168.0.112 mate
24+
25+
192.168.0.116 dc
26+
192.168.0.117 sqla
27+
192.168.0.118 sqlb
28+
192.168.0.119 sqlc
29+
192.168.0.120 sqld
30+
192.168.0.121 sqle
31+
32+
192.168.178.116 dc
33+
192.168.178.117 sqla
34+
192.168.178.118 sqlb
35+
192.168.178.119 sqlc
36+
192.168.178.120 sqld
37+
192.168.178.121 sqle
38+
39+
192.168.178.125 sqlag-admin
40+
192.168.0.125 sqlag-admin
41+
192.168.178.126 sqlag
42+
192.168.0.126 sqlag
43+
44+
192.168.178.116 contso.com
45+
192.168.178.116 mail.contso.com
46+
192.168.178.116 smtp.mail.contso.com
47+
192.168.178.116 pop3.mail.contso.com

0 commit comments

Comments
 (0)