Manual update from single database to multi database architecture at Microsoft SQL Server
Update procedure for one tenant with examples for the first tenant. Target database architecture is single server and multiple database, database deployment is with SQL Server authentication. You could update all tenants data analogically. Create system backup before the update.
- Backup single database and dwhtenant schema only.
Backup Dispatcher Paragon Management Server database (default name is SQDB6) in SQL Server Management Studio utility. Right click on database and choose Tasks > Back Up. You could run command line command also, at example:
BACKUPDATABASE[SQDB6]TODISK = N'SQDB6.bak'WITHNOFORMATSee Backup of Databases for detailed instructions.
- Uninstall Dispatcher Paragon Management Server completely. Uninstall Dispatcher Paragon Management Server including database.
- Clean install Dispatcher Paragon Management Server. Install Dispatcher Paragon Management Server in multi database configuration.
- Get configuration data.
Get necessary configuration data from production database (SQDB6):
-- get tenant password and tenant schema name [@tenant_password@, @tenant_schema_name@]selectdb_pass, schema_namefromcluster_mngmt.tenants;-- get dwhtenant password and dwhtenant schema name [@dwhtenant password@, @dwhtenant_schema_name@]selectdb_pass, schema_namefromcluster_mngmt.tenant_warehouses;-- get server guid and id [@server_guid@, @server_id]selectserver_guid, idfromcluster_mngmt.cluster_server;Write it down, you will use these values later for Update configuration data in step 7.
- Stop Dispatcher Paragon services. See Stop Dispatcher Paragon services for detailed instructions.
- Drop new production database and restore the old one.
Drop production database (SQDB6) in SQL Server Management Studio. Right click on production database and choose drop database. You could run sql command also, at example:
DROPDATABASE[SQDB6];In SQL Server Management Studio restore whole database (SQDB6) from step 1. Right click on Databases (SQDB6) and choose Restore Database. You could run sql command also, at example:
RESTOREDATABASE[SQDB6]FROMDISK = N'SQDB6.bak'WITHFILE = 1, NOUNLOAD, STATS = 5 - Update the configuration data.
Update necessary configuration data in production database (SQDB6):
-- update server guidupdatecluster_mngmt.cluster_serversetserver_guid ='@server_guid@'whereid = @server_id@;-- update tenant passwordupdatecluster_mngmt.tenantssetdb_pass ='@tenant_password@'whereschema_name ='@tenant_schema_name@';-- update dwhtenant passwordupdatecluster_mngmt.tenant_warehousessetdb_pass ='@dwhtenant password@'whereschema_name ='@dwhtenant_schema_name@';Replace placeholders by values from step number 4.
Alter users and grant permissions.
-- Alter user with loginALTERUSERcluster_mngmtWITHLOGIN = cluster_mngmt;ALTERUSERcluster_guestWITHLOGIN = cluster_guest;ALTERUSERtenantuser_1WITHLOGIN = tenantuser_1;ALTERUSER[dwhtenantuser_1]WITHLOGIN = [dwhtenantuser_1], DEFAULT_SCHEMA = [tenant_1];-- Grant permissionsEXEC('exec sp_addrolemember db_datareader, dwhtenantuser_1');EXEC('exec sp_addrolemember db_datawriter, dwhtenantuser_1');EXEC('exec sp_addrolemember db_ddladmin, dwhtenantuser_1');GRANTDELETEONSCHEMA::[tenant_1]TO[dwhtenantuser_1];GRANTEXECUTEONSCHEMA::[tenant_1]TO[dwhtenantuser_1];GRANTINSERTONSCHEMA::[tenant_1]TO[dwhtenantuser_1];GRANTREFERENCESONSCHEMA::[tenant_1]TO[dwhtenantuser_1];GRANTSELECTONSCHEMA::[tenant_1]TO[dwhtenantuser_1];GRANTUPDATEONSCHEMA::[tenant_1]TO[dwhtenantuser_1];GRANTVIEWDEFINITIONONSCHEMA::[tenant_1]TO[dwhtenantuser_1];- Copy data into warehouse database.
Run queries from the select at warehouse database (default name is SQDB6_DWH):
select'insert into dwhtenant_1.'+TABLE_NAME+' select * from SQDB6.dwhtenant_1.'+TABLE_NAME+' where id not in (select id from dwhtenant_1.'+TABLE_NAME+')'fromINFORMATION_SCHEMA.TABLESwhereTABLE_SCHEMA ='dwhtenant_1'andTABLE_TYPE ='BASE TABLE'andTABLE_NAMEnotlike'smartq_jobs%'orderbycasewhenTABLE_NAMElike'%dimension'then2whenTABLE_NAMElike'%measures'then3whenTABLE_NAMElike'%junction'then4else1end,TABLE_NAMEExample of the insert returned by the query above: "insert into dwhtenant_1.color_type_accids select * from SQDB6.dwhtenant_1.color_type_accids where id not in (select id from dwhtenant_1.color_type_accids)".
Update warehouse sequencies.
Run queries from the select at warehouse database (default name is SQDB6_DWH):
SELECT'DECLARE @x_sql'+CAST(object_idasNVARCHAR(32))+' as NVARCHAR(1024) select @x_sql'+CAST(object_idasNVARCHAR(32))+' = ''ALTER SEQUENCE ['+SCHEMA_NAME(schema_id)+'].['+name+'] RESTART WITH '' + (select CAST(coalesce((max(id)+1),1) AS NVARCHAR(32)) from ['+SCHEMA_NAME(schema_id)+'].['+SUBSTRING(name,1,(LEN(name)-7))+'] WHERE id != 0) EXECUTE(@x_sql'+CAST(object_idasNVARCHAR(32))+')'FROMsys.sequencesWHEREnamelike'%_id_seq'ANDSCHEMA_NAME(schema_id) ='dwhtenant_1'Example of the insert returned by the query above: "DECLARE @x_sql14623095 as NVARCHAR(1024) select @x_sql14623095 = 'ALTER SEQUENCE [dwhtenant_1].[dm_v2_device_dimension_id_seq] RESTART WITH ' + (select CAST(coalesce((max(id)+1),1) AS NVARCHAR(32)) from [dwhtenant_1].[dm_v2_device_dimension] WHERE id != 0) EXECUTE(@x_sql14623095)".
- Drop dwhtenant schema from production database (SQDB6).
Create a procedure from the cleanUpSchema.sql file into the production database (SQDB6). The file is distributed in the installation package under \Complementary Solutions\Enterprise Reporting.
Execute procedure at production database ( SQDB6 ):
execCleanUpSchema'dwhtenant_1','w'Multitenant environment
If you have multitenant environment repeat steps 8-11 for remaining tenants.Spooling Management
If you have spoolinh Management server you need to update SPOC guid according to new installation.