![]() |
|

SQL Server backup compression with network fault tolerance and zero impact encryption
|
|
By: Kun Lee | Read Comments (10) | Related Tips: 1 | 2 | 3 | 4 | More > Central Management Servers |
Problem
Managing multiple SQL Servers has its challenges. One of the big challenges is having to collect data from each of the servers you manage and figure out which servers need attention. You can setup a process to connect to each server and collect the data or you can use a third party tool, but SQL 2008 offers a new way of doing this using Central Management Servers. In this tip I show you what this new feature is, how to setup it and how to collect data from all of your servers at the same time. And best of all, once it is setup you can even use it on your SQL 2000, SQL 2005 and SQL 2008 servers.
Solution
SQL 2008 introduced a new feature call "Central Management Servers (CMS)" which allows you to administer multiple servers and consolidate the SQL Server registration for all the SQL Server users such as developers, DBAs, etc.
Pre-requisite
Initial Setup
The setup is very straight forward. You just need to follow the How to: Create a Central Management Server and Server Group (SQL Server Management Studio) process which is outlined below.
General Structure for Server Groups (How I do it) - Setting up Folders and register servers

Now, here is one little tip. When you try to register the server that is running "Central Management Server" (for my case, DCKLEE3\SQL8008A), you will get the below error which says you cannot add a shared registered server with the same name as the Configuration Server.

When you get this error here is the work around. First, you need to find what port number the server is using. You can see "Static Port Assignments in SQL 2005" article to check what port is being using.
(If you are using Dynamic Ports, then you need to create an alias (see How to setup and use a SQL Server alias), but I wouldn't recommend using this because now you have to ask all the users to setup the same alias to use it. To make it easier you can deploy it automatically to all desktops by using a script, but again I wouldn't recommend using it unless you have to use dynamic ports.)
Anyway, once you find the port number, you need to put the port number along with the server name like "DCKLEE3\SQL2008A,2010" (i.e, 2010 is the port number for this server) and now you should be able to register it.

Example1: Pull Failed SQL Server Agent jobs for last 7 days for all SQL Servers
First, right click the "All" folder that you just created and choose "New Query":

Second, run "SELECT @@VERSION" to see version information for all servers that have been registered. If you run the query you will see something like below which will give you this information for all servers in the "All" folder. (Note: for security purposes I hid the beginning part of the server names below, so the output looks a little weird.)

Example 2: Get the query from article "Failed SQL Server Agent Jobs" and try to run it! Pretty slick!
At this point you can execute any query you want and it will return results for each server in the group you selected.
Security Setup
In order to use this, you will need to setup two different permissions for two different users/groups. One will have management rights and the other read rights. There are new database roles in the msdb database, the two roles that will be used are:
-- Setting up User for General Reader USE [master] GO CREATE LOGIN [ILOVESQL\GroupDeveloper] FROM WINDOWS WITH DEFAULT_DATABASE=[msdb] GO USE [msdb] GO CREATE USER [ILOVESQL\GroupDeveloper] FOR LOGIN [ILOVESQL\GrpDeveloper] GO EXEC sp_addrolemember N'ServerGroupReaderRole', N'ILOVESQL\GroupDeveloper' GO |
-- Setting up User for Administrator USE [master] GO CREATE LOGIN [ILOVESQL\GrpDBA] FROM WINDOWS WITH DEFAULT_DATABASE=[msdb] GO USE [msdb] GO CREATE USER [ILOVESQL\GrpDBA] FOR LOGIN [ILOVESQL\GrpDBA] GO EXEC sp_addrolemember N'ServerGroupAdministratorRole', N'ILOVESQL\GrpDBA' |
That's all there is to it. Just setup a Central Management Server, register your servers, grant permissions and start executing queries across all of your SQL Servers.
Next Steps
References
| Monday, June 08, 2009 - 4:18:35 AM - ellis | Read The Tip |
|
is it true that CMS will only work with Windows authentication, so you can't connect to servers vis a sql login, it has be windows... that kind of makes it useless to me, for the servers i can only connect to using SQL Logins... |
|
| Monday, June 08, 2009 - 2:40:59 PM - kunsikl@gmail.com | Read The Tip |
|
Dear Ellis, Thank you for a great input. |
|
| Monday, June 08, 2009 - 3:09:09 PM - ellis | Read The Tip |
|
Hi? Thanks for the articles, will this process allow me to execute, say a query returning failed jobs in one place and get the results of many servers. I know i can register servers and connect to them easily enough but to check several server i guess i still need to execute the query multiple times on different servers |
|
| Monday, June 08, 2009 - 3:29:42 PM - kunsikl@gmail.com | Read The Tip |
|
Absolutely Not :) You do not need to execute the quer multiple times! As long as you have SQL 2008 Management Studio and once you setup on your local machine, just right click the folder and and choose "New Query". That will get you what you need. Of course, assume you have servers that registered. Again it will initiate multi server query on all different servers that you registered and it will return the result set as one grid or text. If you do not want to see the result in one grid or text, you can change the option to disable/enable under Options (Query Results/SQLServer/Multi-Server) See this for more information on http://msdn.microsoft.com/en-us/library/bb895275.aspx Thanks, |
|
| Wednesday, June 09, 2010 - 4:44:06 PM - ocean_emerald | Read The Tip |
|
Is there a way to schedule something using central management server? For instance, I want to run a same query against a list of servers each day and email the result to an email addr? |
|
| Wednesday, June 16, 2010 - 11:19:28 AM - MikeC | Read The Tip |
|
The CMS is handy for a hands on view of your servers; However, I cannot figure out how do access a CMS group via a job or script. Do you know of anyway to run a multi server query from a job?
Thanks. Mike |
|
| Wednesday, June 16, 2010 - 1:51:23 PM - kunsikl@gmail.com | Read The Tip |
|
Unfortunately, that is not built in feature. In my company, we actually have customize Central Management DB via .NET code and that code uses the connect string to push things out. Also since we have SQL server name stored as table, I have SSIS package to grab that as connection string and run the command or you can use “SQLCMD.exe” with xp_cmdshell or OPENQUERY commend to execute the query to all servers. I am sorry that I can’t give you easy answer for this. |
|
| Tuesday, November 09, 2010 - 10:40:55 AM - Robert | Read The Tip |
|
Is there a way to connect to the CMS server using reporting services and run a report? |
|
| Monday, April 29, 2013 - 9:29:14 AM - Roderick McBan | Read The Tip |
|
Is it possible to import servers to the Central Management Servers Group through a script ? I have 150+ servers that I would like to add to Central Maangement Server and if I could avoit the pain of donig them all manually it would be great. |
|
| Tuesday, April 30, 2013 - 4:40:31 PM - Kun Lee | Read The Tip |
|
Yes, you can load that to a table and use "msdb.dbo.sp_sysmanagement_add_shared_registered_server" proc to load it. |
|
|
privacy | disclaimer | copyright | advertise | about authors | contribute | feedback | giveaways | user groups Some names and products listed are the registered trademarks of their respective owners. Edgewood Solutions LLC | MSSharePointTips.com | MSSQLTips.com |