Configuring sql server - SQL Saturday, Athens Oct 2014
-
Upload
antoniosch -
Category
Technology
-
view
372 -
download
0
description
Transcript of Configuring sql server - SQL Saturday, Athens Oct 2014
![Page 1: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/1.jpg)
Configuring SQL Server
![Page 2: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/2.jpg)
I have been started with computers.
I started my professional carrier in computers industry.
I have been started to work with SQL Server version 6.0
I earned my first certification at Microsoft as Microsoft
Certified Solution Developer (3rd in Greece) and started
my carrier as Microsoft Certified Trainer (MCT) with more
than 20.000 hours of training until now!
I became for first time Microsoft MVP on SQL Server
I created the SQL School Greece (www.sqlschool.gr)
I became MCT Regional Lead by Microsoft Learning
Program.
I was certified as MCSE : Data Platform, MCSE: Business
Intelligence
Antonios ChatzipavlisSolution Architect • SQL Server Evangelist • Trainer • Speaker MCT, MCSE, MCITP, MCPD, MCSD, MCDBA, MCSA, MCTS, MCAD, MCP, OCA, ITIL-F
1982
1988
1996
1998
2010
2012
2013
![Page 3: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/3.jpg)
![Page 4: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/4.jpg)
![Page 5: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/5.jpg)
![Page 6: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/6.jpg)
SQL Server Configuration Checklist
![Page 7: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/7.jpg)
Choosing Windows OS
Windows Server 2012 R2
Highly recommended especially for server
than need to be highly available.
Avoid Windows Server 2008 R2 and older
versions
![Page 8: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/8.jpg)
Apply patches and hotfixes on WinOS
If you plan to use AlwaysOn AG it is
important to apply the following patches
Windows Server 2008 R2 SP1 – KB2545685
Windows Server 2012 – KB2784261
Windows Server 2012 R2 – KB2920151
Prerequisites, Restrictions, and
Recommendations for AlwaysOn Availability
Groups
![Page 9: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/9.jpg)
Configure the Windows page file
SQL Server does not need a giant page file
If SQL Server is the major service on the box
a 2GB page file on system drive it’s enough
Beware removing the page file (KB254649)
![Page 10: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/10.jpg)
Use Anti-Virus when…
The servers is public on the Internet.
The server have open ports to servers that are not behind a firewall.
The server read or execute files from other servers.
The server run HTTP servers
The server hosting file shares.
The server use Database Mail to handle incoming or outgoing email messages.
![Page 11: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/11.jpg)
Setting Anti-Virus exclusions
Directories of SQL Server instance
SQL Server data files
SQL Server backup files
Full-Text catalog files
Trace files
SQL audit files
SQL query files
SQL Server service
![Page 12: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/12.jpg)
Use RAID
Minimum RAID 1 for all drives
Including OS system drive
Even SSD or PCI-Express
RAID 10 for best performance
Use 128GB drive for OS system drive
Test the I/O performance SQLIO/SQLIOSIM
![Page 13: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/13.jpg)
Disk Drive Format
OS System drive should be formatted with
the default (4K) cluster size.
All drives holding data & log files should be
formatted with 64K cluster size
Check your storage for partition alignment
Follow this rule even if it’s a VM on shared
storage
![Page 14: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/14.jpg)
Power Option
Confirm that the Windows power plan is set
to high performance
Confirm that the processors are running at
full speed using CPU-Z
![Page 15: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/15.jpg)
Use Multiple Physical Network Cards when
The connectivity with SQL Server is
important!
You have Failover clustering or Availability
Groups
It’s a good practice even for standalone
server
Teaming NICs
![Page 16: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/16.jpg)
Use separate drive for
SQL Server application folders
SQL Server database data files
SQL Server database log file
including TempDB
TempDB data files
Backups
![Page 17: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/17.jpg)
SQL Server services accounts
Use dedicated domain user account with nospecial rights on the domain.
You do not need or want this account to be a local admin on the machine where SQL Server will be installed.
Use a separate, dedicated domain user accountfor the SQL Server Agent service.
If you are going to be installing and using otherSQL Server related services, you will wantdedicated domain accounts for each service.
![Page 18: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/18.jpg)
Policy Settings and Rights for the SQL
Server service account
Enable Instant File Initialization Perform Volume Maintenance Tasks
Grant Lock pages in memory Common on SQL Server 2005 / Windows 2003
Less common with newer versions(Still it is a good idea to enable LPIM on a new system)
Add the permissions to the Service Account in AD - KB319723 readServicePrincipalName
writeServicePrincipalName
![Page 19: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/19.jpg)
SQL Server Installation
Install only the features you actually need This will reduce your attack surface
It will speed future maintenance of the instance becausethere are fewer components to patch
Install Services Packs or CUs
Enter a strong password for the sa account if youchoose Mixed Mode authentication
Set the Data Directories according to plan Do not use C: drive
![Page 20: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/20.jpg)
Trace Flags to enable
1118
This trace flag switches allocations in tempdb
from single-page at a time for the first 8 pages, to
immediately allocate an extent (8 pages).
2371
that you can use to control when the query
optimizer generates autostats on a table
![Page 21: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/21.jpg)
Server Properties
Enable compressed backups
Setting Default backup media retention
(days)
Setting Database default location for
Data files
Log files
Backups
![Page 22: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/22.jpg)
Server Properties
Max Worker Threads
Priority Boost
Lightweight Pooling
Maximum number of concurrent connections
Network Packet Size
![Page 23: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/23.jpg)
SQL Server Memory
Set Max Server Memory Important when LPIM is enabled
Use this formula to calculate SQL Server Memory Reserve 1GB for OS
Reserve 1GB for each 4GB after the first 4GB and until 16GB
Reserve 1GB for each 8GB after the first 16GB
Monitor the Memory:AvailableMB performance counter
Server Memory 64GB
1GB for OS
3GB for 4-16GB
6GB for 16-64GB
10GB in total
64-10 = 54 Max SQL
Server memory
![Page 24: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/24.jpg)
Tweak Model database
Change the default size for data and log files
Change the file growth to fixed units
![Page 25: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/25.jpg)
Configure TempDB
Move TempDB to its own drive
Grow the size of data file
Add additional data files as the number of
logical processors up to 8 logical CPUs
Each file must have the same size
Pre-allocate the space.
KB2154845
![Page 26: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/26.jpg)
Configure MAXDOP
Set this to the number of physical cores in a single NUMA node socket on your hardware or less
Always use an even value
Use the value of 1 only of you have specific vendor requirements SharePoint
BizTalk
SAP
KB2806353
![Page 27: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/27.jpg)
Cost Threshold of Parallelism
General default value of 5 is low for most
OLTP workloads and should be increased.
Base value of 20-25 used for most server
installs.
![Page 28: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/28.jpg)
Optimize for Ad-hoc workloads
Control the amount of memory that is used bysingle-use, ad hoc query plans in the plan cache.
SQL Server store only a small stub of an ad hoc query plan in the plan cache the first time that the ad hoc plan is executed
Reduces the memory required for that plan in the plan cache.
It’s not a panacea for single-use ad hoc query plans
http://www.sqlschool.gr/blog/do-you-have-optimize-for-ad-hoc-workloads-on-sql-server-2008-r2-instances-380.aspx
![Page 29: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/29.jpg)
SQL Server Network Connectivity
Enable TCP/IP
Firewall exceptions
TCP port of instance
UTP 1434 for SQL Browser
![Page 30: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/30.jpg)
Configure Alerting and Monitoring
Configure Database Mail
Create Operators
Configure SQL Agent to use Database Mail
Create Alerts for Severity 16 to 25
Create Alerts for Errors 823, 824, 825
Adding Ola Hallengren’s MaintenanceSolution
Install Adam Machanic sp_WhoIsActive
Install and run Brent Ozar sp_Blitz
![Page 31: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/31.jpg)
Create Database
Don’t use the default file size
Don’t use presentence as file growth
Pay attention on T-Log size and growth to produce equal VLFs
Use more than one filegroups
In PRIMARY leave system object
Put all user objects to another filegroup
Use more than one data files
Even this are in the same drive
![Page 32: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/32.jpg)
Database Properties
Don’t set Auto Close
Don’t set Auto Shrink
Don’t unset Auto Create/Update Statistics
![Page 33: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/33.jpg)
ANSI_NULLS
Determine comparison evaluations.
When set to ON all comparison to a null value evaluate to UNKNOWN
When set to OFF all comparison to a null value evaluate to TRUE if both values are NULL
The default value is OFF
This option is deprecated and will always be ON in a future version of SQL Server
![Page 34: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/34.jpg)
ANSI_PADDING
When set to ON data stored in char, varchar, binary, varbinary data types retain any padded zeros To the left of variable binary
Left and Right of variable length characters
The default is OFF
This option is deprecated and will always be ON in a future version of SQL Server
![Page 35: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/35.jpg)
INSTEAD OF Triggers
Instead Of triggers can be nested regardless
of the setting of Nested triggers option
![Page 36: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/36.jpg)
![Page 38: Configuring sql server - SQL Saturday, Athens Oct 2014](https://reader031.fdocuments.net/reader031/viewer/2022020306/54820ffb5806b5e8048b4609/html5/thumbnails/38.jpg)