Sunday, March 24, 2013

Database Mirroring step by step

Database Mirroring step by step



Step 1

Create MirrorDB in the source database (called as Principal database), for which we are going to start mirroring.

mirror1


mirror2
Step 2 

Create a backup of the MirrorDB in the source SQL Server (Principal database) & restore it in the destination server with the same name. Make sure to restore the database with NORECOVERY. The destination server MirrorDB is called as Mirror database.

mirror3

mirror4




mirror5

mirror6

mirror7

mirror9
  
Step 3

As shown in the below screen, right click on the database, select properties & select Mirroring. Select Configure Security to configure mirroring for the required database.
Follow the screen shots as given below.

 Note that here I do not have a Witness server, & hence select “NO” for include Witness server option.
  mirror10
 mirror11
mirror12
 mirror13
Step 4
Select the Mirror Server Instance as shown below & click connect. Here we have to specify the destination, i.e. Mirror database server’s credentials to connect.
 mirror14
Step 5
Leave service accounts for both Principal & Mirror blank, follow the remaining screen shots.
mirror15
mirror16
mirror17
Step 6 
Click on Start Mirroring to start the mirroring from Principal database to Mirror database.
  mirror18
Step 7

As you can see in the below screen shot, the status is, the databases are fully Synchronized.
mirror19
Step 8 
The MirrorDB in the source server is now marked as Principal, Synchronized.
mirror20

Step 9 
The MirrorDB in the destination server is now marked as Mirror, Synchronized (Restoring)
mirror21

Step 10

You can do manual failover as shown below, by selecting Failover option.
mirror22
mirror23b
Step 11

The Principal database is now changed to Mirror & the Mirror is changed to Principal as shown in the below screen shots.
mirror23
mirror24
Mirroring is a simple process & if failed we can easily reset it up, by restoring the latest backup of the source in the destination & reconfigure Mirroring.

The following tutorial explains you the backing up and restoration of your MS SQL Server 2008 Database using the Microsoft SQL Server Management Studio. Cloud Hosting ServersMicrosoft SQL Server Management Studio Express (SSMSE) which is an free open source graphical management tool which can be used to manage your SQL Server 2008 Express Edition. You can use these backups later if a disaster strikes. It is always better to backup your database, because you never know if the information is lost or the database goes corrupt. The backup file you download will need to be in .bak file extension. Database stored on the shared servers, the backups will be generated on the server itself. If you wish to have a copy of your server backup, then you may need to contact the windows support team. In order to backup your MS SQL Server 2008 Database on your windows dedicated server hosting platform, follow the steps shown below: First, you need to configure the Microsoft SQL Server Management Studio on your local machine. If you don’t have it, you can download it from the following location. http://www.microsoft.com/downloads/en/details.aspx?familyid=6053C6F8-82C8-479C-B25B-9ACA13141C9E&displaylang=en Step 1: Open your Microsoft SQL Server Management Studio, whichever you prefer, standard or express edition. Step 2: Using your Database Username and Password, simply login to your MS SQL server database. Step 3: Select the database >> Right-click >> Tasks >> Back Up [as shown in the image below]: Backup MS SQL Server 2008 Database Once you click on the “Backup” the following Backup Database window will appear [as shown in the image below]: Backup MS SQL Server 2008 Database Folow Step 2 Step 4: Select the following options: Backup type: Full Under Destination, Backup to: Disk Step 5: Now, by clicking on the “Add” button the following window will appear to select the path and file name for the database backup file [as shown in the image below]: Backup MS SQL Server 2008 Database - Select Backup Destination Step 6: Select the destination folder for the backup file and enter the “File name” with .bak extension [as shown in the image below]: Backup MS SQL Server 2008 Database - Locate A Database Files Cloud ComputingMake sure you place your MS SQL database .bak file under the MSSQL backup folder. Step 7: Hit the OK button to finish the backup of your MS SQL Server 2008 Database. Upon the successful completion of database backup, the following confirmation window will appear with a message “The backup of database “yourdatabasename” completed successfully. [as shown in the image below]: Backup MS SQL Server 2008 Database - Confirmation Screen Following the above shown steps, you will be able to create a successful backup of your MS SQL Server 2008 Database into the desired folder. How to Restore MS SQL Server 2008 Database Backup File ? In order to restore a database from a backup file, follow the steps shown below: Step 1: Open your Microsoft SQL Server Management Studio Express and connect to your database. Step 2: Select the database >> Right-click >> Tasks >> Restore >> Database [as shown in the image below]: Restore MS SQL Server 2008 Database Step 3: The following “Restore Database“ windows will appear. Select “From device” mentioned under the “Source for restore” and click the button infront of that to specify the file location [as shown in the image below]: Restore MS SQL Server 2008 Database - Step 2 Step 4: Select the option “Backup media as File” and click on the Add button to add the backup file location [as shown in the image below]: Restore MS SQL Server 2008 Database - Specify Backup Step 5: Select the backup file you wish to restore and Hit the OK button [as shown in the image below]: Restore MS SQL Server 2008 Database Locate The Backup File That’s it! You will get the confirmation windows with a message “The restoration of database “yourdatabasename” completed successfully.” Now you know the procedure of backing up and restoring MS SQL Server 2008 Database.



The following tutorial explains you the backing up and restoration of your MS SQL Server 2008 Database using the Microsoft SQL Server Management Studio.

Microsoft SQL Server Management Studio Express (SSMSE) which is an free open source graphical management tool which can be used to manage your SQL Server 2008 Express Edition. You can use these backups later if a disaster strikes. It is always better to backup your database, because you never know if the information is lost or the database goes corrupt.
The backup file you download will need to be in .bak file extension. Database stored on the shared servers, the backups will be generated on the server itself. If you wish to have a copy of your server backup, then you may need to contact the windows support team.
In order to backup your MS SQL Server 2008 Database on your windows dedicated server hosting platform, follow the steps shown below:
First, you need to configure the Microsoft SQL Server Management Studio on your local machine. If you don’t have it, you can download it from the following location.
http://www.microsoft.com/downloads/en/details.aspx?familyid=6053C6F8-82C8-479C-B25B-9ACA13141C9E&displaylang=en
Step 1: Open your Microsoft SQL Server Management Studio, whichever you prefer, standard or express edition.
Step 2: Using your Database Username and Password, simply login to your MS SQL server database.
Step 3: Select the database >> Right-click >> Tasks >> Back Up [as shown in the image below]:
Backup MS SQL Server 2008 Database
Once you click on the “Backup” the following Backup Database window will appear [as shown in the image below]:
Backup MS SQL Server 2008 Database Folow Step 2
Step 4: Select the following options:
  1. Backup type: Full
  2. Under Destination, Backup to: Disk
Step 5: Now, by clicking on the “Add” button the following window will appear to select the path and file name for the database backup file [as shown in the image below]:
Backup MS SQL Server 2008 Database - Select Backup Destination
Step 6: Select the destination folder for the backup file and enter the “File name” with .bak extension [as shown in the image below]:
Backup MS SQL Server 2008 Database - Locate A Database Files
Cloud ComputingMake sure you place your MS SQL database .bak file under the MSSQL backup folder.
Step 7: Hit the OK button to finish the backup of your MS SQL Server 2008 Database. Upon the successful completion of database backup, the following confirmation window will appear with a message “The backup of database “yourdatabasename” completed successfully. [as shown in the image below]:
Backup MS SQL Server 2008 Database - Confirmation Screen
Following the above shown steps, you will be able to create a successful backup of your MS SQL Server 2008 Database into the desired folder.
How to Restore MS SQL Server 2008 Database Backup File ?
In order to restore a database from a backup file, follow the steps shown below:
Step 1: Open your Microsoft SQL Server Management Studio Express and connect to your database.
Step 2: Select the database >> Right-click >> Tasks >> Restore >> Database [as shown in the image below]:
Restore MS SQL Server 2008 Database
Step 3:  The following “Restore Database“ windows will appear. Select “From device” mentioned under the “Source for restore” and click the button infront of that to specify the file location [as shown in the image below]:
Restore MS SQL Server 2008 Database - Step 2
Step 4: Select the option “Backup media as File” and click on the Add button to add the backup file location [as shown in the image below]:
Restore MS SQL Server 2008 Database - Specify Backup
Step 5: Select the backup file you wish to restore and Hit the OK button [as shown in the image below]:
Restore MS SQL Server 2008 Database Locate The Backup File
That’s it! You will get the confirmation windows with a message “The restoration of database “yourdatabasename” completed successfully.” Now you know the procedure of backing up and restoring MS SQL Server 2008 Database.

A Step by Step guide to installing SQL Server 2008 PART 2

STEP 13 : Server Configuration
This step allows you to set up the service accounts that will be used to run SQL Server. If you have created Windows NT or Active Directory accounts for use with services, use these. If not, then just to get the installation up and working, use the built-in Network Service account for all three services listed (this account does not require a password).
This allows SQL Server to start up after installation. However, it can be easily changed later to another account through the Services applet (Control Panel -> Administrator Tools -> Services):
In addition, remember to change the Startup Type to Automatic, for all three services. This automatically starts the SQL Server database engine, SQL Agent and SQL Browser services when the server is re-booted. The first service runs the SQL Server database engines executable process. The other two services allow scheduled jobs to run after installation (and after a re-boot), and allow the SQL Server to be found by clients on the network.
Do not worry about changing the collation tab, unless there is a specific requirement for anything other than the default collation sequence. Finally, click on Next. STEP 14 : Database Engine Configuration – Account Provision
This screen allows you to set up database engine security.
Change the Authentication Mode to Mixed Mode unless you are certain you only need Windows-only authentication.
  • Many third party applications rely on SQL Server logins to operate correctly, so if you are setting up a server for a third party application, rather than one developed in-house, enabling Mixed Mode authentication is a good idea.
If you pick Mixed Mode security, you must also enter a password for the sysadmin account (sa). Enter and confirm a secure password for the sa account and keep it somewhere safe. Do not give it to any one you do not want to have access to the SQL Server.
Note that you MUST also provide a Windows NT account on the local machine as a SQL Server administrator. If you do not want Windows system administrators to be able walk up to the box and login to SQL Server, create a new, local, dummy Windows user and add this account instead. Otherwise, add in the local administrator account, or your own Windows account on the domain in which the SQL Server will reside. STEP 15 : Database Engine Configuration – Data Directories
Click on the Data Directories tab.
Change the directories to specify which drives in your system will be used for the various types of database files. Generally it’s advisable to put the User database directory and User log directory on separate physical drives for performance, but it will depend on how Windows has been configured and how many disk drives you have available.
If you are installing on a single drive laptop or desktop, then simply specify:
Data root directory C:\Program Files\Microsoft SQL Server
User database directory C:\Data
User log directory C:\Logs
Temp DB directory C:\TempDB
Temp Log directory C:\TempDB
Backup directory C:\Backups
Do not click on the FILESTREAM tab unless you know you need to change these options, as it is not generally required for most installations, but can easily be changed by using sp_configure 'filestream_access_level', ''after SQL Server has been installed. Click on Next.
STEP 16 : Error Usage Reporting This screen simply asks if you want to send error information to Microsoft and can safely be skipped if you do not want to share any information.

Click boxes if you want to help Microsoft help you.
Click on Next again… STEP 16 : Installation Rules
This screen simply checks if there are any processes or other installations running which will stop the installation of SQL Server 2008.
Click on Next again – you’re almost ready to install:
STEP 17 : Ready to Install This screen summarises what you are about to install and gives you a last chance to cancel or change anything that’s wrongly configured:
Check that what’s being installed is what you want and then click on Install when you’re sure you want to start the installation process:
Installation Progress SQL Server 2008 will now install. How long it takes depends on the speed of your machine, what load it’s under, the installation media (CD is slower) and what you’ve chosen to install.
…More Installation Progress

... and Finally
Finally, the installation will complete:
...and the following dialog box will appear:
Click on OK, the machine will NOT reboot.
The following will appear:
…followed by:
Click on the Next button again... STEP 18 : Installation Complete
The following screen appears:
It may be worth clicking on the installation log at the top of the screen to check everything’s gone as expected. Not that this is MUCH smaller than the usual SQL Server installation log files of old. Finally, click on the Close button. The following dialog will appear:
Click on OK – your server will NOT re-boot at this point.
The dialog box will disappear and you will be returned to the Installation Center:
Click on the Close button (the “x”) in the top right of the screen.
Finally, manually reboot your machine to complete the SQL Server 2008 installation. Top Tips :
How to check that SQL Server 2008 has installed correctly Here are a short number of post-installation checks which are useful to perform after re-booting your new SQL Server. You don’t have to run these, and there are other ways to check, but they are very useful for non-DBAs to be sure that the installation is basically sound and a connection can be made to the new SQL Server before handing it over to someone else.
Check 1: Has the SQL Server Service Started? Check SQL Server 2008 has started.
Check 2: Does Management Studio Work?
Check Management Studio works by firing it up.
Click on NO when you see this dialog box:

Check 3: Can you run a basic query against the new SQL Server? Check SQL Server works by running a simple query from Management Studio:
Enter the query shown below and hit F5 to run it:
Check 4: Is SQL Server Agent Running?
Check SQL Server Agent is running for scheduled jobs. There should be a green arrow next to the SQL Server Agent database symbol (it’s small, you might have to look hard):
Check 5: Can SQL Server be seen from the Network? Check that the new SQL Server can be seen from another SQL Server on the same domain by running isql –L (or osql –L):
If you can’t see the new SQL Server in this list, check that the SQL Server Browser service is started on the machine where you have just installed SQL Server. Check 6: Has the TCP/IP network protocol library been enabled on the server?
If the browser service is started but you still cannot connect to the server, click on Start ->Programs -> SQL Server 2008 -> SQL Server Configuration Manager (on the server where SQL Server’s just been installed)
The SQL Server Configuration Manager window opens.
Click on the SQL Server Network Configuration node and expand it. In the example below, we have MSSQLSERVER (a base instance of SQL Server), and SQLEXPRESS showing as installed.
If in doubt, click on Protocols for MSSQLSERVER.
In the above screenshot, the TCP/IP network protocol library is disabled. We need to enable it in order that remote servers can talk to the newly installed SQL Server.
  • A word of explanation : In most installations, Named Pipes can be ignored, unless there is a requirement for it. In virtually all environments, VIA can also be ignored as this protocol requires a special network card. Shared memory is the “local” protocol that SQL Server uses when talking to a client application on the same server as itself, for example when SQL Server Management Studio connects to it. It is usually best to leave this enabled.
You will need the TCP/IP protocol enabled if you need to connect to your new SQL Server from a remote client or another server via TCP/IP, which is what most networks use.
If it shows as DISABLED (above), double click on the TCP/IP protocol line, and the following window will appear:
Ensure that Enabled is set to Yes, and click on OK.
The following warning will appear:
Click on OK, and you will be returned to the Configuration Manager window, where TCP/IP will now be shown as enabled:
Go back to the Services applet, and re-start the MSSQLSERVER service so that the TCP/IP protocol can be used to connect to your new SQL Server. Then try to connect to it again from a remote machine.
If you have experienced problems with the previous connectivity tests, you should now be able to repeat at least some of them successfully.