SQL Server system database migration


Label:


Category: SQLServer Database Migration

First, the meaning of migration:

1. Generally, move other partitions from the C drive;

2. Move other hard disks from this hard disk, and the database still starts normally;

3. Prepare for general database migration;

 

2. System database migration The main database to be migrated

The first category: tempdb, model, msdb

The second category: master, (resource optional)

 

3. Migration steps:

 1, master database

 Generally, after the installation of the default SQlServer database is completed, the four system databases (master, model, msdb, tempdb) of SQL Server will be automatically installed in the installation path, that is, in the ProgramFIles folder of the system disk. The problem is that most database servers will install the database on the same disk (raid1) in order to take care of performance, cost and high availability at the same time. Usually this disk (Raid1) is not necessarily used. On the 15k SAS, some only use 10k SAS. What’s more, for the cost, it is enough to install two 7.2k sata. In addition, the Raid1 array itself has a very strong read performance, but write into an array form with rather poor performance. Therefore, it is very unfavorable for the system database, especially the tempdb database, and it will definitely affect the performance of the entire SQL Server.

 Therefore, migrating the entire system database to an array with higher performance is a basic solution to solve the hardware performance bottleneck.

 Specifically, how to migrate the system database to other partitions (using sql2008 R2 as an example):

  1. First migrate the master database, and the master database is also the core of the entire SQLServer database instance. All settings are stored in the master database. If there is a problem with the master database, the entire instance will be paralyzed.

    First open SQLServerConfiguration Manager, select the SQLServerServices node in the left list box, and then find the SQL Server service of the instance of the system database to be migrated in the left list box, such as SQLServer (MSSQLSERVER), stop the service of this instance, and then click to select "Properties" at the bottom, and switch to the "Aspect" tab, as shown in the figure:

SQL <wbr>Server System Database Migration



See "Startup Parameters", the parameters here are what we need to modify, as shown in the figure:

SQL <wbr>Server System Database Migration


Text finishing:

 

-dC:\Program Files\Microsoft
SQLServer\MSSQL10.MSSQLSERVER\MSSQL\DATA\master.mdf;
-eC:\Program Files\Microsoft SQL
Server\MSSQL10.MSSQLSERVER\MSSQL\Log\ERRORLOG;
-lC:\Program Files\Microsoft
SQLServer\MSSQL10.MSSQLSERVER\MSSQL\DATA\mastlog.ldf

 

After "-d" is the location of the master database file, "-e" is the location of the error log of the SQLServer instance, as for "-l"

This is where the master database log files are located.

   Modify the path of the data file and log file to the appropriate location. Generally, the location of the error log needs to be changed. For example, if the database file is stored in the SQLData folder of the D disk, and the log file is stored in the SQLLog folder of the E disk, the parameters are as follows :

-dD:\SQLData\master.mdf;-eC:\Program Files\Microsoft
SQLServer\MSSQL10.MSSQLSERVER\MSSQL\Log\ERRORLOG;-lE:\SQLLog\mastlog.ldf

Click "OK" to save and close the dialog.

  Then what needs to be done is to paste the database file and log file of the master database into the path defined by "startup parameters", and then start the service of the service instance.

   Notice:

    At this time, there may still be a situation where the SQL Server service cannot be started. Make sure that the configuration just now is accurate, and then it is the NTFS permission. If you do not use LocalSystem to start the SQL Server service, then after changing the storage path, you need to give the new The corresponding permissions of the drive letter or folder, so that the service can be started. It is recommended to directly give the corresponding account the "FullControl" permission. As for why, that is experience, and the reason must be asked by Microsoft. 
    The master database is even migrated.

 对于tempdb、msdb和model数据库
 1、修改文件路径
  --Move tempdb 
   ALTER DATABASE tempdbMODIFY
FILE(NAME='tempdev',FILENAME='D:\Database\tempdb.mdf'); 
   ALTER DATABASE tempdbMODIFY
FILE(NAME='templog',FILENAME='D:\Database\templog.ldf'); 
--Move model 
   ALTER DATABASE modelMODIFY
FILE(NAME='modeldev',FILENAME='D:\Database\model.mdf'); 
   ALTER DATABASE modelMODIFY
FILE(NAME='modellog',FILENAME='D:\Database\modellog.ldf'); 
--Move msdb 
   ALTER DATABASE msdbMODIFY 
FILE(NAME='MSDBData',FILENAME='D:\Database\msdbdata.mdf'); 
   ALTER DATABASE msdbMODIFY
FILE(NAME='MSDBLog',FILENAME='D:\Database\msdb_log.ldf');

 

2. Stop the SQL Server service;

3. Physically move the file to the file we want to define;

4. Start the SQL Server service;

5. The migration is complete.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=324809596&siteId=291194637
Recommended