Click here to view and discuss this page in DocCommentXchange. In the future, you will be sent there automatically.

SAP Sybase SQL Anywhere 16.0 » SQL Anywhere Server - Database Administration » High availability and read-only scale-out systems » Database mirroring » Tutorial: Creating a database mirroring system

 

Lesson 3: Switching roles in a database mirroring system

Force the servers to switch roles without stopping the mirroring system.

Prerequisites

This lesson assumes that you have completed all preceding lessons. See Lesson 1: Creating a database mirroring system.

This lesson assumes that you have the roles and privileges listed in the Privileges section at the start of this tutorial: Tutorial: Creating a database mirroring system with multiple databases that share an arbiter server.

 Task
  1. Connect to the primary server. Run the following command:

    dbisql -c "UID=DBA;PWD=sql;SERVER=mirror_demo_primary;HOST=localhost:6871,localhost:6872" 
  2. Use the ServerName database server property to determine the name of the server that is currently the primary server.

    SELECT PROPERTY( 'ServerName' );

    The name of the primary server appears (mirror_server1).

    The ServerName database server property returns the real name, not the alternate name, of the server.

  3. Initiate the failover by executing the ALTER DATABASE SET PARTNER FAILOVER statement

    ALTER DATABASE SET PARTNER FAILOVER;

    Connections to the primary server close. The database server messages window for server2 displays a message indicating that it is the new primary server:

    Accessibility description
  4. Connect to the current primary server:

    dbisql -c "UID=DBA;PWD=sql;SERVER=mirror_demo_primary;HOST=localhost:6871,localhost:6872"
  5. Execute the following statement to verify that the server that was previously acting as the mirror server (mirror_server2) is now acting as the primary server:

    SELECT PROPERTY ( 'ServerName' );
  6. Execute the following statement to verify that all transactions were mirrored to the mirror database:

    SELECT * FROM test;
  7. Disconnect from Interactive SQL.

Results

The partner servers switch roles.

 See also