Tuesday, July 8, 2014

How to Create a New Content Database in SharePoint 2013 using PowerShell

Although a content database can accommodate up to 10,000 site collections in SharePoint, its not advisable to use it so, as the recommended size of the content database is < 200 GB in SharePoint 2013. Also, that could introduce Security, Backup-restore issues to affect your SLA.

When you create new site collection in SharePoint, it picks the available database which has room. Lets see How to create new content database for SharePoint.

How to add a content database in SharePoint 2013 from Central Administration site:

  1. Login to SharePoint App/WFE server as a Farm Administrator
  2. Open Central Administration >> Application Management >> Manage content databases 
  3. Click on "Add a content Database" link
  4. On the Add Content Database page:
    • Specify a Web application for the new database.
    • Specify a database server to host the new database
    • Specify the number of sites collections before a warning is issued. By default, this is 9,000. Specify the total number of sites that can be created in the database. By default, this is 15,000.
    • Click  "OK" to add new content database in SharePoint 2013.
How to Create a New Content Database in SharePoint 2013 using PowerShell

That's a straight forward procedure, isn't it?

A Content Database can only be attached to a single Web Application!

Create a New Content Database in SharePoint 2013 using PowerShell
While you can use SharePoint Central Administration to manage some of the things you need to do to with  content databases, PowerShell is the best tool for managing content databases efficiently. Here is how to add new content database with PowerShell:

New-SPContentDatabase -Name <Content-DB-Name> -WebApplication <Web-App-Name or URL>
Here is an example:
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue

#Variables for Database server and Content Database Name
$DatabaseServerName = "YOUR-DB-SERVER"
$DatabaseName = "Hosting_ContentDB_001"
$WebAppName = "SharePoint Hosting"

#Create content database
New-SPContentDatabase -Name $DatabaseName -DatabaseServer $DatabaseServerName -WebApplication $WebAppName -MaxSiteCount 100 -WarningSiteCount 80

This cmdlet should emit the newly created content database GUID something like:
Id       : faca5154-3c10-4db8-8677-a863b4fc6302

Tips: you cannot have one site collection spread over multiple content databases. But one content database can hold multiple site collections.

Tail: How to create a site collection in a specific Content Database?
If you want to create a new site collection in the new database then there are different options available in the SharePoint 2013. Here is my preferred way: You can create a new site collection in a specific content database by using PowerShell cmdlet New-SPSite cmdlet with -ContentDatabase  parameter. Here is how:
New-SPSite http://your-web-app-url/sites/Your-Site-collection -OwnerAlias "SiteOwnerUserName" -ContentDatabase "ContentDatabaseName" -Name "Site-Name" -Description "Site-Description" -Template "STS#0"

Please note that the "ContentDatabaseName" must refer to an existing database created already.

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...