자체 관리형 세컨더리를 중재자로 전환
이 페이지의 내용
If you have a 보조 in a replicaSet that no longer needs to hold data but that needs to remain in the set to ensure that the set can elect a primary, you may convert the secondary to an 중재자 using either procedure in this tutorial. Both procedures are operationally equivalent:
You may operate the arbiter on the same port as the former secondary. In this procedure, you must shut down the secondary and remove its data before restarting and reconfiguring it as an arbiter.
For this procedure, see Convert Secondary to Arbiter and Reuse the Port Number.
Run the arbiter on a new port. In this procedure, you can reconfigure the server as an arbiter before shutting down the instance running as a secondary.
For this procedure, see Convert Secondary to Arbiter Running on a New Port Number.
Convert Secondary to Arbiter and Reuse the Port Number
If your application is connecting directly to the secondary, modify the application so that MongoDB queries don't reach the secondary.
세컨더리를 종료합니다.
Remove the 보조 from the replicaSet by calling the
rs.remove()
method. Perform this operation while connected to the current 기본 inmongosh
:rs.remove("<hostname><:port>") Verify that the replica set no longer includes the secondary by calling the
rs.conf()
method inmongosh
:rs.conf() Move the secondary's data directory to an archive folder. For example:
mv /data/db /data/db-old 참고
옵션
You may remove the data instead.
Create a new, empty data directory to point to when restarting the
mongod
instance. You can reuse the previous name. For example:mkdir /data/db Restart the
mongod
instance for the secondary, specifying the port number, the empty data directory, and the replica set. You can use the same port number you used before. Issue a command similar to the following:경고
인스턴스를 공개적으로 접근 가능한 IP 주소에 바인딩하기 전에 무단 접근으로부터 클러스터를 보호해야 합니다. 보안 권장 사항의 전체 목록은 자체 관리 배포서버에 대한 보안 검사 목록을 참조하세요. 최소한 인증을 활성화하고 네트워크 인프라를 강화하는 것을 고려합니다.
mongod --port 27021 --dbpath /data/db --replSet rs --bind_ip localhost,<hostname(s)|ip address(es)> In
mongosh
convert the secondary to an arbiter using thers.addArb()
method:rs.addArb("<hostname><:port>") Verify the arbiter belongs to the replica set by calling the
rs.conf()
method inmongosh
.rs.conf() The arbiter member should include the following:
"arbiterOnly" : true
Convert Secondary to Arbiter Running on a New Port Number
If your application is connecting directly to the secondary or has a connection string referencing the secondary, modify the application so that MongoDB queries don't reach the secondary.
Create a new, empty data directory to be used with the new port number. For example:
mkdir /data/db-temp Start a new
mongod
instance on the new port number, specifying the new data directory and the existing replica set. Issue a command similar to the following:경고
인스턴스를 공개적으로 접근 가능한 IP 주소에 바인딩하기 전에 무단 접근으로부터 클러스터를 보호해야 합니다. 보안 권장 사항의 전체 목록은 자체 관리 배포서버에 대한 보안 검사 목록을 참조하세요. 최소한 인증을 활성화하고 네트워크 인프라를 강화하는 것을 고려합니다.
mongod --port 27021 --dbpath /data/db-temp --replSet rs --bind_ip localhost,<hostname(s)|ip address(es)> In
mongosh
connected to the current primary, convert the newmongod
instance to an arbiter using thers.addArb()
method:rs.addArb("<hostname><:port>") Verify the arbiter has been added to the replica set by calling the
rs.conf()
method inmongosh
.rs.conf() The arbiter member should include the following:
"arbiterOnly" : true 세컨더리를 종료합니다.
Remove the 보조 from the replicaSet by calling the
rs.remove()
method inmongosh
:rs.remove("<hostname><:port>") Verify that the replica set no longer includes the old secondary by calling the
rs.conf()
method inmongosh
:rs.conf() Move the secondary's data directory to an archive folder. For example:
mv /data/db /data/db-old 참고
옵션
You may remove the data instead.