Installing Mirror Setup in a SQL Server 2012


SQL Server 2012 in a Mirror

Enable SQL Server for high availability by enabling them in a mirror setup, There are two modes of database mirroring – synchronous and asynchronous. With synchronous mirroring, transactions cannot commit on the principal until all transaction log records have been successfully copied to the mirror (but not necessarily replayed yet). This guarantees that if a failure occurs on the principal and the principal am mirror are synchronized, committed transactions are present in the mirror when it comes online – in other words, it is possible to achieve zero data loss.

Synchronous mirroring can be configured to provide automatic failover, through the use of a third SQL Server instance called the witness server (usually hosted on another physically separate server). The sole purpose of the witness is to agree (or not) with the mirror that the principal cannot be contacted. If the witness and mirror agree, that mirror can initiate failover automatically. If synchronous mirroring is configured with a witness, the operating mode is known as high-availability mode and povides a hot standby solution. When no witness is defined, the operating mode is known as high-safety mode, which provides a warm standby solution.

With asynchronous mirroring there is no such guarantee, because transactions can commit on the principal without having to wait for database mirroring to copy all the transaction’s log records. This configuration can offer higher performance because transactions do not have to wait, and it is often used when the principal and mirror servers are separated by large distances (that is, implying a large network latency and possible lower network bandwidth). Consequently, the operating mode is also known as high-performance mode and provides a warm standby solution.

If a failure occurs on the principal, a mirroring failöver occurs, either manually (in the high-performance and high-safety modes) or automatically (only in the high-availability mode). The mirror database is brought online after all the transaction log records have been replayed (that is, after recovery has completed). The mirror becomes the new principal and the applications can reconnect to it. The amount of downtime required depends on how long it takes for the failure to be detected and how much transaction log needs to be replayed before the mirror database can be brought online.

I created three VM’s and attached an extra disk. As was the case for the two domain controllers, and attach the disK, i removed some of info due to confidentiality, virtual machines for the two front-end servers, the two application servers and the three servers to be used by SQL Server. So let start and install .Net and go to Server Manager —>

select Manage —> Add Roles and Features, i used as sp_sql1

sp_sql

 

 

 

 

 

 

Next —>

sp_sql1

 

 

 

 

 

 

 

Next —>

sp_sql2

 

 

 

 

 

 

 

Next —>

sp_sql3

 

 

 

 

 

 

 

Next —>

Install .NET Framework 3.5 Features

sp_sql4

 

 

 

 

 

 

 

Next —>

sp_sql5

 

 

 

 

 

 

 

Next —>

sp_sql6

 

 

 

 

 

 

 

The installation has completed.

Download and attach media (run from DVD)

AttachDownload

 

 

 

 

 

 

SQL Server 2012 SP1 Enterprise Edition.

attach download next —> Run the Setup.exe efter couple of mins this show up this

menu

 

 

 

 

 

 

 

Off course select the New SQL Server stand-alone installation next —>

stand-alone installation

 

 

 

 

 

 

 

Efter support file installation enter product key

product key

 

 

 

 

 

 

 

Read & accept the terms and click Next —>

Accept the terms and click Next

 

 

 

 

 

 

 

Select SQL Server Feature Installation Next —>
My case I did not require SSAS, SSIS or SSRS, but i did select to install the mgm tools. If you need those tools in future you can always come back and install.

Feature Selection select

 

 

 

 

 

 

 

 

 

If all is green click Next even process will be blocked you 🙂

If all is green click Next.

 

 

 

 

 

 

 

Next —>

enough space for the installation

 

 

 

 

 

 

 

Enough space for the installation Next —>

I keep the default settings, but if you plan to use this server in a mirror setup – Default setting  I will recommend that you use a domain account. It will make setting up the security during the mirror configuration so much easier. The reason being that the local account on Server 1 does not know anything about the local account on Server 2.

account on Server 2

 

 

 

 

 

 

 

Just keep default setting values you can always change them later using the SQL Server Configuration Manager.
Database Engine Configuration dialog on the Server Configuration tab keep the default value for the Authentication Mode.  Authentication Mode Click Next.

Authentication Mode

 

 

 

 

 

 

 

Select the Data Directories change the Data root directory to the additional disk we attached, drives C, D, E, F:

DRIVES

 

 

 

 

 

 

 

You want to select both the Enable FILESTREAM for Transact-SQL access and the Enable FILESTREAM for file I/O access options.

Enable FILESTREAM

 

 

 

 

 

 

 

Next —>

Error Reporting option

 

 

 

 

 

 

 

If all is green in the Installation Configuration Rules. The installation will begin and it is take a time, all should be green then go next otherwise fixed error then click Next —>

green markers close

 

 

 

 

 
Next —>

Repeat the above process for the other two SQL Servers. Once all are installed we will have the primary, mirror partner and witness servers and we are ready to enable the mirror.

However, before actually do this, we need to install SharePoint. The reason is that the mirror is enabled by backing up and restoring databases, hence we need something “in” SQL so to speak. As I am a SharePoint Admin also.

Start a working SharePoint installed in to the primary SQL Server –SP-SQL1 (I given name to sp=SharePoint and SQL is SQL. To ensure that all SQL logins are present on the primary and mirror server, then must ensure that all databases are running with recovery mode set to FULL MODE. RDP into SP-SQL1 (the primary) and open op SQL Server Management Studio.

Note: there are no data connections to the SQL Server you may want to close down the SP site, use simple syntax, here we go!!!

USE master;
GO
ALTER DATABASE AdminContent SET RECOVERY FULL;

First take Full Backup the database

USE master;
GO

BACKUP DATABASE AdminContent
TO DISK = ‘D:BackUpAdminContent.bak’ –Path can be different i.e. e: or f:
WITH FORMAT
GO

And the log:

USE master;
GO

BACKUP LOG AdminContent
TO DISK = ‘D:BackUpAdminContent_log.bak’

GO

Copy the files to the mirror partner (SP-SQL2). Ensure they are placed in the same location, e.g. D:BackUp in the above example. It is not a requirement, but the syntax of the T-SQL is slightly different if the location is different. Connect to the mirror partner (SP-SQL2) from the open Management Studio or RDP into the server and open SSMS from here.

First we restore the database

USE master;
GO

RESTORE DATABASE AdminContent
FROM DISK = ‘D:BackUpAdminContent.bak’ –Path can be different i.e. e: or f:
WITH NORECOVERY
GO

And the log:

USE master;
GO

RESTORE LOG AdminContent
FROM DISK = ‘D:BackUpAdminContent_log.bak’
WITH FILE=1, NORECOVERY — with norecovery mode it must be.
GO

Now ready to enable mirroring in SSMS right click on one of the databases and select Tasks and then Mirrror. Don’t forget to Configure Security in Database Properties. First step in the configuration wizard is to decide whether or not a witness server, here is using with a witness server.  Good Luck

Let me know if you have any further question and comments is learning point.

Mehboob

Microsoft Certified Solutions Associate (MCSA)

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s