AI エージェント向け: ドキュメントインデックスは https://www.mongodb.com/ja-jp/docs/llms.txt で利用できます。すべてのページの markdown バージョンは、いずれかの URL パスに .md を追加することで利用できます。
Docs Menu

自己管理型セカンダリのアービタへの変換

レプリカセット 内に セカンダリ があり、データを保持する必要がなくなり、セットが プライマリ を選択 できるようにするにはセット内に残っている必要がある場合は、このチュートリアルのいずれかの手順を使用してセカンダリを アービタ に変換できます。どちらの手順も操作上では同等です。

  1. アプリケーションがセカンダリに直接接続している場合は、アプリケーションを変更して、MongoDB クエリがセカンダリに到達しないようにします。

  2. セカンダリをシャットダウンします。

  3. Remove the secondary from the replica set by calling the rs.remove() method. Perform this operation while connected to the current primary in mongosh:

    rs.remove("<hostname><:port>")
  4. Verify that the replica set no longer includes the secondary by calling the rs.conf() method in mongosh:

    rs.conf()
  5. セカンダリのデータ ディレクトリをアーカイブ フォルダーに移動します。 例:

    mv /data/db /data/db-old

    注意

    任意

    代わりにデータを削除できます。

  6. mongodインスタンスの再起動時にポイントする新しい空のデータディレクトリを作成します。 以前の名前を再利用できます。 例:

    mkdir /data/db
  7. ポート番号、空のデータディレクトリ、レプリカセットを指定して、セカンダリのmongodインスタンスを再起動します。 以前に使用していたポート番号を使用できます。 次のようなコマンドを発行します。

    警告

    インスタンスをパブリックにアクセス可能な IP アドレスにバインドする前に、クラスターを不正アクセスから保護する必要があります。 セキュリティ推奨事項の完全なリストについては、「自己管理型配置のセキュリティ チェックリスト」を参照してください。 最低限、認証を有効化し、ネットワーク インフラストラクチャの強化 を検討してください。

    mongod --port 27021 --dbpath /data/db --replSet rs --bind_ip localhost,<hostname(s)|ip address(es)>
  8. In mongosh convert the secondary to an arbiter using the rs.addArb() method:

    rs.addArb("<hostname><:port>")
  9. Verify the arbiter belongs to the replica set by calling the rs.conf() method in mongosh.

    rs.conf()

    アービタ ノードには以下を含める必要があります。

    "arbiterOnly" : true
  1. アプリケーションがセカンダリに直接接続している場合、またはセカンダリを参照する接続stringがある場合は、アプリケーションを変更して、 MongoDBクエリがセカンダリに到達しないようにします。

  2. 新しいポート番号で使用する新しい空のデータディレクトリを作成します。 例:

    mkdir /data/db-temp
  3. 新しいデータディレクトリと既存のレプリカセットを指定して、新しいポート番号で新しいmongodインスタンスを起動します。 次のようなコマンドを発行します。

    警告

    インスタンスをパブリックにアクセス可能な IP アドレスにバインドする前に、クラスターを不正アクセスから保護する必要があります。 セキュリティ推奨事項の完全なリストについては、「自己管理型配置のセキュリティ チェックリスト」を参照してください。 最低限、認証を有効化し、ネットワーク インフラストラクチャの強化 を検討してください。

    mongod --port 27021 --dbpath /data/db-temp --replSet rs --bind_ip localhost,<hostname(s)|ip address(es)>
  4. In mongosh connected to the current primary, convert the new mongod instance to an arbiter using the rs.addArb() method:

    rs.addArb("<hostname><:port>")
  5. Verify the arbiter has been added to the replica set by calling the rs.conf() method in mongosh.

    rs.conf()

    アービタ ノードには以下を含める必要があります。

    "arbiterOnly" : true
  6. セカンダリをシャットダウンします。

  7. Remove the secondary from the replica set by calling the rs.remove() method in mongosh:

    rs.remove("<hostname><:port>")
  8. Verify that the replica set no longer includes the old secondary by calling the rs.conf() method in mongosh:

    rs.conf()
  9. セカンダリのデータ ディレクトリをアーカイブ フォルダーに移動します。 例:

    mv /data/db /data/db-old

    注意

    任意

    代わりにデータを削除できます。