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

SQL Anywhere 11.0.1 (Français) » MobiLink - Getting Started » MobiLink Tutorials » Tutorial: Writing Scripts and Monitoring Synchronizations


Lesson 2: Set up the remote SQL Anywhere databases

MobiLink is designed for synchronization involving a consolidated database server and a large number of mobile databases. In this section, you create two remote databases. For each database you:

  • Migrate a selected portion of the consolidated schema.

  • Create a synchronization publication, user, and subscription.

Create SQL Anywhere databases

In Lesson 1, you used Sybase Central to create databases. In this tutorial, you use a command line utility. The two tools produce identical results.

♦  To create and start SQL Anywhere remote databases
  1. At a command prompt, navigate to the directory where you would like to create the remote databases.

  2. Type the following commands to create the database:

    dbinit -p 4096 remote1.db

    For remote2, type:

    dbinit -p 4096 remote2.db

    The -p option defines a 4K page size shown to increase performance for many environments.

    For more information about dbinit options, see Initialization utility (dbinit).

  3. Now, to start the databases, type:

    dbeng11 remote1.db

    For remote2, type:

    dbeng11 remote2.db
Migrating a subset of the consolidated database schema

Migrating a subset of the consolidated database schema involves:

  • Connecting to the remote database.

  • Creating a remote server and external login.

  • Using the Sybase Central Migrate Database Wizard.

♦  To migrate a subset of your consolidated database schema to remote1
  1. Click Start » Programs » SQL Anywhere 11 » Sybase Central.

  2. Connect to the remote database:

    1. In the left pane, click SQL Anywhere 11.

    2. Click File » Connect.

    3. Click the Identification tab.

    4. In the User ID field, type DBA.

    5. In the Password field, type sql.

    6. Click the Database tab.

    7. In the Server Name field, type remote1.

    8. Click OK.

  3. Create a remote server:

    1. In the left pane, right-click Remote Servers and choose New » Remote Server.

    2. In the What Do You Want To Name The New Remote Server field, type my_sa. Click Next.

    3. Click SQL Anywhere. Click Next.

    4. In the What Is The Connection Information field, type sa_cons. Click Next.

    5. Click Next.

    6. Click Create An External Login For The Current User.

    7. In the Login Name field, type DBA.

    8. In the Password field, type sql.

    9. In the Confirm Password field, type sql.

    10. Click Finish.

  4. Migrate the consolidated database schema:

    1. Click Tools » SQL Anywhere 11 » Migrate Database.

    2. Click Next.

    3. In the To Which Database Do You Want To Migrate list, select remote1. Click Next.

    4. In the From Which Remote Server Do You Want To Migrate list, select my_sa. Click Next.

    5. In the Available Tables list, choose Product, and then click Add. Click Next.

    6. Click DBA. Click Next.

    7. Clear Migrate The Data. Click Finish.

    8. Click Close.

  5. Repeat steps 2 to 4 using the remote2 database.

Synchronization subscriptions and publications

Publications identify the tables and columns on your remote database that you want synchronized. These tables and columns are called articles. A synchronization subscription subscribes a MobiLink user to a publication.

Synchronization subscriptions and publications are stored in the remote database.

♦  To create a remote synchronization publication, synchronization user, and synchronization subscription
  1. In the left pane of Sybase Central, right-click remote1 - DBA and choose File » Open Interactive SQL.

  2. Enter synchronization information for remote1:

    • Execute the following in Interactive SQL:

      CREATE PUBLICATION pub_1 (TABLE Product);
       FOR user_1 TYPE TCPIP ADDRESS 'host=localhost'
       OPTION scriptversion='ver1';
  3. Start Interactive SQL and connect to remote2.

  4. Enter synchronization information for remote2.

    • Execute the following in Interactive SQL:

      CREATE PUBLICATION pub_2 (TABLE Product);
       FOR user_2 TYPE TCPIP ADDRESS 'host=localhost'
       OPTION scriptversion='ver1';

Now you have prepared the remote and consolidated databases. In the next lesson you write synchronization scripts. In Lesson 4 you run the synchronization.

Further reading

For more information about defining publications and subscriptions, see Publishing data.