Supporting MS SQL Server Failover Using Database Mirroring



Similar documents
Migrating from DAW s CK for MS SQL to Mertech s MS SQL Driver

SQL Server Mirroring. Introduction. Setting up the databases for Mirroring

Understanding Evolution's Architecture A Technical Overview

Configure SQL database mirroring

Sophos for Microsoft SharePoint startup guide

Using SQL Database Mirroring to Improve Citrix XenApp Server Farm Disaster Recovery Capabilities

HELP DOCUMENTATION E-SSOM BACKUP AND RESTORE GUIDE

Lab 07: Configuring High Availability and Disaster Recovery in Microsoft Lync Server 2013

HELP DOCUMENTATION E-SSOM BACKUP AND RESTORE GUIDE

Installing RMFT on an MS Cluster

Microsoft SQL Server 2005 Database Mirroring

High Availability Solution Database Mirroring in SQL Server 2008 R2. About The Writer

1 of 10 1/31/2014 4:08 PM

ISAM TO SQL MIGRATION

Administering and Managing Log Shipping

Moving the TRITON Reporting Databases

Module 07. Log Shipping

Using DBMoto 7 in a Microsoft Windows Cluster

Migrating MSDE to Microsoft SQL 2008 R2 Express

SafeCom G2 Enterprise Disaster Recovery Manual

Configuring High Availability and Disaster Recovery in Microsoft Lync Server 2013

Availability Guide for Deploying SQL Server on VMware vsphere. August 2009

BrightStor ARCserve Backup for Windows

Database Mirroring: High Availability (HA) and Disaster Recovery (DR) Technology

Citrix EdgeSight for Load Testing User s Guide. Citrix EdgeSight for Load Testing 3.8

Installing SQL Express. For CribMaster 9.2 and Later

HP Device Manager 4.6

Microsoft SQL Replication

How To Create An Easybelle History Database On A Microsoft Powerbook (Windows)

XenDesktop 5 Database Sizing and Mirroring Best Practices

Citrix EdgeSight for Load Testing User s Guide. Citrx EdgeSight for Load Testing 2.7

Setup and configuration for Intelicode. SQL Server Express

VMware/Hyper-V Backup Plug-in User Guide

Enabling Remote Management of SQL Server Integration Services

Windows SharePoint Services Installation Guide

Implementing Microsoft SQL Server 2008 Exercise Guide. Database by Design

Database Mirroring & Snapshots SQL Server 2008

Dell Recovery Manager for Active Directory 8.6. Quick Start Guide

This article Includes:

SQL Server AlwaysOn (HADRON)

Changing Your Cameleon Server IP

SteelEye Protection Suite for Windows Microsoft Internet Information Services Recovery Kit. Administration Guide

Deploy App Orchestration 2.6 for High Availability and Disaster Recovery

Creating a New Database and a Table Owner in SQL Server 2005 for exchange@pam

EXPRESSCLUSTER X for Windows Quick Start Guide for Microsoft SQL Server Version 1

SQL Tuning and Maintenance for the Altiris Deployment Server express database.

Panorama High Availability

EMC NetWorker Module for Microsoft for Windows Bare Metal Recovery Solution

NTP Software File Auditor for Windows Edition

Technical Notes. EMC NetWorker Performing Backup and Recovery of SharePoint Server by using NetWorker Module for Microsoft SQL VDI Solution

QUANTIFY INSTALLATION GUIDE

3 Setting up Databases on a Microsoft SQL 7.0 Server

LockView 4.2 CompX Database & Network Configuration & Installation Manual

SQL Server 2012/2014 AlwaysOn Availability Group

ActiveImage Protector 3.5 for Hyper-V with SHR. User Guide - Back up Hyper-V Server 2012 R2 host and

Crystal Reports Installation Guide

Backup & Restore with SAP BPC (MS SQL 2005)

Non-Native Options for High Availability

Metalogix SharePoint Backup. Advanced Installation Guide. Publication Date: August 24, 2015

SolarWinds Migrating SolarWinds NPM Technical Reference

LockView CompX Database & Network Configuration & Installation Manual

Dell InTrust Preparing for Auditing Microsoft SQL Server

StarWind Virtual SAN Installation and Configuration of Hyper-Converged 2 Nodes with Hyper-V Cluster

Course Syllabus. Maintaining a Microsoft SQL Server 2005 Database. At Course Completion

Pharos Uniprint 8.4. Maintenance Guide. Document Version: UP84-Maintenance-1.0. Distribution Date: July 2013

KEYWORDS InteractX, database, SQL Server, SQL Server Express, backup, maintenance.

Course Syllabus. At Course Completion

Upgrading from Call Center Reporting to Reporting for Contact Center. BCM Contact Center

vcenter Configuration Manager Backup and Disaster Recovery Guide VCM 5.3

Attix5 Pro Disaster Recovery

VMware vcenter Configuration Manager Backup and Disaster Recovery Guide vcenter Configuration Manager 5.4.1

Windows Small Business Server 2003 Upgrade Best Practices

SharePoint Server for Business Intelligence

Upgrade Guide BES12. Version 12.1

BrightStor ARCserve Backup for Linux

Norman Secure Backup. SQL Backup Training Guide. Author: Arne Stieghorst Layout: Eva Langballe

CA ARCserve and CA XOsoft r12.5 Best Practices for protecting Microsoft SQL Server

SQL Server Training Course Content

SQL Server AlwaysOn. Michal Tinthofer 11. Praha What to avoid and how to optimize, deploy and operate.

WhatsUp Gold v16.3 Installation and Configuration Guide

Lepide Software. LepideAuditor for File Server [CONFIGURATION GUIDE] This guide informs How to configure settings for first time usage of the software

High Availability for VMware GSX Server

Privileged Access Management Upgrade Guide

PAINLESS MULTI-DBMS STRATEGY For Magic Developers

Upgrade Guide. McAfee Vulnerability Manager Microsoft Windows Server 2008 R2

Remote Management System

Microsoft File and Print Service Failover Using Microsoft Cluster Server

Xopero Backup Build your private cloud backup environment. Getting started

Install SQL Server 2014 Express Edition

SafeCom Smart Printing Administrator s Quick Guide

SAM 8.0 Backup and Restore Guide. SafeNet Integration Guide

Database Configuration Guide

Moving the Web Security Log Database

WhatsUp Gold v16.1 Database Migration and Management Guide Learn how to migrate a WhatsUp Gold database from Microsoft SQL Server 2008 R2 Express

Jet Data Manager 2012 User Guide

Microsoft SQL Server 2008 R2 Express Edition with Advanced Services Installation Guide

GO!NotifyLink. Database Maintenance. GO!NotifyLink Database Maintenance 1

Using MS-SQL Server with Visual DataFlex March, 2009

Technical Notes TECHNICAL NOTES. Release number 8.2 Service Pack REV 01. January, 2015

DocAve 6 High Availability

Transcription:

MERTECH DATA SYSTEMS, INC 18503 Pines Boulevard, Suite 312 Pembroke Pines, FL 33029, USA Tel: 1-954-585-9016 Fax: 1-866-228-1213 www.mertechdata.com Contents Supporting MS SQL Server Failover Using Database ing with Mertech Flex2SQL for MS SQL Server Overview How Does it Work? SQL Server Setup Using ing Support Contact Information 2006-2013 Mertech Data Systems, Inc. All rights reserved. This document is for informational purposes only. Mertech makes no warranties, expressed or implied, in this document. Microsoft, Windows, and SQL Server are registered trademarks of Microsoft Corporation DataFlex is a trademark of Data Access Worldwide, Inc. Other trademarks and trade names mentioned herein are the property of their respective owners.

Overview Microsoft introduced database mirroring in SQL Server 2005 to increase database availability. Database mirroring maintains two copies of a single database on different server instances. One instance is the primary or principal server, the other instance is the standby or mirror server. If the principal server goes down the mirror server can take over with no loss of committed data. Fast failover with minimal data loss has traditionally involved higher hardware cost and greater software complexity. Database mirroring, however, can fail over quickly with no loss of committed data, does not require proprietary hardware, and is easy to set up and manage. SQL Server 2005 SP1 or above is required to use mirroring. How Does it Work? All SQL Server databases record data changes in a transaction log before any changes are made to the actual database. In database mirroring, the principal server writes the transaction log buffer to disk and simultaneously sends it to a mirror server. The transaction log records are then replayed on the mirror server to keep the two database instances in sync. A third (optional) server witnesses the health of the principal and mirror servers to enable automatic failover. Optional Data Flow Server Roles The originating server, the one that sends the transaction log to the standby SQL Server instance. The principal database is available to an SQL client during normal operation. The standby SQL Server instance, the one that receives the transaction log from the principal server. The mirror database is not available to an SQL client unless the principal server is down and the mirror server has taken over. Partner The principal and mirror servers are considered partners in maintaining the mirrored database. Copyright 2013 Mertech Data Systems, Inc. All Rights Reserved. 2

The witness server's role is to allow the mirror server to recognize that the principal server is down and to take over. The witness server does not have a database of its own. The principal, mirror, and witness servers all send heartbeat messages to each other to monitor their connection status. If the partners become disconnected from each other, they rely on the witness to make sure that only one of them is currently serving the database. If a mirror server loses its connection to the principal server, the mirror server contacts the witness to determine whether the witness has lost its connection to the principal server: If the principal server is still connected to the witness, the principal server continues to serve the database while accumulating log records to send the mirror server when the partners reconnect. If the witness is also disconnected from the principal server, the mirror server initiates an automatic failover. All Servers Alive Remains in Charge Takes Over The requirement that at least two of the server instances be connected is known as quorum. Quorum makes sure that the database can only be served by one partner at a time. Copyright 2013 Mertech Data Systems, Inc. All Rights Reserved. 3

Operational Modes There are three operational modes in SQL Server mirroring: High Availability The High Availability operating mode supports maximum database availability with automatic failover to the mirror database if the principal database fails. It requires that you set safety to FULL and define a witness server as part of the database mirroring session. The database mirroring operation is synchronous, a transaction is not completed on the principal server until the principal server receives an acknowledgement from the mirror server that the transaction log record has been recorded. Once this occurs, the client application gets confirmation that the transaction was committed. A witness server is used to monitor the status of the principal and mirror servers. If the principal server becomes unavailable, and the mirror server and witness are connected, the mirror server can initiate take over. 2. Log 3. ACK 1. Update 4. Comitted High Protection The High Protection operating mode also has transactional safety set to FULL and the database mirroring operation is synchronous. However, there is no witness server as part of the mirroring session. In this mode only a manual failover is possible because the partners have no way to determine each other s status. 2. Log 3. ACK 1. Update 4. Comitted Copyright 2013 Mertech Data Systems, Inc. All Rights Reserved. 4

High Performance In the High Performance operating mode, transactional safety is OFF and the transfer of log records is asynchronous. The principal server does not wait for an acknowledgement from the mirror that all transaction log records have been recorded on the mirror. The mirror does its best to keep up with the principal, but it is not guaranteed at any point in time that all the most recent transactions from the principal will have been hardened in the mirror's transaction log. 3. Log 1. Update 2. Comitted Database ing Feature Support by SQL Server 2012 Enterprise Business Intelligence Standard Web Express with Advanced Services Express with Tools Express Yes Yes (Safety Full Only) Yes (Safety Full Only) only only only only Refer to Microsoft documentation for additional information and a description of feature support by server addition. Copyright 2013 Mertech Data Systems, Inc. All Rights Reserved. 5

SQL Server Setup Create the Databases The principal server, mirror server, and (optional) witness must be hosted by separate server instances. The principal and mirror server instances must be running on the same version and edition of SQL Server. The mirror database must have the same name as the principal database. All the database users should have logins on the mirror server. Our example uses SQL server instances, LEIA\MAIN and LEIA\MIRROR running SQL Server 2008. Enable FULL Recovery Mode Both databases must use the FULL recovery model. Log records that result from bulk-logged operations cannot be sent to the mirror database. Check to see if FULL recovery mode is enabled: Select name, recovery_model_desc FROM sys.databases WHERE name = 'main'; If not, set FULL recovery mode: USE master; ALTER DATABASE main SET RECOVERY FULL; Copyright 2013 Mertech Data Systems, Inc. All Rights Reserved. 6

You can also use SQL Server Management Studio: 1. In Object Explorer, click the server name to expand the server tree. 2. Right-click the database. 3. Select Properties. 4. Select Options in the Select a page pane. 5. Select Full Recovery model using the drop-down arrow. 6. Click OK. Create Endpoints Configure endpoints (port listeners) where the principal and mirror are going to establish communication. Endpoint: USE main; CREATE ENDPOINT ingendpoint_ STATE=STARTED AS TCP (LISTENER_PORT=10111) FOR DATABASE_MIRRORING (ROLE=PARTNER) -- Enabled as Partner only Endpoint: USE main; CREATE ENDPOINT ingendpoint_ STATE=STARTED AS TCP (LISTENER_PORT=10112) FOR DATABASE_MIRRORING (ROLE=ALL) -- enabled as or Partner To inspect your created endpoints: SELECT name, role_desc, state_desc FROM sys.database_mirroring_endpoints; Copyright 2013 Mertech Data Systems, Inc. All Rights Reserved. 7

Backup the Database Important: The principal and mirror backup (log and data) should be located in the same exact location (e.g. C:\backup\data.bak). Issue a full backup of the database and transaction log: USE main BACKUP DATABASE main TO DISK = 'C:\main_Data.bak' WITH FORMAT BACKUP LOG main TO DISK = 'C:\main_Log.bak' WITH FORMAT You can also use SQL Server Management Studio: 1. In Object Explorer, click the server name to expand the server tree. 2. Right-click the database. 3. Select Tasks Back Up. 4. In the Backup type list box, select Full. 5. Click Add, enter the backup file name, then click OK. Restore the Backup to the Restore the backup to the mirror server using the WITH NORECOVERY option. RESTORE DATABASE main FROM DISK='C:/main_data.bak' WITH REPLACE,NORECOVERY Also restore the log WITH NORECOVERY option. RESTORE LOG main FROM DISK='C:/main_Log.BAK' WITH NORECOVERY You can also use SQL Server Management Studio: 1. In Object Explorer, click the server name to expand the server tree. 2. Right-click the database. 3. Select Tasks Restore Database. 4. On the General page, use the Source section to specify the source and location of the backup sets to restore. 5. On the Options page, select Recovery state RESTORE with NORECOVERY. This mirror database is no longer available to open or make changes; it is now a mirror database and can only be used for mirroring. Copyright 2013 Mertech Data Systems, Inc. All Rights Reserved. 8

Enable the ing Session Setting up a database mirroring session requires a server network address for each of the server instances. Before you can specify a port in a server network address, the database mirroring endpoint must exist on the server instance To identify the port currently associated with database mirroring endpoint of a server instance: SELECT type_desc, port FROM sys.tcp_endpoints Start the database mirroring session on the mirror: ALTER DATABASE main SET PARTNER = 'TCP://127.0.0.1:10111' Start the database mirroring session on the principal: ALTER DATABASE main SET PARTNER = 'TCP://127.0.0.1:10112' Obtain general information: SELECT DB_NAME(database_id) AS 'DatabaseName', mirroring_role_desc, mirroring_safety_level_desc, mirroring_state_desc, mirroring_safety_sequence, mirroring_role_sequence, mirroring_partner_instance, mirroring_witness_name, mirroring_witness_state_desc, mirroring_failover_lsn FROM sys.database_mirroring WHERE mirroring_guid IS NOT NULL; Refer to Microsoft documentation for additional details. Copyright 2013 Mertech Data Systems, Inc. All Rights Reserved. 9

Using ing Support in Mertech Flex2SQL DataFlex developers using Mertech s Flex2SQL can take advantage of the SQL Server Database ing feature to develop high-availability applications. To use this feature, the developers need to use a new command, SET_MIRROR_SERVER in their login module. This identifies the mirrored server to the driver which in turns negotiates the communication with the server. If the principal server fails, the driver automatically connects to the mirror server and continues operation. This does not require any additional code in DataFlex to check for a lost connection. Syntax Note: Any non-committed transactions need to be retried by the application. A VDF application normally retries the transaction, but please consult the VDF manual for details. SET_MIRROR_SERVER to <Server name> <Main server> Example To make DataFlex work with mirroring and Mertech's driver, you can create a program that logs in, sets the mirror, and then executes your application. loginchain.src use mertech.inc string p1 p2 Load_Driver "SQL_DRV" // Set the Server SET_MIRROR_SERVER to "MACHINE\MIRROR" "main" If (Err) showln "Error setting failover Server" // Login into the main server login "MACHINE\MAIN" "user" "password" "sql_drv" cmdline p1 cmdline p2 chain (p1 + " " + p2) Compile the login program and run it: dfcomp loginchain.src dfrun logchain your_application_executable Note: The GET_MIRROR_SERVER command is also available. Syntax: GET_MIRROR_SERVER to <VAR>. Copyright 2013 Mertech Data Systems, Inc. All Rights Reserved. 10

The Flex2SQL automatic login dialog also has an option to set the mirror server and database: If you have a personalized login dialog, using the SET_MIRROR_SERVER command is the best option. Note: The mirror server and mirror database can also be provided as settings in the Mertech INI file. Testing Your ed Environment To verify that your Visual DataFlex application is running in a mirrored environment: 1. Shutdown the main server. 2. Start your application. A driver trace will show that your application logged into the mirror server. Copyright 2013 Mertech Data Systems, Inc. All Rights Reserved. 11

3. Examine stored data. 4. Make changes to stored data. 5. Restart the principal server. 6. Fail over to the principal server. ALTER DATABASE main SET PARTNER FAILOVER Copyright 2013 Mertech Data Systems, Inc. All Rights Reserved. 12

7. Examine the changes in SQL Server Manager. Conclusion Using SQL Server ing, you can ensure that your application is up 24/7. If your principal server goes down, failover to a standby server can occur automatically without any loss of data and transparently to your users. Mertech s Flex2SQL for MS SQL Server takes advantage of the MS SQL mirroring support and enables a DataFlex application to be used in a high-availability environment. Contact Information If you would like to know more about Mertech s products, please visit our web site at www.mertechdata.com or contact us at Corporate Headquarters Brazilian Subsidiary Mertech Data Systems, Inc. 18503 Pines Boulevard, Suite 312 Pembroke Pines, FL 33029 USA Tel: +1 (954) 585 9016 Fax: +1 (866) 228 1213 e-mail: sales@mertechdata.com Mertech Data Systems Brasil Ltda. Av. Yojiro Takaoka, 4.384 Cj. 2227, Alphaville Santana de Parnaiba, SP 06541-038 Brazil Tel: +55 (11) 4152 8433 Fax: +55 (11) 4152 8433 e-mail: mertechbrasil@mertechdata.com Copyright 2013 Mertech Data Systems, Inc. All Rights Reserved. 13