Using the Tools and Configuring SQL Server 2008
-
Upload
learnitfirst -
Category
Documents
-
view
225 -
download
0
Transcript of Using the Tools and Configuring SQL Server 2008
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
1/82
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
2/82
A Look at the Tools and Configuring
SQL Server 2008
Presented by Scott Whigham
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
3/82
O v e r v i e w Overview
of Chapter
T h e T o o
l s AnOverview
of the Tools Demo
C o n
f i g u r a t i o n
ConfiguringSQL Server
2008
What Were Going to Cover
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
4/82
What this chapter covers What has been installed An overview of each of the tools
Answering The Three Ws: W hat it is, W hat it does, W ho Uses It
An overview of configuring the server
This Chapter
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
5/82
What this chapter does NOT cover An overview of configuring databases In-depth coverage of all tools
Every single server option available Cover every tool available
This Chapter
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
6/82
O v e r v i e w Overview
of Chapter
T h e T o o
l s AnOverview
of the Tools Demo
C o n
f i g u r a t i o n
ConfiguringSQL Server
2008
What Were Going to Cover
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
7/82
There are tools available for: Administrators
SQL Server Database Administrators (DBAs) Reporting Services Administrators Analysis Services Administrators Systems Administrators
Developers SQL Programmers Report developers Integration Services developers Analysis Services developers
An Overview of What Is Installed
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
8/82
There are tools available for: Command line only GUI (Graphical User Interface)
APIs (Application Programming Interface) Lets look at each
An Overview of What Is Installed
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
9/82
Command line tools primarily targetDBAs
Command line tools
Tool Who uses? Description
sqlcmd.exe DBAs, Developers Command line queries/batchesdtexec.exe DBAs Execute SSIS packages
sqldiag.exe DBAs Diagnostics, system info, monitor, troubleshoot
bcp.exe DBAs Import/export text files
profiler.exe DBAs Trace server activity
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
10/82
GUI tools are for everyone!
GUI tools
Tool Who uses? Description
SQL ServerManagement Studio(SSMS)
DBAs, Developers Queries, management, security
Business IntelligenceDevelopment Studio(BIDS)
Developers Develop/edit reports, SSIS packages, SSAS
Visual Studio 2008 Developers It is the real name of BIDS
SQL ServerConfigurationManager
DBAs Manage services, aliases, and networkconfiguration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
11/82
More GUI tools
GUI tools
Tool Who uses? Description
SQL Server Profiler DBAs Trace server activity
Database EngineTuning Advisor
DBAs Performance tuning, optimizations
Data Profile Viewer DBAs View stats on column/table usage
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
12/82
APIs are for developers and integrators
Command line tools
API Who uses? Description
SQL ServerManagement Objects(SMO)
Developers Manage SQL Server via programming interfaces
SQL Server ReplicationManagement Objects(RMO)
Developers Manage replication via programming interfaces
Data Collector Developers Capture, store and report onperformance/health stats
Native Client Developers Combines both ODBC and OLE-DB into one DLL
WMI Developers Use WMI for server events and configuration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
13/82
O v e r v i e w Overview
of Chapter
T h e T o o
l s AnOverview
of the Tools Demo
C o n
f i g u r a t i o n Configuring
SQL Server
2008
In the next video
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
14/82
A Look at the Tools and Configuring
SQL Server 2008
Presented by Scott Whigham
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
15/82
O v e r v i e w Overview
of Chapter
T h e T o o
l s AnOverview
of the Tools Demo
C o n
f i g u r a t i o n Configuring
SQL Server
2008
What Were Going to Cover
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
16/82
You can configure SQL Server at theinstance and database level
This chapter covers the instance level Next chapter covers the database level
Configuration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
17/82
Instance-level configurations affect allconnections and all databases for thatinstance
You can change settings using SQL Server Management Studio SQL Server Configuration Manager
sqlcmd.exe SQL Server Management Objects (SMO) API
Configuration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
18/82
Commonly changed configurations are: Service accounts Network protocols
Memory, CPU Authentication mode and auditing Connection options
Default file locations, compression settings Lets look at each one
Configuration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
19/82
Commonly changed configurations are: Service accounts Network protocols
Memory, CPU Authentication mode and auditing Connection options
Default file locations, compression settings Lets look at each one
Configuration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
20/82
Service accounts are not static Change passwords Change accounts
Changing anything here can be anexciting experience
To change, use the SQL ServerConfiguration Manager
Configuration: Service Accounts
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
21/82
To modify the service accounts, use theSQL Server Configuration Manager
Configuration: Service Accounts
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
22/82
Configuration: Service Accounts
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
23/82
Commonly changed configurations are: Service accounts Network protocols
Memory, CPU Authentication mode and auditing Connection options Default file locations, compression settings
Lets look at each one
Configuration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
24/82
Network protocols define whatconnections SQL Server will accept
Configuration: Network Protocols
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
25/82
If SQL Server has TCP/IP enabled but allothers disabled, only clients using TCP/IPfor connections would be allowed
Both the server and client must use the sameprotocol
Configuration: Network Protocols
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
26/82
Shared Memory Connections and data are not transferred across IP
stack; done in memory Clearly this only works when the client and server
are on the same machine For remote connections, must use one of the
other network protocols
Configuration: Network Protocols
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
27/82
How to Enable Remote Connections Default for Express and Developer editions is to
turn off remote connections This is done by disabling all protocols except Shared
Memory
To enable remote connections:1. Enable TCP/IP or one of the other network
protocols2. Restart SQL Server instance
Configuration: Network Protocols
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
28/82
TCP/IP is most common Requires a unique port per instance Default port for default instance is 1433
Named instances use a random-first-time port
Configuration: Network Protocols
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
29/82
Change/view settings in theConfiguration Manager Any changes here require restarting instance
Configuration: Network Protocols
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
30/82
Configuration: Service Accounts
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
31/82
O v e r v i e w Overview
of Chapter
T h e
T o o
l s AnOverviewof the Tools
Demo
C o n
f i g u r a t i o n Configuring
SQL Server2008
In the next video
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
32/82
A Look at the Tools and Configuring
SQL Server 2008
Presented by Scott Whigham
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
33/82
O v e r v i e w Overview
of Chapter
T h e
T o o
l s AnOverviewof the Tools
Demo
C o n
f i g u r a t i o n Configuring
SQL Server2008
What Were Going to Cover
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
34/82
Memory and CPU usage can change When new hardware is added When the applications usage changes
Some changes require restarting the SQLServer service but most are dynamic
Lets look at memory in this video
Configuration: Memory, CPU
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
35/82
Commonly changed configurations are: Service accounts Network protocols
Memory, CPU Authentication mode and auditing Connection options Default file locations, compression settings
Lets look at each one
Configuration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
36/82
Memory is used the most in two areas Buffer cache
Stores the data users are working with in memory toavoid reading disk on commonly-requested data
Procedure cache SQL Server caches the how of running queries and
routines to avoid having to figure out the fastest routeto the data on subsequent calls
The how is the Execution Plan
Configuration: Memory, CPU
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
37/82
Sizing the Buffer Cache Too small means that users have to wait for SQL
Server to access hard disk Too large means that the operating system and/or
other applications do not have enough memory
Configuration: Memory, CPU
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
38/82
Buffer cache as a percentage of the datafile size The larger the database, the smaller the
percentage of the size A 10TB system with 10 concurrent users likely needs a
1-2% buffer cache A 10GB system with 100 concurrent users may need as
much as a 25% buffer cache
Configuration: Memory, CPU
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
39/82
The Buffer Cache should be expected tobe between 5 and 25% of the data filesize for an online transaction processing
(OLTP) system Should be a bit larger percentage for reporting
Configuration: Memory, CPU
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
40/82
Sizing the Procedure Cache On a 32-bit system, the procedure cache is limited
to 1GB Cannot use Address Windowing Extensions (AWE)
On a 64-bit system, procedure cache can be larger This is necessary on larger systems
Configuration: Memory, CPU
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
41/82
Memory options you can change Max server memory
Always, always set this to avoid a too-large buffer cache Min server memory Using Address Windowing Extensions (AWE)
Only used in 32-bit installations when there is > 4GB of RAM
Configuration: Memory, CPU
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
42/82
Memory options you can change (cont.) Index create memory
Specifies the amount of memory to use in indexcreation sorts
0 means dynamic Have a good reason to change
Configuration: Memory, CPU
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
43/82
Memory options you can change (cont.) Minimum memory per query
Specifies the amount of memory to use for execution of a query
0 means dynamic 1024KB is default Have a good reason to change
Configuration: Memory, CPU
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
44/82
O v e r v i e w Overview
of Chapter
T h e
T o o
l s AnOverviewof the Tools
Demo
C o n
f i g u r a t i o n Configuring
SQL Server2008
In the next video
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
45/82
A Look at the Tools and Configuring
SQL Server 2008
Presented by Scott Whigham
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
46/82
O v e r v i e w Overview
of Chapter
T h e
T o o
l s AnOverviewof the Tools
Demo
C o n
f i g u r a t i o n Configuring
SQL Server2008
What Were Going to Cover
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
47/82
Commonly changed configurations are: Service accounts Network protocols
Memory, CPU Authentication mode and auditing Connection options Default file locations, compression settings
Lets look at each one
Configuration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
48/82
CPU settings that can be changed Enable/disable processors
Licensing needs System performance
Affinity mask options Processor affinity: binds processors to specific threads
to prevent switching mid-execution
I/O affinity: binds disk I/O to specific processors
Configuration: Memory, CPU
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
49/82
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
50/82
Parallel queries are queries whose workis split among CPUs Cost is a metric of time
A query with a cost of 1 says that theoretically willtake 1 second
This was determined pre-release in the Microsoft labstherefore it will not likely match your system
performance
Configuration: Memory, CPU
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
51/82
You can configure how SQL Serverhandles parallel queries Cost threshold for parallelism
SQL Server does not run a parallel plan for queries thatcost less than this amount
Default value is 5 This means that a query has to be estimated to run for 5
seconds before SQL Server will consider using a parallel plan 5 is the default for a very good reason
Configuration: Memory, CPU
f
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
52/82
You can configure how SQL Serverhandles parallel queries (cont.) Max degree of parallelism
Controls how many processors are available to run asingle statement
Default value is 0 which means to use all availableCPUs
Can be overridden at query level
Configuration: Memory, CPU
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
53/82
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
54/82
A Look at the Tools and Configuring
SQL Server 2008
Presented by Scott Whigham
Wh W G i C
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
55/82
O v e
r v i e w Overview
of Chapter
T h e
T o o
l s AnOverviewof the Tools
Demo
C o n
f i g u r a t i o n Configuring
SQL Server2008
What Were Going to Cover
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
56/82
C fi ti S it
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
57/82
Security settings that can be changed: Authentication mode
Requires restarting SQL Server service to take effect Login auditing
Bare auditing doesnt record too much information None, Failed only, Successful only, Both
Server Proxy Account
Used with xp_cmdshell Not likely to use but, if you do, be careful
Configuration: Security
C fig ti S it
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
58/82
Security settings that can be changed (cont.): Enable Common Criteria Compliance Forces SQL Server to adhere to Common Criteria compliance Developer and Enterprise edition only
More info: http://www.commoncriteriaportal.org/ Enable C2 audit tracing
Audits all attempts to access statements and objects tofile(s)
Cross database ownership chaining Coming up in later chapter
Configuration: Security
Config ration
http://www.commoncriteriaportal.org/http://www.commoncriteriaportal.org/ -
8/14/2019 Using the Tools and Configuring SQL Server 2008
59/82
Commonly changed configurations are: Service accounts Network protocols Memory, CPU Authentication mode and auditing Connection options Default file locations, compression settings
Lets look at each one
Configuration
Configuration: Connections
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
60/82
Connection options affect all connectionsto the instance Some can be overridden at connection level
Triple check this in development/testingbefore deployment
One setting change can cause critical parts of an
application to fail
Configuration: Connections
Configuration: Connections
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
61/82
Connection options you can change: Maximum number of concurrent connections
Default is 0 which is no limit Use Query Governor to prevent long-running
queries Great idea in theory; better to use Resource Governor
Configuration: Connections
Configuration: Connections
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
62/82
Connection options you can change(cont.): Allow remote server connections
Do you want remote servers to run stored procedureson this server?
Require distributed transactions for server-to-server communication
Uses Microsoft DTC to ensure that transactionscompletely succeed on all servers
Configuration: Connections
Configuration: Connections
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
63/82
Common connection options All are Off by default This allows client to set its own defaults
Configuration: Connections
Setting Description Defaultansi nulls Does the statement
WHERE LastName =NULL return any rows?
Statement would return 0rows; requires ISNULL totest for NULL values
no count 34 rows affected
messages are returned toclient
quoted identifier Do double quotes identifyobject names or querycriteria?
In the next video
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
64/82
O v e r v i e w Overview
of Chapter
T h e
T o o
l s AnOverviewof the Tools
Demo
C o n
f i g u r a t i o n Configuring
SQL Server2008
In the next video
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
65/82
A Look at the Tools and Configuring
SQL Server 2008
Presented by Scott Whigham
What Were Going to Cover
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
66/82
O v e r v i e w Overview
of Chapter
T h e
T o o
l s AnOverviewof the Tools
Demo
C o n
f i g u r a t i o n Configuring
SQL Server2008
What We re Going to Cover
Configuration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
67/82
Commonly changed configurations are: Service accounts Network protocols Memory, CPU Authentication mode and auditing Connection options Default file locations, compression settings
Configuration
Configuration: File locations &
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
68/82
Defaults for new databases: Default index fill factor How full should a page be? Default is to fill page completely
Backup compression Sets whether a backup is compressed by default Any backup can be compressed or uncompressed
regardless of this setting For Enterprise and Developer edition
Configuration: File locations &Compression
Configuration: File locations &
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
69/82
Defaults for new databases (cont.) Database default locations
Configure the default locations for data and log filesindividually
For new databases only Default locations are only used in statements that do
not specify file locations
Configuration: File locations &Compression
CREATE DATABASE ScottsDB
In the next video
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
70/82
O v e r v i e w Overview
of Chapter
T h e
T o o
l s AnOverviewof the Tools
Demo
C o n
f i g u r a t i o n Configuring
SQL Server2008
Demo
In the next video
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
71/82
A Look at the Tools and Configuring
SQL Server 2008
Presented by Scott Whigham
What Were Going to Cover
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
72/82
O v e r v i e w Overview
of Chapter
T h e T o o
l s AnOverviewof the Tools
Demo
C o n
f i g u r a t i o n Configuring
SQL Server2008
What We re Going to Cover
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
73/82
How to Change ConfigurationSettings
How to Change Configuration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
74/82
How to change configuration settings Use SSMS for interactive or jobs Use sqlcmd.exe for scripts
Can use the GUI and Transact SQL scripts
ow to C a ge Co gu at oSettings
Configuration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
75/82
GUI is great for learning Scripts are better for
Change tracking Undoing Sharing across machines/users
Changes require two things: The actual change Acknowledgement that the change should be
applied
g
Configuration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
76/82
Tips Have a backup or back out plan Understand that SQL Server will often clear out
portions of its memory after configurationchanges
This can have severe short-term impact!
g
Configuration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
77/82
Configured values are what SQL Serverwill change to once you click OK Running values are what SQL Server is
currently using Running values is a read-only view of what the
system is using right now
g
Configuration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
78/82
To change configurations in the GUI:1. Launch SQL Server Management Studio2. Login as a sysadmin
3. Right click on server and select Properties After changes, click OK to save
Try, try, try not to do this during productionhours!
g
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
79/82
Configuration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
80/82
sp_configure is the Transact-SQL way tomodify server configurations To use sp_configure, you must first
enable the advanced options
g
EXEC sp_configure show advanced, 1
RECONFIGURE
Configuration
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
81/82
sp_configure requires use of RECONFIGURE or RECONFIGURE WITHOVERRIDE to take effect without a
restart of SQL Server service Otherwise changes will not take effect until you
stop/start
EXEC sp_configure show advanced, 1RECONFIGURE
-
8/14/2019 Using the Tools and Configuring SQL Server 2008
82/82