本文へスキップ
バージョン: 5.0

デプロイメント方法

Apache RocketMQ 5.0バージョンでは、NameServer、Broker、Proxyコンポーネントを含む、基本的なメッセージの送受信が完了しています。5.0バージョンでは、実際の要件に応じて、ProxyとBrokerをローカルモードとクラスタモードに分割できます。通常、特別な要件がない場合、または以前のバージョンからのスムーズなアップグレードを目的とする場合は、ローカルモードを使用できます。

  • ローカルモードでは、BrokerとProxyは同じプロセスでデプロイされ、元のBroker設定に基づいてProxy設定を追加するだけで実行できます。
  • クラスタモードでは、BrokerとProxyは別々にデプロイされます。つまり、既存のクラスタに加えて、Proxyを個別にデプロイできます。

ローカルモードでのデプロイメント

ローカルモードではProxyとBrokerが同じプロセスでデプロイされるため、Proxyはステートレスです。そのため、メインクラスタの設定は依然としてBrokerに基づいて行うことができます。

NameServerの起動

### Start Name Server first
$ nohup sh mqnamesrv &

### Verify that the Name Server has started successfully.
$ tail -f ~/logs/rocketmqlogs/namesrv.log
The Name Server boot success...

Broker+Proxyの起動

単一ノード単一レプリカモード

警告

この方法は、Brokerにノードが1つしかないため、高いリスクを伴います。Brokerが再起動または停止すると、サービス全体が利用できなくなります。オンライン環境では推奨されませんが、ローカルテストに使用できます。


$ nohup sh bin/mqbroker -n localhost:9876 --enable-proxy &

### Verify that the Broker has started successfully, for example, the broker IP is 192.168.1.2, and the name is broker-A
$ tail -f ~/logs/rocketmqlogs/broker_default.log
The broker[xxx, 192.169.1.2:10911] boot success...

複数ノード(クラスタ)単一レプリカモード

クラスタ内のすべてのノードはマスターロールでデプロイされ、スレーブレプリカはデプロイされません(例:マスター2台または3台)。このモードの長所と短所は以下のとおりです。

  • 長所:設定が簡単で、単一マスターのダウンタイムや再起動はアプリケーションに影響を与えません。ディスクがRAID10として構成されている場合、マシンが回復不能にダウンしても、RAID10ディスクの信頼性によりメッセージは失われません(非同期ディスクフラッシュでは少量のメッセージが失われますが、同期ディスクフラッシュではメッセージは全く失われません)。パフォーマンスも最高です。
  • 短所:単一マシンのダウンタイム中は、そのマシンで消費されていないメッセージは、マシンが回復するまで購読できません。メッセージのタイムリー性が影響を受けます。

Broker+Proxyクラスタの起動

### On machine A, start the first Master, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-noslave/broker-a.properties --enable-proxy &

### On machine A, start the second Master, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-noslave/broker-b.properties --enable-proxy &

...
注意

上記の起動コマンドは、NameServerが1台の場合に使用します。複数のNameServerを持つクラスタの場合、Broker起動コマンドの-nの後のアドレスリストはセミコロンで区切ります(例:192.168.1.1:9876;192.161.2:9876)。

複数ノード(クラスタ)複数レプリカモード - 非同期レプリケーション

各マスターにはスレーブが1台構成され、複数のマスター・スレーブペアが存在します。HAは非同期レプリケーションを使用しており、プライマリとセカンダリの間には短いメッセージ遅延(ミリ秒レベル)があります。このモードの長所と短所は以下のとおりです。

  • 長所:ディスクが破損した場合でも、非常に少ないメッセージしか失われず、メッセージのタイムリー性にも影響しません。また、マスターがダウンした後も、コンシューマはスレーブから消費を継続でき、このプロセスはアプリケーションに対して透過的で、手動による介入は必要ありません。パフォーマンスは複数マスターモードとほぼ同じです。
  • 短所:マスターの停止またはディスクの破損が発生した場合、少数のメッセージが失われる可能性があります。

Broker+Proxyクラスタの起動

### On machine A, start the first Master, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-async/broker-a.properties --enable-proxy &

### On machine B, start the second Master, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-async/broker-b.properties --enable-proxy &

### On machine C, start the first slave, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-async/broker-a-s.properties --enable-proxy &

### On machine D, start the second slave, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-async/broker-b-s.properties --enable-proxy &

複数ノード(クラスタ)複数レプリカモード - 同期デュアルライト

各マスターにはスレーブが1台構成され、複数のマスター・スレーブペアが存在します。HAは同期デュアルライトを使用しており、プライマリとセカンダリの両方が書き込みに成功した場合のみ、アプリケーションに成功を返します。このモードの長所と短所は以下のとおりです。

  • 長所:データとサービスの両方に単一障害点がなく、マスターの停止が発生した場合でもメッセージの遅延はありません。サービスの可用性とデータの可用性の両方が非常に高くなります。
  • 短所:非同期レプリケーションモードよりもパフォーマンスがわずかに低くなります(約10%低減)。単一メッセージの送信におけるRTがわずかに高くなります。また、現在のバージョンでは、プライマリノードがダウンした後、スタンバイノードが自動的にプライマリに切り替わることはありません。

Broker+Proxyクラスタの起動

### On machine A, start the first Master, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-sync/broker-a.properties --enable-proxy &

### On machine B, start the second Master, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-sync/broker-b.properties --enable-proxy &

### On machine C, start the first slave, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-sync/broker-a-s.properties --enable-proxy &

### On machine D, start the second slave, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-sync/broker-b-s.properties --enable-proxy &
ヒント

上記のBrokerとSlaveのペアリングは、同じBrokerNameパラメータを指定して行います。マスターのBrokerIdは0でなければならず、スレーブのBrokerIdは0より大きい数値でなければなりません。さらに、別のマスターに複数のスレーブをマウントでき、同じマスターの下にある複数のスレーブは、異なるBrokerIdを指定することで区別されます。$ROCKETMQ_HOMEはRocketMQのインストールディレクトリを表し、この環境変数はユーザーによって設定する必要があります。

5.0 HA

RocketMQ 5.0は、より柔軟なHAメカニズムを提供し、メッセージングとストリーミングストレージのシナリオをサポートしながら、コスト、サービスの可用性、データの信頼性のバランスを最適化できます。詳細はこちら

クラスタモードでのデプロイメント

クラスタモードでは、BrokerとProxyは別々にデプロイされ、NameServerとBrokerの起動後にProxyをデプロイできます。

クラスタモードでは、ProxyクラスタとBrokerクラスタは一対一に対応しており、Proxyの設定ファイルrmq-proxy.jsonrocketMQClusterNameを構成できます。

NameServerの起動

### Start NameServer first
$ nohup sh mqnamesrv &

### Verify tha Name Server has started successfully
$ tail -f ~/logs/rocketmqlogs/namesrv.log
The Name Server boot success...

Brokerの起動

単一ノード単一レプリカモード

警告

この方法は、Brokerにノードが1つしかないため、高いリスクを伴います。Brokerが再起動または停止すると、サービス全体が利用できなくなります。本番環境での使用は推奨されませんが、ローカルテストに使用できます。

### On machine A, start the first Master, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 &

複数ノード(クラスタ)単一レプリカモード

このモードでは、クラスタ内のすべてのノードはマスターロールでデプロイされ、スレーブレプリカはデプロイされません(例:マスター2台または3台)。このモードの長所と短所は以下のとおりです。

  • 長所:設定が簡単で、単一マスターのダウンタイムや再起動はアプリケーションに影響を与えません。ディスクがRAID10として構成されている場合、マシンが回復不能にダウンしても、RAID10ディスクの信頼性によりメッセージは失われません(非同期ディスクフラッシュでは少量のメッセージが失われますが、同期ディスクフラッシュではメッセージは全く失われません)。パフォーマンスも最高です。
  • 短所:単一マシンのダウンタイム中は、そのマシンで消費されていないメッセージは、マシンが回復するまで購読できません。メッセージのリアルタイム性が影響を受けます。
### On machine A, start the first Master, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-noslave/broker-a.properties &

### On machine B, start the first Master, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-noslave/broker-b.properties &

...
注意

上記の起動コマンドは、NameServerが1台の場合に使用します。複数のNameServerを持つクラスタの場合、Broker起動コマンドの-nの後のアドレスリストはセミコロンで区切ります(例:192.168.1.1:9876;192.161.2:9876)。

複数ノード(クラスタ)複数レプリカモード - 非同期レプリケーション

各マスターにはスレーブが1台構成され、複数のマスター・スレーブペアが存在します。HAは非同期レプリケーションを使用しており、プライマリとスタンバイの間には短い遅延(ミリ秒レベル)があります。このモードの長所と短所は以下のとおりです。

  • 利点:ディスクが破損しても、メッセージの損失は非常に小さく、メッセージのタイムリーさも影響を受けません。さらに、マスターがダウンした後も、コンシューマはスレーブから消費を継続でき、このプロセスはアプリケーションに対して透過的で、手動による介入は必要ありません。パフォーマンスはマルチマスターモードとほぼ同じです。
  • 欠点:マスタークラッシュまたはディスク破損が発生した場合、少数のメッセージが損失する可能性があります。
### On machine A, start the first Master, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-async/broker-a.properties &

### On machine B, start the second Master, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-async/broker-b.properties &

### On machine C, start the first Slave, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-async/broker-a-s.properties &

### On machine B, start the second Slave, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-async/broker-b-s.properties &

複数ノード(クラスタ)複数レプリカモード - 同期デュアルライト

各マスターは1つのスレーブと構成され、複数のマスター・スレーブペアが存在します。HAは同期デュアルライトを使用し、プライマリとスタンバイの両方が正常に書き込みを完了した場合のみ、アプリケーションに成功を返します。このモードの利点と欠点は次のとおりです。

  • 利点:データとサービスの両方が単一障害点から解放されます。マスタークラッシュが発生した場合、メッセージの遅延はなく、サービスの可用性とデータの可用性の両方が非常に高くなります。
  • 欠点:非同期レプリケーションモードよりもパフォーマンスがやや低くなります(約10%低い)、単一メッセージ送信のRTがやや高く、現在のバージョンでは、プライマリノードがダウンした後、スタンバイが自動的にプライマリに切り替わることはありません。
### On machine A, start the first Master, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-sync/broker-a.properties &

### On machine B, start the second Master, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-sync/broker-b.properties &

### On machine C, start the first Slave, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-sync/broker-a-s.properties &

### On machine B, start the second Slave, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqbroker -n 192.168.1.1:9876 -c $ROCKETMQ_HOME/conf/2m-2s-sync/broker-b-s.properties &
ヒント

ブローカーとスレーブのペアリングは、同じBrokerNameパラメータを指定して行われます。マスターのBrokerIdは0でなければならず、スレーブのBrokerIdは0より大きい数値でなければなりません。さらに、1つのマスターの下に複数のスレーブをマウントでき、同じマスターの下にある複数のスレーブは、異なるBrokerIdを指定することで区別されます。$ROCKETMQ_HOMEはRocketMQのインストールディレクトリを表し、ユーザーが環境変数として設定する必要があります。

5.0 HA

RocketMQ 5.0は、より柔軟なHAメカニズムを提供し、メッセージングとストリーミングストレージのシナリオをサポートしながら、コスト、サービスの可用性、データの信頼性のバランスを最適化できます。詳細はこちら

プロキシの起動

複数のプロキシを複数のマシンで起動できます。

### On machine A start the first Proxy, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqproxy -n 192.168.1.1:9876 &

### On machine B start the second Proxy, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqproxy -n 192.168.1.1:9876 &

### On machine C start the third Proxy, for example, the IP of the NameServer is: 192.168.1.1
$ nohup sh bin/mqproxy -n 192.168.1.1:9876 &

設定ファイルを指定する必要がある場合は、-pcまたは--proxyConfigPathを使用して指定できます。

### custom config file
$ nohup sh bin/mqproxy -n 192.168.1.1:9876 -pc /path/to/proxyConfig.json &