Tuesday, 16 April 2013

some of the topics that will be covered in future..

Due to sudden sheer interest in VMware and windows administration, some of the main topics were jotted down.
Future blogs will cover each of them.


move SQL Server from Standalone to Cluster environment

For each file to be moved, run the following statement.
ALTER DATABASE database_name MODIFY FILE ( NAME = logical_name , FILENAME = 'new_path\os_file_name' );
Stop the instance of SQL Server or shut down the system to perform maintenance.
Move the file or files to the new location.
Restart the instance of SQL Server or the server.
Verify the file change by running the following query.
SELECT name, physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID(N'<database_name>');
If a file must be moved because of a hardware failure, follow these steps to relocate the file to a new location. This procedure applies to all system databases except the master and Resource databases.
If the database cannot be started, that is it is in suspect mode or in an unrecovered state, only members of the sysadmin fixed role can move the file.
Stop the instance of SQL Server if it is started.
Start the instance of SQL Server in master-only recovery mode by entering one of the following commands at the command prompt. The parameters specified in these commands are case sensitive. The commands fail when the parameters are not specified as shown.
  • For the default (MSSQLSERVER) instance, run the following command:
    NET START MSSQLSERVER /f /T3608
    
  • For a named instance, run the following command:
    NET START MSSQL$instancename /f /T3608
For each file to be moved, use sqlcmd commands or SQL Server Management Studio to run the following statement.
ALTER DATABASE database_name MODIFY FILE( NAME = logical_name , FILENAME = 'new_path\os_file_name' )
Stop the instance of SQL Server. For example, run NET STOP MSSQLSERVER.
Move the file or files to the new location.
Restart the instance of SQL Server. For example, run NET START MSSQLSERVER.
Verify the file change by running the following query.
SELECT name, physical_name AS CurrentLocation, state_desc
FROM sys.master_files
WHERE database_id = DB_ID(N'<database_name>');
The purpose of this blog is not to tell what is already available :) I have a little trick to make things faster. Here we go…
First lets understand what we are doing and what’s the reason behind it. Whenever we start SQL Server, it goes to registry to find out location of master.mdf, maslog.ldf and ErrorLog files. Once all three are located, logging would start and master database would be opened to know location of other databases mdf and ldf files.
Take Standalone machine out of network. Make sure there is no entry for host name or IP address anywhere in the network.
Install SQL server in clustered environment and keep IP address and Virtual Server name same.
While installing make sure that folder structure is same as standalone instance.
Bring clustered SQL to same patch level as standalone SQL. This reason of this is that system databases can’t be reused across builds.
make sure that you can do failover.
Take SQL Server offline, keep a backup of DATA folder to safe location
Now, take the DATA folder from Standalone server (Copy all folders which have mdf, ndf and ldf files) and put this in DATA folder on clustered SQL Server. Verify that all the files are at same location which was there on Standalone server.
Bring SQL server online. If there are failures then start looking at Error Logs and troubleshoot further.