In this configuration the primary and mirror servers each host three individual databases participating in mirroring systems. All three mirroring systems communicate with the same arbiter server. Each mirroring system uses a unique alternate server name that is specified using the -sn option. With this type of configuration, the primary, mirror, and arbiter servers can all run on separate computers.
If the primary server becomes unavailable, then a role switch occurs and the mirror server takes ownership of the databases. The mirror server becomes the primary server. The client must re-establish a connection to the primary server. The alternate server name is all that needs to be specified to re-establish the connection to the primary server. This configuration also has the ability to protect against failure of a single database. If a database running on the primary server becomes unavailable, then a role switch occurs and the mirror server takes ownership for the failed database. The mirror server becomes the primary server for only this database. The client must re-establish a connection to the primary server for this database using the alternate server name.
To set up a mirroring system with three databases and one arbiter server
Create the following directories:
Run the following commands from the c:\server1 directory:
dbinit one.db |
dbinit two.db |
dbinit three.db |
Create a transaction log for each database by running the following commands:
dbping -d -c "UID=DBA;PWD=sql;DBF=c:\server1\one.db" |
dbping -d -c "UID=DBA;PWD=sql;DBF=c:\server1\two.db" |
dbping -d -c "UID=DBA;PWD=sql;DBF=c:\server1\three.db" |
Copy the databases from the c:\server1 directory to the c:\server2 directory.
Start the arbiter server:
dbsrv11 -x tcpip(port=2640) -n arbiter -xa "AUTH=abc,def,ghi;DBN=one,two,three" -xf c:\arbiter\arbiterstate.txt -su sql |
Start the databases on server1:
dbsrv11 -n server1 -x tcpip(PORT=2638) -xf c:\server1\server1state.txt -su sql c:\server1\one.db -sn mirrortutorial_one -xp "partner=(ENG=server2;LINKS=tcpip(PORT=2639;TIMEOUT=1)); auth=abc;arbiter=(ENG=arbiter;LINKS=tcpip(PORT=2640;TIMEOUT=1)); mode=sync" c:\server1\two.db -sn mirrortutorial_two -xp "partner=(ENG=server2;LINKS=tcpip(PORT=2639;TIMEOUT=1)); auth=def;arbiter=(ENG=arbiter;LINKS=tcpip(PORT=2640;TIMEOUT=1)); mode=sync" c:\server1\three.db -sn mirrortutorial_three -xp "partner=(ENG=server2;LINKS=tcpip(PORT=2639;TIMEOUT=1)); auth=ghi;arbiter=(ENG=arbiter;LINKS=tcpip(PORT=2640;TIMEOUT=1)); mode=sync" |
Start the databases on server2:
dbsrv11 -n server2 -x tcpip(PORT=2639) -xf c:\server2\server2state.txt -su sql c:\server2\one.db -sn mirrortutorial_one -xp "partner=(ENG=server1;LINKS=tcpip(PORT=2638;TIMEOUT=1)); auth=abc;arbiter=(ENG=arbiter;LINKS=tcpip(PORT=2640;TIMEOUT=1)); mode=sync" c:\server2\two.db -sn mirrortutorial_two -xp "partner=(ENG=server1;LINKS=tcpip(PORT=2638;TIMEOUT=1)); auth=def;arbiter=(ENG=arbiter;LINKS=tcpip(PORT=2640;TIMEOUT=1)); mode=sync" c:\server2\three.db -sn mirrortutorial_three -xp "partner=(ENG=server1;LINKS=tcpip(PORT=2638;TIMEOUT=1)); auth=ghi;arbiter=(ENG=arbiter;LINKS=tcpip(PORT=2640;TIMEOUT=1)); mode=sync" |
After starting server2, the server1 database server messages window shows that server1 is the primary server in the mirroring system for databases one, two, and three. The messages also indicate that the mirror databases for one, two, and three (partners) are connected to server1.
The arbiter messages show that both server1 and server2 are connected.
Run the following command to start Interactive SQL and connect to database one on the primary server:
dbisql -c "UID=DBA;PWD=sql;ENG=mirrortutorial_one;LINKS=TCPIP" |
Add sample data to the SQL Anywhere sample database by executing the following statements:
CREATE TABLE test (col1 INTEGER, col2 CHAR(32)); INSERT INTO test VALUES(1, 'Hello from server1'); COMMIT; |
Determine which database server you are connected to by executing the following statement:
SELECT PROPERTY( 'ServerName' ); |
The name of the primary server appears.
Disconnect from Interactive SQL.
Initiate failover. You can do this by stopping the primary server in one of the following ways:
dbstop -y -c "UID=DBA;PWD=sql;ENG=server1" |
If a warning message appears indicating that the database server still has one connection, click Yes to shut it down.
The arbiter database server messages window displays a message indicating that the primary server is disconnected.
The database server messages window for server2 displays a message indicating that it is the new primary server:
Restart Interactive SQL by running the following command:
dbisql -c "UID=DBA;PWD=sql;ENG=mirrortutorial_two;LINKS=tcpip" |
Execute the following statement to see that you are now connected to the mirror server:
SELECT PROPERTY ( 'ServerName' ); |
Execute the following statement to verify that all transactions were mirrored to the mirror database:
SELECT * FROM test; |
Disconnect from Interactive SQL, and then click Shut Down on the database server messages window for the arbiter and server2 database servers.
Send feedback about this page via email or DocCommentXchange | Copyright © 2008, iAnywhere Solutions, Inc. - SQL Anywhere 11.0.0 |