sp_configure and SQL Server Management Studio We’ve covered installing and configuring the different SQL Server Services so far.. For this section we’re going to be focused on the Serve
Trang 1Configuring & Implementing…
Stopping Dynamic Port Detection
Some companies require that dynamic port detection and being able
to browse to SQL Servers on their network must be disabled to tighten security They do this by stopping the SQL Browser Service on all their SQL Servers and manually configuring each SQL Server instance to listen on
a fixed TCP port.
All the applications that connect to the SQL Server instances either specify the port number in the connection string or have a SQL Server Alias configured on the application server which contains the port number.
Launch SQL Server Management Studio and try to connect to
<computername>\SQL1 You should now be able to connect.
You have just changed the SQL Server Service account, changed the TCP port to a fixed nondefault value, stopped dynamic port detection, and created a client connection alias specifying the TCP port to which to connect.
sp_configure and
SQL Server Management Studio
We’ve covered installing and configuring the different SQL Server Services so far Now we’ll move on to configuring SQL Server itself
SQL Server Management Studio is the central tool for managing SQL Server, and you will need to be very familiar with it for the exam Fortunately, most of the exam objectives require the use of this tool so you will get plenty of practice with
it as you read through the book For this section we’re going to be focused on the
Server Properties that can be changed through the Management Studio interface and
by using the sp_configure command in a query window.
sp_configure provides far more configuration options than the Management
Studio interface, and you will need to be familiar with it for the exam Because of this, we’re going to focus on sp_configure and its options, highlighting where a particular option is also available in Management Studio
Trang 2Figure 3.10 sp_configure Output With Default Values
To run sp_configure simply type it into a query window and click execute
In Figure 3.10 you can see the results of executing sp_configure on an instance with
default values To access the Server Properties in Management Studio, right-click
on a registered server in the Object Explorer window and select Properties.
Advanced Options
As you can see in Figure 3.10, when you run sp_configure you’ll get a list of
16 options One of the first things you’ll typically do as a DBA is to expand that list
to show all of the configuration options You do this by enabling show advanced
options using the following command:
sp_configure 'show advanced options', 1
go
reconfigure
Trang 3This is the format for changing all of the options; you pass the option name in single quotes followed by a comma and then the value you want to change it to
When you change a configuration option, typically only the config_value changes, and
then you need to run reconfigure to tell SQL Server to reload all the values After
this is executed you’ll see the new values in both the config_value and run_value columns
in the sp_configure output, indicating that SQL Server is using the new values
There are some settings, however, that require SQL Server to be restarted
When you run sp_configure again you’ll see an extended list of 68 options
This is a persisted instance-wide change, so all administrators will now see the
advanced options
We’ll now take a look at some of the most commonly changed options and requirements, highlighting where the change can also be made in Management Studio
AWE
On a 32-bit system SQL Server is limited to using 2GB of memory To use more
than 2GB of memory you need to enable the Address Windowing Extensions
(AWE) option in SQL Server AWE allows a 32-bit application, built to support it, to
access as much memory as the underlying operating system Windows Server 2008 Enterprise supports as much as 64GB of RAM AWE has two valid values, 0 or 1
To enable AWE to run:
sp_configure 'AWE', 1
go
This setting is only visible after enabling show advanced options It requires
you to restart SQL Server before it takes effect and can also be configured in SQL
Server Management Studio You should always set max server memory when
using AWE to prevent SQL Server taking too much RAM from Windows
Setting the Maximum and
Minimum Memory for SQL Server
By default, SQL Server will grow its memory usage to take advantage of as much memory on the server as possible This can very often leave only 100 to 200 MB of memory free on a server, causing problems when Windows requires more memory for something and SQL Server is too slow to give some back
Trang 4Max Server Memory (MB)
Max server memory (MB) controls the maximum size of the buffer pool, which is the
pool of memory that SQL Server uses for most of its requirements Setting the
maximum server memory is strongly recommended if you are using AWE or if you’re
running a 64-bit version of SQL Server To set max server memory (MB) to 6 GB run:
sp_configure 'max server memory (MB)', 6144
go
reconfigure
This setting is only visible with sp_configure after enabling show advanced
options, but you can also change this setting in SQL Server Management Studio
on the Memory page.
Min Server Memory (MB)
Min server memory works hand in hand with max server memory but isn’t as
impor-tant to as many scenarios It provides a minimum value that SQL Server will attempt
not to go under once it has reached that value
For example, you set min server memory to 2GB When SQL Server first starts it
takes the minimum amount of memory required for it to start and then grows its
memory usage as it needs to Once it has grown to be more than 2GB, SQL Server
will attempt to keep the buffer pool above that value This setting is most useful when running multiple instances on a single server or if there are other memory-intensive
applications running on the server To set min server memory (MB) to 2GB run:
sp_configure 'min server memory (MB)', 2048
go
reconfigure
You can also change this setting in SQL Server Management Studio on the
Memory page.
Trang 5Maximum Degree of Parallelism
If SQL Server determines that a query that has been executed is expensive enough
in terms of resource consumption, it may try to break down the work into several
units and execute them on separate CPUs This is called parallelism and is a very
intensive operation, where SQL Server assumes that this query is important enough
to run as quickly as possible at the expense of additional CPU usage
By default SQL Server will use up to all of the available CPUs on a server for a parallel operation This can cause problems with all the CPUs running at 100 percent for a period and slowing down other operations
The max degree of parallelism option allows you to control how many CPUs can
be used for parallel operations A common best practice is to set this value to half the number of CPU cores on your server For example, if you have four dual-core
CPUs, you will see eight cores in Windows, so you should set max degree of
parallelism to 4 You will not be tested on what the formula should be to calculate
the optimal value, but you may be tested on what it does
To set max degree of parallelism to 4 run:
sp_configure 'max degree of parallelism', 4
go
reconfigure
The max degree of parallelism is also known as MAXDOP and can be specified
at the query level using the MAXDOP keyword, as well as the server level
Head of the Class…
32-bit, 64-bit, and Memory
32-bit (or x86 as it’s sometimes known) systems have a limitation of 4 GB
of virtual address space, so if you have more than 4 GB of RAM in a server without AWE enabled, then SQL Server won’t be able use the extra memory 64-bit (or x64 as the most common platform is known) has a limitation of 8TB of virtual address space, so you get access to more RAM without having to switch on AWE.
The Standard and Enterprise Editions of SQL Server both support as much RAM as the Windows version that they run on, and they come with licenses to run either the x86 or x64 version of SQL Server at no additional cost.