In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-03-01 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Description:
Replication sets are additional copies of data, the process of synchronizing data across multiple servers, provide redundancy and increase data availability, and allow recovery from hardware failures and service outages. Its advantages are as follows:
1 . Make your data more secure.
2 . High data availability.
3 . Disaster recovery.
4 . No downtime maintenance (e.g. backup, index rebuild, failover).
5 . Read Bloom (extra copy read).
6 . The replica set is transparent to the application.
.
.
Experimental environment:
.
.
The experimental steps are as follows: (install mongodb first)
.
.
1 . Close the firewall.
systemctl stop firewalld.servicesetenforce 0
Add 3 instances, create data store directories and log store directories for these instances, and upgrade
mkdir -p /data/mongodb/mongodb{2,3,4}mkdir -p /data/mongodb/logstouch /data/mongodb/logs/mongodb{2,3,4}.logchmod 777 /data/mongodb/logs/*.log
.
.
2 . Go to the configuration file and set the data type name.
vim /etc/mongod.conf replication: replSetName: abcrs #Set data type name
.
.
3 . After changing the configuration file, refresh the service.
mongod -f /etc/mongod.conf --shutdown #Close mongodmongod -f /etc/mongod.conf #Open mongod
.
.
4 . Make a copy of the configuration file and change the corresponding parameters as the configuration file for mongod2.
cp -p /etc/mongod.conf /etc/mongod2.conf #Copy the configuration file and rename vim /etc/mongod2.conf path: /data/mongodb/logs/mongodb2.log #Log file storage location... dbPath: /data/mongodb/mongodb2 #Data file storage location... port: 27018 #Port number
.
.
5 . Change the other two profiles as well.
cp -p /etc/mongod2.conf /etc/mongod3.conf cp -p /etc/mongod2.conf /etc/mongod4.conf
.
.
6 . After making the changes, start the instance.
mongod -f /etc/mongod2.conf mongod -f /etc/mongod3.conf mongod -f /etc/mongod4.conf #Start an instance
Check to see if the port is open.
netstat -ntap #View open ports
At this point, you can enter the instance view.
mongo --port 27018mongo --port 27019mongo --port 27020 #Enter Example View
.
.
7 . Configure three node replication sets.
db.stats() #View replication set cfg={"_id":"abcrs","members":[{"_id":0,"host":"192.168.200.132:27017"},{"_id":1,"host":"192.168.200.132:27018"},{"_id":2,"host":"192.168.200.132:27019"}]} #Configure Node Server Associated Ports
.
.
8 . Start replication set.
rs.initiate(cfg) #Initiate replication set
.
.
9 . You can add and delete nodes, so I won't demonstrate them here. The code is as follows:
rs.add("192.168.200.132:27020") #Add nodes rs.remove("192.168.200.132:27020") #Remove nodes
.
.
10 . Node failures are inevitable and failover is essential.
ps aux | grep mongod #View open node kill 6233 Close a process node
At this point, the primary node switches over to a normal node and fails over.
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.