Rename an xDB Collection database shard
When you rename an xDB Collection shard, you must update references to that shard in several tables. You might rename a shard if you copy xDB Collection database between environments - for example, from your local developer environment to a QA environment. In this scenario you might want to rename a shard from brandlocaldev_Xdb.Collection.Shard1
to brandqa_Xdb.Collection.Shard1
.
A shard is a database. The xDB Collection database is made up of multiple databases - a shard map manager and several shards.
To rename a shard:
-
Follow Microsoft's instructions to rename the shard (database). For example, you might rename
foo_Xdb.Collection.Shard1
tobar_Xdb.Collection.Shard1
. -
For the database that you just renamed (now
bar_Xdb.Collection.Shard1
), locate the_ShardManagement.ShardsLocal
table. -
For each row in the
_ShardManagement.ShardsLocal
table, change the value of theDatabaseName
field from the old database name (foo_Xdb.Collection.Shard1
) to the new database name (bar_Xdb.Collection.Shard1
). -
Switch to the cluster's shard map manager database, for example,
foo__Xdb.Collection.ShardMapManager
. -
In the
_ShardManagement.ShardGlobal
table, select all where theDatabaseName
equals the old database name (foo_Xdb.Collection.Shard1
). You will get three results - one for each shard map. -
Change the value of the
DatabaseName
field from the old shard database name (foo_Xdb.Collection.Shard1
) to the new shard database name (bar_Xdb.Collection.Shard1
). -
Restart all roles that reference the xDB Collection database. This includes:
NoteIf you do not restart before rebuilding the index, the old shard name might still be cached and the rebuild will fail.
-
When you have finished renaming all the shards that you intend to rename, rebuild the xDB search index.
If you rename the ShardMapManager, you must update the collection
connection string of all roles that reference the xDB Collection database.