moving log files

  • 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

  • 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.

  • It's critical databases.

    I will do some testing first.

    Thanks for the quick answer.

  • 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.

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

  • 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
  • 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

  • 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

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

  • 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: https://github.com/SQL-FineBuild/Common/wiki/ 1-click install and best practice configuration of SQL Server 2019, 2017 2016, 2014, 2012, 2008 R2, 2008 and 2005.

    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

  • 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.'

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

Viewing 9 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic. Login to reply