Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

moving log files Expand / Collapse
Author
Message
Posted Saturday, July 27, 2013 8:57 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, March 14, 2014 8:02 AM
Points: 4, Visits: 73
Hi,
I'm quite new to this SQL admin stuff.

I need to move all the log files(user and system databases) on several sql 2008 servers to a new drive.

There are replication jobs set up on the servers.

Will moving the log files affect the replication?

My plan is:
1. Stop the replication jobs
2. change to Single-user mode
3. move the log files
4. restart the sql server.
5.change to muti-user mode

Will this work or do i have to remove the replication jobs and recreate them afterwards?

Regards Carlos
Post #1478284
Posted Saturday, July 27, 2013 9:09 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: 2 days ago @ 1:05 PM
Points: 2,834, Visits: 8,544
I haven't worked with replication in a while, but when I did, and wasn't sure about something critical, I created some test replication databases and tried things out there first. Set up a few dummy tables to replicate, and give it a try.

Moving the system database logs is a bit more involved. There are plenty of threads and documents on it.



Post #1478285
Posted Saturday, July 27, 2013 9:27 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, March 14, 2014 8:02 AM
Points: 4, Visits: 73
It's critical databases.
I will do some testing first.
Thanks for the quick answer.
Post #1478288
Posted Saturday, July 27, 2013 12:05 PM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 4:23 AM
Points: 5,886, Visits: 13,047
why are you moving the log files for the system databases, except perhaps for TempDB there is nothing to be gained by doing that, and a lot of potential heartache to be had.

Replication does not care where the log files are and you will have to quiesce the app to move the files anyway so I don't see any issues there, though I admit to not having done it.

you don't state how you are moving the log files but I strongly recommend using alter database..modify file along with offlining the database whilst you move the file, so there is no need to restart sql server to achieve that.

back the databases up first.


---------------------------------------------------------------------

Post #1478299
Posted Sunday, July 28, 2013 3:51 AM


SSC-Forever

SSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-ForeverSSC-Forever

Group: General Forum Members
Last Login: Today @ 8:31 AM
Points: 40,456, Visits: 36,912
Carlosql (7/27/2013)
My plan is:
1. Stop the replication jobs
2. change to Single-user mode
3. move the log files
4. restart the sql server.
5.change to muti-user mode


If you do that to the system databases, SQL won't start (though you won't be able to move the system DB's log files with SQL running). You do that to user databases, they'll come up recovery pending (though you won't be able to move the log files with SQL running)

The correct procedure for moving databases' log files does not involve single user at all. Other than for the system DBs (which you may want to leave alone), the procedure is:

Run ALTER DATABASE specifying the WITH MOVE to change the metadata saying where the log files are
Take the database offline (works fine for replicated DBs)
Move the actual files
Bring the database online.

You can do similar with TempDB, which is probably the only system DB that moving the files for is important (maybe MSDB), but with a restart of SQL instead of taking the DB offline.



Gail Shaw
Microsoft Certified Master: SQL Server 2008, MVP
SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

We walk in the dark places no others will enter
We stand on the bridge and no one may pass

Post #1478341
Posted Sunday, July 28, 2013 6:02 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Friday, March 14, 2014 8:02 AM
Points: 4, Visits: 73
Separating the data and log files are a company policy.
The servers are running i a virtual environment so I know there are no performance benefits.
I think i will leave the system log files alone.
Thanks!
//Carlos
Post #1478348
Posted Monday, July 29, 2013 4:31 AM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 4:23 AM
Points: 5,886, Visits: 13,047
the syntax you want to change the log file location is -

alter database dbname MODIFY FILE ( NAME = logical_file_name, FILENAME = ' new_path/os_file_name ' )


so
stop app
backup database
run alter database command
offline database
copy file to new location (copy rather than move in case of problems)
online database

delete old file once everything checks out OK


---------------------------------------------------------------------

Post #1478519
Posted Tuesday, July 30, 2013 2:48 AM
SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Friday, November 14, 2014 8:26 AM
Points: 2,894, Visits: 3,278
Separating the data and log files are a company policy


Once upon a time this policy did not exist. Then it got created.

You need another company policy that says 'Leave the data and log files of SQL Server system databases master, model, resource where they are put by the install process'.


Original author: SQL Server FineBuild 1-click install and best practice configuration of SQL Server 2014, 2012, 2008 R2, 2008 and 2005. 18 October 2014: now over 31,000 downloads.
Disclaimer: All information provided is a personal opinion that may not match reality.
Concept: "Pizza Apartheid" - the discrimination that separates those who earn enough in one day to buy a pizza if they want one, from those who can not.
Post #1478878
Posted Tuesday, July 30, 2013 10:33 AM
SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Yesterday @ 4:23 AM
Points: 5,886, Visits: 13,047
EdVassie (7/30/2013)
Separating the data and log files are a company policy


Once upon a time this policy did not exist. Then it got created.

You need another company policy that says 'Leave the data and log files of SQL Server system databases master, model, resource where they are put by the install process'.


+1

I would go further, the default location as part of the install is C:\program files\.... that is rarely the best place for your system databases so designate a drive for them and the policy would be 'system database files are placed on drivedirectory (your choice here) as part of the install process and never shall they be moved.'


---------------------------------------------------------------------

Post #1479102
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse