Page tree
Skip to end of metadata
Go to start of metadata

Purpose

The purpose of this page is to go through the necessary steps to apply MobiLink Agents and remote tasks to centralize the remote databases for synchronization.

Overview

The example in this document uses one consolidated database with two remote databases, all with matching schema. It also requires a working synchronization model with synchronization profiles for each remote database. The Initial Setup section goes through the steps for creating this environment.

Once this basic setup is complete, this document goes through the necessary steps in applying Mobilink Agents and remote tasks to centralize the remote databases for synchronization.

Requirements

It is expected that the reader is familiar with basic functionality and setup of MobiLink. A quick-start guide for MobiLink can be found in the Related Documents section..

Initial Setup

Creating the Databases and DSNs

First, the required databases need to be created with the appropriate schema.

Open a command prompt in the appropriate directory and run the folowing commands to create folders for the databases and MobiLink setup:

mkdir "Centralize Remotes Demo"
cd "Centralize Remotes Demo"
mkdir "ConsolidatedDB" "Remote1" "Remote2" "MobiLink Setup" "Debugging"

To create the databases, run the following from the Centralize Remotes Demo directory:

dbinit "ConsolidatedDB\Consolidated.db"
dbinit "Remote1\Remote1.db"
dbinit "Remote2\Remote2.db"

Now start each database:

dbsrv16 "ConsolidatedDB\Consolidated.db" -o "Debuggin\ConsLog.log" -zr ALL
dbsrv16 "Remote1\Remote1.db" -o "Debugging\Remote1Log.log" -zr ALL
dbsrv16 "Remote2\Remote2.db" -o "Debugging\Remote2Log.log" -zr ALL

Create a DSN for each newly created database to make connections easier. Open the ODBC Data Source Administrator and create a new System DSN for each database with the following settings:

  • Ensure it is a SQL Anywhere 16 DSN
  • Make the Data source name the same as the database name (i.e. Consolidated, Remote1, Remote2)
  • User ID is DBA; Password is sql
  • Action is Connect to a running database on this computer
  • Server name is the appropriate engine name hosting each database (from the previous commands, these servers should be named Consolidated, Remote1, and Remote2)

Test the connection to ensure each DSN is configured correctly. This could also be done using the Data Source Utility (dbdsn).

Note: There are two ODBC Administrators on 64-bit (x64) Windows systems:

   C:\Windows\SysWOW64\odbcad32.exe   (32-bit ODBC Administrator)
   C:\Windows\System32\odbcad32.exe   (64-bit ODBC Administrator)

Be sure to create DSNs that match the bitness of dbmlsync (the SQL Anywhere MobiLink Client) and the MobiLink Synchronization Server that are being run. You should also create the MobiLink project in the respective Sybase Central bitness that matches the DSN entries.

Preparing the Databases for MobiLink Synchronization

Using Interactive SQL, connect to each of the databases and run the following scripts:

// Run the create table commands on all databases

create table JobDescriptions (
     JobID integer,
     JobDescription char(100),
     primary key (JobID)
)

create table Employees (
     EmployeeID integer,
     EmployeeName char(30),
     EmployeeJobID integer,
     foreign key (EmployeeJobID) references JobDescriptions (JobID),
     primary key (EmployeeID)
)

// Run the insert commands on only the Consolidated

insert into JobDescriptions
     values (1000, 'Tech Support');
insert into JobDescriptions
     values (1001, 'Tech Writing');
insert into JobDescriptions
     values (1002, 'Engineering');

insert into Employees
     values (1, 'Mike', 1000);
insert into Employees
     values (2, 'Joe', 1001);
insert into Employees
     values (3, 'Bob', 1002);
commit;

Each database should now have a table schema that matches the following:

Setting up a MobiLink Project

A working synchronization model and a MobiLink Project are required for setting up agents and remote tasks. Open Sybase Central and connect to all 3 databases. Right-click MobiLink 16 and create a new project. Use Sybase Central and the provided wizards to step through the setup:

Call the project MobiLink Setup and store it in your MobiLink Setup folder. Click Next:

 

 Add a consolidated database to the project and use the appropriate DSN to connect to it, click Next:

 

Pick the consolidated tables you wish to synchronize (to create a new synchronization model), click Next:

 

Add a remote schema called 'Standard_Schema_1_0', click Next:

Choose 'SQL Anywhere' as the Remote database type and click Finish:

The wizard will prompt you to install the MobiLink System objects against the consolidated database. Click Yes:

A new Synchronization Model appears in the MobiLink Project listing in the left navigation tree.

Set both mappings to be download to remote only and click Save:

Finally, deploy the synchronization model. Open Synchronization Models in the MobiLink Setup and right-click on Deploy...

 

Choose the folder to deploy the script files: 

Change the network client details to reach the MobiLink server, if required. For a local test, the defaults are sufficient.

Specify a MobiLink user to use for synchronization (e.g. User: Remote1, Password: sql):

Specify the synchronization profile name (e.g. 'Synch_Remote'):

Choose to execute the deployment against the consolidated database and against an existing remote database. Provide the DSN for Remote1:

The files are generated in the target directory:

A summary screen is displayed. Click Finish:

Note that if an error states that the schema needs to be updated, right-click the Synchronization Model and choose to Update Schema. The wizard for this process is simple and should only take a few seconds.

Repeat the deployment steps for the second remote (Remote2) using MobiLink user "Remote2". Use "DSN=Remote2" when asked for a connection string to the remote database:

Test the Synchronization Setup

Before centralizing the system, ensure the underlying MobiLink setup is working correctly by testing a synchronization in Sybase Central. Start by right-clicking on the Synchronization Model and go to "Test...".

The test synchronization envronment is prepared. Click Synchronize:

The synchronization is successful:

 

To test the existing database synchronization setup, change to the deployment directory in a Command Prompt and start the MobiLink server:

cd "C:\Centralize Remotes Demo\MobiLink Setup\MobiLink Setup\Standard_Schema_1_0_deploy"
mlsrv

The MobiLink server starts and connects to the Consolidated DSN:

To synchronize each remote, type 'sync' with the DSN information:

sync "DSN=Remote1"
sync "DSN=Remote2"

Each remote should show a successful synchronization:

Centralizing the Synchronizations

Creating the MobiLink Agent

A MobiLink agent is required to run remote tasks on the remote databases. Since this demonstration is set up on a single machine, only one MobiLink agent is required to manage both remote databases.

To create the agent, run the following command:

mlagent -cr -a Agent1 -u Remote1 -p sql -x tcpip{host=localhost}

The above command creates an Agent named Agent1, using the MobiLink username and password Remote1 and sql. Agent1 needs to be run before it will appear in the MobiLink Setup.

mlagent

Running mlagent should leave the agent console window open showing all of its activities. Successful configuration of the agent can be verified by opening the MobiLink Setup in Sybase Central, and refreshing the Agents tab to see the newly created Agent1.

 

Now that an Agent has been created, it needs to be configured. Right-click Agent1 and select Properties. Change its Synchronization Interval to 20 seconds, as well as its Administration polling interval to 20 seocnds. Under the Managed Remote Databases tab, add a new Managed Database. Choose Standard_Schema_1_0 for the Remote Schema Name and use DSN=Remote1 as the Database connection string.

In order to add another managed remote database for Remote2, another remote schema needs to be created.

Under Remote Schema Names, right-click and add a new Remote Schema Name. Call it Standard_Schema_2_0 and click OK. Go back to Agent1 and add a new Managed Remote Database using the new schema.

There is now a MobiLink agent managing both remote databases.

Creating Remote Tasks for MobiLink Agents

MobiLink agents will not execute anything until a remote task is given to them. This is also done in the MobiLink Setup in Sybase Central. Right-click Remote Tasks and choose New Task.

Call this task Synchronize Remote1 and assign it the Standard_Schema_1_0. Click Next.

Trigger the task based on a schedule and when it is received. Click Next.

For the Start Time and Date configuration, leave all the defaults and click Next. For Repetition, set it to repeat every 20 seconds and click Finish.

There should now be an unconfigured remote Task called Synchronize_Remote1. There are two command types to synchronize a database. Choosing the Execute SQL option gives the option of adding extra features in the future that the Synchronize Remote Task does not include.

A second Remote Task is required to synchronize the Remote2 database. Repeat the previous steps but with Standard_Schema_2_0 to create a task for Remote2.

The Execute SQL command type changes slightly as well. For a local test, be sure to specify a different port to avoid conflicts.

Remote Task Deployment

The remote tasks need to be deployed to the agent before they take effect. Right-click Synchronize_Remote1 and Deploy. Deploy it to the Consolidated database configured earlier.

Make the Recipients Specific agents and choose Agent1. Click Next

Pick a delivery option of "The next time the agent synchronizes". Click Finish.

Repeat the previous steps for Synchronize Remote2. The Remote tasks in Sybase Central should look similar to this:

Shut down the MobiLink Agent and restart it with the mlagent command to see the changes take effect immediately. The MobiLink Agent Console should now display sucessful synchronizations every 20 seconds.

Related Content

Related Documents

Quick start to MobiLink

Data Source utility (dbdsn)

mlagent command

Related SAP Notes/KBAs

 

 

  • No labels