Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


moving log files


moving log files

Author
Message
Carlosql
Carlosql
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 95
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
homebrew01
homebrew01
SSCrazy
SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)SSCrazy (3K reputation)

Group: General Forum Members
Points: 2980 Visits: 9071
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.



Carlosql
Carlosql
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 95
It's critical databases.
I will do some testing first.
Thanks for the quick answer.
george sibbald
george sibbald
SSCertifiable
SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)

Group: General Forum Members
Points: 6348 Visits: 13687
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.

---------------------------------------------------------------------
GilaMonster
GilaMonster
SSC-Forever
SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)SSC-Forever (47K reputation)

Group: General Forum Members
Points: 47311 Visits: 44392
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, MVP, M.Sc (Comp Sci)
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


Carlosql
Carlosql
Forum Newbie
Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)Forum Newbie (4 reputation)

Group: General Forum Members
Points: 4 Visits: 95
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
george sibbald
george sibbald
SSCertifiable
SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)

Group: General Forum Members
Points: 6348 Visits: 13687
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

---------------------------------------------------------------------
EdVassie
EdVassie
Hall of Fame
Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)Hall of Fame (3.2K reputation)

Group: General Forum Members
Points: 3152 Visits: 3820
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 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005. 1 Dec 2016: now over 39,000 downloads.
Disclaimer: All information provided is a personal opinion that may not match reality.
Quote: "When I give food to the poor they call me a saint. When I ask why they are poor they call me a communist." - Archbishop Hélder Câmara
george sibbald
george sibbald
SSCertifiable
SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)SSCertifiable (6.3K reputation)

Group: General Forum Members
Points: 6348 Visits: 13687
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.'

---------------------------------------------------------------------
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search