In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)05/31 Report--
In this issue, the editor will bring you about how to add and delete nodes in the mongodb replica set. The article is rich in content and analyzes and describes for you from a professional point of view. I hope you can get something after reading this article.
Environment introduction: mongodb replica set with three nodes
10.9.21.114: 27017 Primary Node
10.9.21.178: 27017 secondary
10.9.21.179: 27017 secondary
Need to add a new node 10.9.21.115: 27017 to the replica set
Method 1: add rs.add ("10.9.21.115VRO 27017") directly
First of all, this paper introduces the command rs.add method, which is suitable for when the amount of data is relatively small, because this method requires initial sync to synchronize all the data, which is bound to cause pressure on the network and io, and the operation must be performed during the low period of business, because if you execute when the business volume is large, the oplogs in the time period of synchronizing data may be overwritten and lead to synchronization failure! For more information on the process of initial sync, please see http://blog.itpub.net/29654823/viewspace-2668577/.
First, install the same version of mongodb on the 21.115 machine.
A copy of the configuration file copy on the original copy set, adjust accordingly, and then start mongodb, skipping these actions:
/ usr/bin/mongodb/bin/mongod-f / etc/mongod.conf
Second, operate on the master node of the original replica set:
2.1 add a data node
Rs.add ("10.9.21.115purl 27017");-add nodes
Rs.status ()-verify whether the addition is successful
Check to see if there is a delay, as follows:
MongoDB Enterprise liuhe_rs:PRIMARY > rs.printSlaveReplicationInfo ()
Source: 10.9.21.178:27017
SyncedTo: Tue Nov 26 2019 21:43:22 GMT+0800 (CST)
0 secs (0 hrs) behind the primary
Source: 10.9.21.114:27017
SyncedTo: Tue Nov 26 2019 21:43:22 GMT+0800 (CST)
0 secs (0 hrs) behind the primary
Source: 10.9.21.115:27017
SyncedTo: Tue Nov 26 2019 21:43:22 GMT+0800 (CST)
0 secs (0 hrs) behind the primary
If the newly added status is STARTUP2, then you can restart the new node
Use admin
Db.shutdownServer ()
/ usr/bin/mongodb/bin/mongod-f / etc/mongod.conf
2.2 Delete a data node
Rs.remove ("10.9.21.115purl 27017")
Check again and find that there is no synchronization information of 115.
MongoDB Enterprise liuhe_rs:PRIMARY > rs.printSlaveReplicationInfo ()
Source: 10.9.21.178:27017
SyncedTo: Tue Nov 26 2019 21:47:12 GMT+0800 (CST)
8 secs (0 hrs) behind the primary
Source: 10.9.21.114:27017
SyncedTo: Tue Nov 26 2019 21:47:12 GMT+0800 (CST)
8 secs (0 hrs) behind the primary
MongoDB Enterprise liuhe_rs:PRIMARY >
2.3 add an arbitration node
Rs.addArb ("10.9.21.115purl 27017")
Or
Rs.add ({host: "10.9.21.115 virtual 27017", arbiterOnly:true})
Rs.status ()
{
"_ id": 3
"name": "10.9.21.115purl 27017"
"health": 1
"state": 7
"stateStr": "ARBITER"
"uptime": 165
"lastHeartbeat": ISODate ("2019-11-26T13:55:21.391Z")
"lastHeartbeatRecv": ISODate ("2019-11-26T13:55:21.150Z")
"pingMs": NumberLong (0)
"lastHeartbeatMessage":
"syncingTo":
"syncSourceHost":
"syncSourceId":-1
"infoMessage":
"configVersion": 6
}
2.4 add a hidden node
PRIMARY > rs.add ({host: "10.9.21.115 host", priority:0,hidden:true})
The above is how to add and delete nodes to the mongodb copy set shared by the editor. If you happen to have similar doubts, please refer to the above analysis to understand. If you want to know more about it, you are welcome to follow the industry information channel.
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.