You are on page 1of 19

SQL SERVER

DATABASE
MIGRATION
SQL Server 2016 - SQL Server 2019
WHAT IS MIGRATION IN SQL?

Database migration is a process of migrating data from one or more


source databases to a target databases by using A database
migration service. When A migration is finished, the dataset in the
source databases resides fully, however, possibly restructured, in the
target databases.

• This project is upgrading sql server from 2016 to


2019 version
• Steps of migration:
– pre-migration
– migration
– post-migration
Why We Need to Migrate Data?
There are many circumstances where you will need
to move a database or restore databases.
The most common reasons are:-
• Moving to an entirely new server.
• Moving to a different instance of SQL.
• New technology and enhanced features E.g 2012
Always on
• Hardware up gradation
• Business requirements change
Hardware Requirements 2019 SQL Server

Component Requirement
Hard Disk SQL Server requires a minimum of 6 GB of available hard-disk space.

Monitor SQL Server requires Super-VGA (800x600) or higher resolution monitor.

Internet Minimum
Express Editions: 512 MB
All other editions: 1 GB

Recommended : Express Editions: 1 GB

All other editions: At least 4 GB and should be increased as database size increases to ensure
optimal performance.
Processor Speed Minimum: x64 Processor: 1.4 GHz

Recommended: 2.0 GHz or faster


Processor Type x64 Processor: AMD Opteron, AMD Athlon 64, Intel Xeon with Intel EM64T support, Intel
Pentium IV with EM64T support

Note:
Installation of SQL Server is supported on x64 processors only. It is no longer supported on
x86 processors.
Software Requirements

Component Requirement
Operating system Windows 10 TH1 1507 or greater

Windows Server 2016 or greater

.NET Framework Minimum operating systems includes minimum .NET


framework.

Network Software Supported operating systems for SQL Server have built-in
network software.

Named and default instances of a stand-alone installation


support the following network protocols: Shared memory,
Named Pipes, and TCP/IP.

Note: SQL Server Setup installs the following software components required by the product:
SQL Server Native Client
SQL Server Setup support files
PRE-MIGRATION PLAN
● SQL SERVER DATABASE MIGRATION PATHS:
○ Source Server: 2016
○ Destination Server: 2019

● METHODS OF DATABASE MIGRATION IN SQL SERVER DATABASE:


■ Backup or Restore
■ Detach or Attach
■ Data import/export
■ Log shipping
■ Copy Database Wizard
■ Third Party SQL Database Migration Tool

● MIGRATION PLANNING STRATEGY:

○ In-Place: With the help of SQL Server Setup program users can directly upgrade the running
instance of Server 2016 to SQL Server 2019. An earlier instance of MS SQL Server will be replaced.

○ Side-by-side: With steps to migrate multiple or some data from an instance of SQL Server (2016) to
the separate instances of SQL Server 2019. There are two types of variations of the side-by-side
upgrade strategy:
Action Item In Place Upgrade Parallel or Side by Side Upgrade
Upgrade Efforts ● Minimum ● Efforts needs to be planned
● Upgrade is Automated ● Manual migration
● No data migration Needed ● Data migration required

Downtime ● Requires downtime ● Minimum or no downtime required


● Production will be online while migration is taking place
Configuration Changes ● Configuration changes are Automated by the system ● All configurations needs to be preserved and migrated over to new
● Application configuration is not need since it would use SQL Server instance
same connection information ● Applications needs to change configuration to connect to new SQL
Server instance
● Requires manual check of all configurations(system and user)
Data Transfer ● No Data Transfer required ● Data Transfer required and can be planned in staging manner
● All server integration changes remain intact and get ● All server integrations needs to be created over to new SQL Server
upgraded by the system (Replication, Mirroring, Linked Instance
Server and SQL Server Agent Jobs etc.)

Server Name and IP ● No changes in Server and SQL server instance ● Server and IP address will change
● Application can continue using same server Name and IP ● All application needs to change their connection to connect to new
Address server with new IP address

Testing ● Testing is relatively faster as same testing script and be ● Thorough testing required as there are chances to a configuration
used once upgrade is completed mismatch
● Testing needs to be planned and new testing script required since
Server Instance has changed for testing script
Rollback ● Rollback usually is rebuilding the whole system ● Rollback is very easy as production system remains online during
● Requires backup of all configuration, databases including migration, if testing fails, it can be remediated with no downtime
system databases required and all application can connect to previous Online
production system
SQL Versioning and Architecture ● Versioning upgrade would be possible with same ● Since it would be new install, any version with any architecture can
architecture (32 bit to 32 bit), 32bit to 64 bit is not be installed and tested
supported
● TASK AT SOURCE SERVER
○ Roll up all required Service Packs, Updates, and Hotfixes (fix a single issue). Microsoft SQL Server
2016 can directly transfer to MS SQL server 2019 after achieving these below Service Packs:
■ SQL Server 2016: SP1.
■ SQL Server 2016: SP2.

○ Run DBCC CHECKDB :command on all databases to be sure that they are in the consistent state.
○ Run the Upgrade Advisor Tool: Is a great tool provided by Microsoft to help you understand what
needs to be changed within the database before and after migration.

● PRE-MIGRATION CHECKLIST AT SOURCE SERVER

○ Database sizes and disk sizes.


--PROCEDURE TO CHECK DISC SPACE
EXEC MASTER..XP_FIXEDDRIVES
-- TO CHECK DATABASE SIZE
EXEC SP_HELPDB [DBNAME]
○ Data and Log file location.
USE MASTER;
SELECT NAME 'LOGICAL NAME',PHYSICAL_NAME 'FILE LOCATION'
FROM SYS.MASTER_FILES;
○ Server and Database properties (Collation, Auto Stats, DB Owner, Recovery Model, Compatibility
level, Trustworthy option e.t.c)
SELECT
SYSDB.DATABASE_ID,
SYSDB.NAME AS 'DATABASE NAME',
SYSLOGIN.NAME AS 'DB OWNER',
SYSDB.STATE_DESC,
SYSDB.RECOVERY_MODEL_DESC,
SYSDB.COLLATION_NAME,
SYSDB.USER_ACCESS_DESC,
SYSDB.COMPATIBILITY_LEVEL,
SYSDB.IS_READ_ONLY,
SYSDB.IS_AUTO_CLOSE_ON,
SYSDB.IS_AUTO_SHRINK_ON,
SYSDB.IS_AUTO_CREATE_STATS_ON,
SYSDB.IS_AUTO_UPDATE_STATS_ON,
SYSDB.IS_FULLTEXT_ENABLED,
SYSDB.IS_TRUSTWORTHY_ON
FROM SYS.DATABASES SYSDB
INNER JOIN SYS.SYSLOGINS SYSLOGIN ON SYSDB.OWNER_SID = SYSLOGIN.SID

○ Linked Servers
--LINKED SERVERS
SELECT *
FROM SYS.SYSSERVERS
○ Collect the information of dependent applications
○ Database logins, users and their permissions.
○ Maintenance plans.
○ SQL Agent Job
○ Check Orphan users and Orphan fix
--CHECK ORPHAN USERS
SP_CHANGE_USERS_LOGIN 'REPORT'
GO
--CHECK ORPHAN USERS FIX
USE
MASTER
CREATE LOGIN [LOGINNAME] WITH PASSWORD = ‘LOGIN@123’,
SID = USERSID

● PRE MIGRATION CHECKLIST AT DESTINATION SERVER (SQL 2019)

○ Adequate Disk space on the server.


○ Correct destination folders are created.
○ SQL Server is correctly installed and configured as per requirement.
○ Connectivity to the application servers and linked servers.
Checklist on Source SQL Server 2016

Action Item Yes, No, N/A


1. Identify databases you would like to migrate
2. Backup all user database
3. Script out all the existing login
4. Script out all the server Role if Applicable
5. Script out all Audit and Audit Specifications
6. Script out backup device
7. Script out server level triggers if applicable
8. Script out Replication along with Configuration
9. Script out Mirroring
10. Script out Data collection
11. Script out Resource Governor’s Objects
12. Script out Linked server
13. Script out Log shipping, Disaster recovery or High Availability
14. Script out all SQL Server Agent jobs
15. Script out all proxy accounts and credentials
16. Script out all DB Mail objects such as profile and its setting
17. Script out all Operators
18. Script out all alerts
19. Save SQL Server, Server configuration in a file
20. Data encryption Keys
Checklist on Destination SQL Server 2019

Action Item Yes, No, N/A


1. Required SQL Server is installed
2. DBA SQL Server Check list is Competed
3. Enough space for storing Backup and Source scripts
4. Application compatibility is signed off
5. Move Migration folder from source to destination
6. Restore all databases, change compatibility to 150
7. Run Create login script that was generated on source
8. Run linked server scripts
9. Run server role, Audit trigger, Resource governor
10. Data collection
11. Run DB Mail Script, Operator, Alert
12. Run replication, Mirroring, Agent job scripts
13. Check to see if all is working
Migration
Migration Checklist

✓ Stop all applications services with database connected with the database
✓ Set the database to read only mode (if required)
✓ Take latest backup of the database
✓ Restore the latest copy of the database to the new server
✓ Check database compatibility lever after restore
✓ Migrate all user logins and windows logins to new server
✓ Enable trustworthy database setting
✓ Verify the orphan users and fix the same
✓ Execute DBCC UPDATEUSAGE command to correct pages and row counts on migrated data
✓ Rebuild all indexes on newly migrated database
✓ Upgrade statistics on migrated database
✓ Recompile all stored procedures, functions and triggers with sp_recompile.
✓ Deploy your high availability and disaster recovery plans (if any)
✓ Test the application and correct errors (if any)
POST-MIGRATION PHASE
AFTER THE MIGRATION IS COMPLETE IT IS IMPORTANT TO PERFORM THE FOLLOWING TASKS:

❏ UPGRADE DATABASE COMPATIBILITY LEVEL: THE DATABASE COMPATIBILITY LEVEL NEEDS TO BE MANUALLY CHANGED
ON THE 2016 INSTANCE

❏ RUN DBCC CHECKDB WITH DATA_PURITY: CHECKS FOR INVALID DATA VALUES BASED ON COLUMN DATA TYPE

❏ RUN DBCC UPDATEUSAGE: CORRECTS PAGE COUNT INACCURACIES TO REFLECT ACCURATE INFORMATION WHEN USING
SP_SPACEUSED

❏ RUN SP_REFRESHVIEW: ENSURES THAT VIEWS ARE UP TO DATE

❏ UPDATE STATISTICS: BRINGS DATABASE STATISTICS ARE UP TO DATE TO ALLOW THE QUERY OPTIMIZER TO CHOOSE
THE BEST QUERY PLAN

❏ TAKE A FULL BACKUP OF THE DATABASE: MAKE SURE YOU CAN RECOVER THE DATABASE WITH ALL OF THE MIGRATION
EFFORTS
❏ POINT THE APPLICATION TO THE NEW DB SERVER IP (CONNECTION STRING ETC TO ALTERED BY THE
APPLICATION SUPPORT TEAM)

❏ RESTART NETWORK CONNECTIONS BETWEEN ALL STAKE HOLDING SERVERS (NETWORK TEAM)

❏ CHECK THE SQL SERVER ERROR LOG AND WINDOWS ERROR LOGS FOR ANY FAILURES.

❏ CONFIRM APPLICATION FUNCTIONALITY WITH END USERS.


SUMMARY:
THANK
YOU!

You might also like