Moving log files in publishing and replication mode in SQL Server Series

Source: Internet
Author: User

I. Cause

With the increasing number of database files, the storage space on the disk becomes increasingly insufficient. To improve the performance of the database, migration of database log files is particularly important, that is, the primary and log files of the database are stored on different disks.

 

Ii. Try migration

The first method to migrate log files is the Detach and Attach methods. You can use either of the following methods:

1. Script

SP_DETACH_DB 'DB NAME', 'TRUE'

You will find the following errors

2. Use the SSMS Manager

Note the Status and Message columns.

I checked MSDN and found that this is the case. If the database has publishing replication, it cannot be completed through Detach and Attach (unless you remove publishing replication first ).

Iii. Problem Solving

1. Run the following command to obtain basic database information:

SP_HELPDB DB_NAME

2. Execute the following script

ALTER DATABASE DB_NAMEMODIFY FILE (NAME =DB_NAME_log,              FILENAME = 'D:\DB_Log\DB_NAME_log.ldf');

3. Stop the replication log reader agent job and distribution agent job

4. Offline database publishing (if the time is too long, you can stop the SQL Server service and then restart the service so that all database connections and operations can be quickly stopped)

ALTER DATABASE DB_NAME SET OFFLINE

5. Move the log file to Step 1 (Directory D: \ LMS_DB \)

6. Publish database Online

ALTER DATABASE DB_NAME SET ONLINE;

7. Start two jobs stopped in step 1

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.