I recently took over a new environment and have had my hands full exploring and setting up all my checks. When I attended users group a few weeks ago I realized I was doing it the hard way. I was connecting to each server one at a time to run my install t-sql scripts and checks. Mike Tutor gave a fantastic presentation on CMS (Central Management Servers) in SQL Server and how to get started using it. Today I had another issue with a database logfile that had autogrown to an unruly size. I started to do the math and realized that if I didn’t learn how to use CMS, I would be fixing autogrowth settings all week. So let’s begin. This article assumes that you have already registered your Instances into Groups within CMS. Right-click on your group and select New Query. Run this query to see where you are at:
SELECT sd.name AS DBname, smf.name AS Filename, smf.size, smf.max_size, smf.growth, smf.is_percent_growth
FROM sys.master_files smf
INNER JOIN sys.databases sd ON smf.database_id = sd.database_id
This will give you both the Server Name and the database name on all your files if you are running in CMS but will also work if you are just on one local server.
Next, I am going to use Policy Based Management to Apply a Default Value across all my databases. On a test server, you want to create a new condition:
Whatever you set that @Growth value to is the value that will be set on all your files that you apply this policy on, please use caution and plan a value that will fit your growth needs.
Then pull it into a policy:
Right Click on the Policy and Evaluate the policy to make sure it will do what you are expecting it to do. The green ones were already matching what your policy would do. The red ones are the ones the policy would update. Under Details select View to see what the values are now. You can test out how it is going to work by checking a check box or two and selecting Apply.
Export the policy by right clicking on it and selecting “Export Policy”.
Then go back to your CMS Group and right click to Import Policy. Right click on the group again and select Evaluate Policies. Find the one you just imported and check the box for it and run it. This is the same as before, select the check boxes of the ones you want to update and Apply.
Next, I want to be able to control the rate each system database will grow, this is just an example. Please plan your growth and modify as needed. Right click on your CMS group and select New Query and paste this in then modify as needed. (You could also do this with a more specialized policy, but I wanted to use both.)
ALTER DATABASE [master] MODIFY FILE ( NAME = N'master', FILEGROWTH = 240MB )
ALTER DATABASE [master] MODIFY FILE (NAME = N'mastlog', FILEGROWTH = 160MB )
ALTER DATABASE [msdb] MODIFY FILE ( NAME = N'MSDBData', FILEGROWTH = 240MB )
ALTER DATABASE [msdb] MODIFY FILE (NAME = N'MSDBLog', FILEGROWTH = 160MB )
ALTER DATABASE [model] MODIFY FILE ( NAME = N'modeldev', FILEGROWTH = 240MB )
ALTER DATABASE [model] MODIFY FILE (NAME = N'modellog', FILEGROWTH = 160MB )
ALTER DATABASE [tempdb] MODIFY FILE ( NAME = N'tempdev', FILEGROWTH = 240MB )
ALTER DATABASE [tempdb] MODIFY FILE (NAME = N'templog', FILEGROWTH = 160MB )
Many Chocolate Covered Gummy Bears gave their lives to bring you this information.