Automate vCenter/VUM Database Creation Process

After installing and re-installing VMware vCenter and VUM many times (mostly for testing) all of the manual database creation steps got old pretty fast. So I put some effort into creating a T-SQL script for SQL 2008 that automates most of the tasks.

The T-SQL script below does the following:

1. Adds an existing domain service account for vCenter to SQL. Change the value in the SET command.
2. Grants this account db_owner rights on msdb. Required for vCenter/VUM installation.
3. Creates separate vCenter and VUM databases. Feel free to change their sizes.
4. Sets the ownership of the new databases to the service account.

It’s up to the installer to remove the db_owner rights on the MSDB database after you get done installing vCenter and VUM. I apologize for the line wrapping and weird spacing. It might take a bit of futzing to get it all looking pretty. Of course you will need to tweak the paths and any other information as required.

DECLARE @login_name NVARCHAR(50)
SET @login_name=’contososvc-020-VCTR01′
EXEC(‘CREATE LOGIN [‘+@login_name + ‘]FROM WINDOWS’)


EXEC sp_grantdbaccess @login_name
EXEC sp_addrolemember db_owner, @login_name

USE master
create database “vCenter Server”
( name = ‘vCenter Server’,
filename = ‘K:DataMSSQLvCenter_server.mdf’,
size = 5000MB,
filegrowth = 250MB )

log on
( name = ‘vCenter Server log’,
filename = ‘L:LogsvCenter_server.ldf’,
size = 200MB,
filegrowth = 20MB )

COLLATE SQL_Latin1_General_CP1_CI_AS;

create database “vCenter Update Manager”
( name = ‘vCenter Update Manager’,
filename = ‘K:DatavCenter_Update_Manager.mdf’,
size = 250MB,
filegrowth = 25MB )

log on
( name = ‘vCenter Update Manger log’,
filename = ‘L:LogsvCenter_Update_Manager.ldf’,
size = 25MB,
filegrowth = 2MB )

COLLATE SQL_Latin1_General_CP1_CI_AS;

EXEC(‘ALTER AUTHORIZATION ON DATABASE::”vCenter server” TO [‘+@login_name + ‘]’)

EXEC(‘ALTER AUTHORIZATION ON DATABASE::”vCenter Update Manager” TO [‘+@login_name + ‘]’)


Print Friendly, PDF & Email

Related Posts

Notify of
Inline Feedbacks
View all comments