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 サーバ データベース管理 » 高可用性と読み込み専用のスケールアウトシステム » データベースミラーリング » チュートリアル:監視サーバを共有している複数データベースでデータベースミラーリングシステムを作成する

 

レッスン 1:3 つのデータベースと 1 つの監視サーバで構成されるデータベースミラーリングシステムの作成

同じ監視サーバを使用する 3 つのミラーリングされたデータベースで構成されるデータベースミラーリングシステムを作成します。

前提条件

このレッスンでは、このチュートリアルの開始時に、権限のセクションで一覧されているロールと権限を持っていることを前提としています。 チュートリアル:監視サーバを共有している複数データベースでデータベースミラーリングシステムを作成する

 ♦ タスク
  1. 次のディレクトリを作成します。

    • c:\server1
    • c:\server2
    • c:\arbiter
  2. newdemo.bat を使用して、SQL Anywhere 16 サンプルデータベース (demo.db) のコピーを作成します。次のコマンドを実行します。

    newdemo.bat c:\server1\one.db
  3. 次のコマンドを実行します。

    newdemo.bat c:\server1\two.db
  4. c:\server1 ディレクトリから、次のコマンドを実行します。

    newdemo.bat c:\server1\three.db
  5. server1 という名前のデータベースサーバを起動します。

    dbsrv16 -n server1 -x tcpip(PORT=6871) -su sql c:\server1\one.db -xp on c:\server1\two.db -xp on c:\server1\three.db -xp on

    -su オプションを含めてユーティリティデータベースのパスワードを指定することをおすすめします。そうすることで、必要に応じてユーティリティデータベースに接続してデータベースサーバをシャットダウンできるようになります。ミラーリングシステムのデータベースサーバの停止を参照してください。

  6. Interactive SQL からデータベース one に接続し、必要なミラーリングオブジェクトを定義します。

    dbisql -c "UID=DBA;PWD=sql;SERVER=server1;DBN=one"
    1. server1 をデータベース one のパートナサーバとして定義します。

      CREATE MIRROR SERVER server1
      AS PARTNER
      connection_string='SERVER=server1;host=localhost:6871'
      state_file='c:\\server1\\server1state.txt';
    2. データベースサーバ primary_one をデータベース one の論理プライマリサーバとして定義します。

      CREATE MIRROR SERVER primary_one
      AS PRIMARY
      connection_string='SERVER=primary_one;host=localhost:6871,localhost:6872';
    3. server2 をデータベース one のパートナサーバとして定義します。

      CREATE MIRROR SERVER server2
      AS PARTNER
      connection_string='SERVER=server2;host=localhost:6872'
      state_file='c:\\server2\\server2state.txt';
    4. データベースサーバ mirror_one をデータベース one の論理ミラーサーバとして定義します。

      CREATE MIRROR SERVER mirror_one
      AS MIRROR
      connection_string='SERVER=mirror_one;host=localhost:6871,localhost:6872';
    5. 監視サーバを定義します。

      CREATE MIRROR SERVER arbiter
      AS ARBITER
      connection_string='SERVER=arbiter;HOST=localhost:6870';
    6. データベースミラーリングシステムのミラーリングオプションを設定します。

      SET MIRROR OPTION authentication_string='abc';
    7. Interactive SQL との接続を切断します。

    8. c:\server2 ディレクトリにデータベースのバックアップコピーを作成します。

      dbbackup -c "UID=DBA;PWD=sql;SERVER=server1;DBN=one" c:\server2
  7. Interactive SQL からデータベース two に接続し、必要なミラーリングオブジェクトを定義します。

    dbisql -c "UID=DBA;PWD=sql;SERVER=server1;DBN=two"
    1. server1 をデータベース two のパートナサーバとして定義します。

      CREATE MIRROR SERVER server1
      AS PARTNER
      connection_string='SERVER=server1;host=localhost:6871'
      state_file='c:\\server1\\server1state.txt';
    2. データベースサーバ primary_two をデータベース two の論理プライマリサーバとして定義します。

      CREATE MIRROR SERVER primary_two
      AS PRIMARY
      connection_string='SERVER=primary_two;host=localhost:6871,localhost:6872';
    3. server2 をデータベース two のパートナサーバとして定義します。

      CREATE MIRROR SERVER server2
      AS PARTNER
      connection_string='SERVER=server2;host=localhost:6872'
      state_file='c:\\server2\\server2state.txt';
    4. データベースサーバ mirror_two をデータベース two の論理ミラーサーバとして定義します。

      CREATE MIRROR SERVER mirror_two
      AS MIRROR
      connection_string='SERVER=mirror_two;host=localhost:6871,localhost:6872';
    5. 監視サーバを定義します。

      CREATE MIRROR SERVER arbiter
      AS ARBITER
      connection_string='SERVER=arbiter;HOST=localhost:6870';
    6. データベースミラーリングシステムのミラーリングオプションを設定します。

      SET MIRROR OPTION authentication_string='def';
    7. Interactive SQL との接続を切断します。

    8. c:\server2 ディレクトリにデータベースのバックアップコピーを作成します。

      dbbackup -c "UID=DBA;PWD=sql;SERVER=server1;DBN=two" c:\server2
  8. Interactive SQL からデータベース three に接続し、必要なミラーリングオブジェクトを定義します。

    dbisql -c "UID=DBA;PWD=sql;SERVER=server1;DBN=three"
    1. server1 をデータベース three のパートナサーバとして定義します。

      CREATE MIRROR SERVER server1
      AS PARTNER
      connection_string='SERVER=server1;host=localhost:6871'
      state_file='c:\\server1\\server1state.txt';
    2. データベースサーバ primary_three をデータベース three の論理プライマリサーバとして定義します。

      CREATE MIRROR SERVER primary_three
      AS PRIMARY
      connection_string='SERVER=primary_three;host=localhost:6871,localhost:6872';
    3. server2 をデータベース three のパートナサーバとして定義します。

      CREATE MIRROR SERVER server2
      AS PARTNER
      connection_string='SERVER=server2;host=localhost:6872'
      state_file='c:\\server2\\server2state.txt';
    4. データベースサーバ mirror_three をデータベース three の論理ミラーサーバとして定義します。

      CREATE MIRROR SERVER mirror_three
      AS MIRROR
      connection_string='SERVER=mirror_three;host=localhost:6871,localhost:6872';
    5. 監視サーバを定義します。

      CREATE MIRROR SERVER arbiter
      AS ARBITER
      connection_string='SERVER=arbiter;HOST=localhost:6870';
    6. データベースミラーリングシステムのミラーリングオプションを設定します。

      SET MIRROR OPTION authentication_string='ghi';
    7. Interactive SQL との接続を切断します。

    8. c:\server2 ディレクトリにデータベースのバックアップコピーを作成します。

      dbbackup -c "UID=DBA;PWD=sql;SERVER=server1;DBN=three" c:\server2
  9. server2 という名前のデータベースサーバを起動します。

    dbsrv16 -n server2 -x tcpip(PORT=6872) -su sql c:\server2\one.db -xp on c:\server2\two.db -xp on c:\server2\three.db -xp on
  10. 監視サーバを起動します。

    dbsrv16 -n arbiter -su sql -x tcpip(port=6870) -xf c:\arbiter\arbiterstate.txt -xa "AUTH=abc,def,ghi;DBN=one,two,three"

結果

server2 を起動した後、server1 のデータベースサーバメッセージウィンドウに、server1 がデータベース one、two、three のミラーリングシステムにおけるプライマリサーバであることが表示されます。また、メッセージウィンドウには、one、two、three のミラーデータベース (パートナ) が server1 に接続されていることも表示されます。

arbiter サーバのメッセージウィンドウには、server1 と server2 の両方が接続されていることが表示されます。