In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-04-09 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
MongoDB officially does not recommend using master-slave mode. The alternative is to use replica set mode. Click, as shown in the figure:
So what is a copy of the episode? Playing World of Warcraft is always about making copies, but in fact, these two concepts have almost the same meaning. The copy in the game means that when players focus on fighting monsters in a scene during peak hours, there will be too many players and few monsters. In order to ensure the players' experience, the game developers will open the same space and the same number of monsters separately for each group of players. This copied scene is a copy, no matter how many players play in their own copies will not affect each other. The copy of mongoDB is the same, and the master-slave mode is actually a single-copy application, which does not have good scalability and fault tolerance. The replica set has multiple copies to ensure fault tolerance, even if one copy is dead, there are still many copies, and the first problem above is "if the master node dies, it will be automatically switched in the whole cluster". No wonder mongoDB officially recommends this model.
Let's look at the architecture diagram of the mongoDB replica set:
From the figure, you can see that the client connects to the entire replica set, regardless of which machine is down. The master server is responsible for reading and writing the whole replica set, and the replica set synchronizes data backup periodically. Once the master node dies, the replica node will elect a new master server, which does not need to be concerned about the application server. Let's take a look at the architecture after the primary server is down:
After the replica node in the replica set is detected by the heartbeat mechanism after the master node dies, it will initiate the election mechanism of the master node in the cluster and automatically elect a new master server. It looks like a great X, let's quickly operate and deploy it!
The official recommended number of replica set machines is at least 3, so we will also configure the test according to this number.
Mongodb replica set environment deployment record
System environment
Centos7.5, MongoDB4.0.6, turn off the firewall, if tested on one machine, the cluster uses different communication ports
1) Machine environment
10.153.1.183 master-node (primary node)
10.153.1.184 slave-node1 (slave node)
10.153.1.185 slave-node2 (slave node)
2) install master-node
Introduction to #! / bin/bash####mongodb # mongodb is a non-relational database, but its operation is most similar to relational data. Mysql is a relational database. # mongodb is a non-relational database for document storage. Data is stored in json format. # mongodb can be used for permanent storage or for caching data. # mongodb provides replica set and shard cluster functions. Easy to operate # # if [`whoami`! = root] thenecho "Please login as root to continue:)" exit 1fiif [!-d / home/tools/] Thenmkdir-p / home/toolselserm-rf / home/tools & & mkdir-p / home/toolsfi#Prohibit memory giant pagesecho 'never' > / sys/kernel/mm/transparent_hugepage/enabledecho' never' > / sys/kernel/mm/transparent_hugepage/defrag#Add commands to / etc/rc.localchmod + x / etc/rc.d/rc.localecho "echo 'never' > / sys/kernel/mm/transparent_hugepage/enabled" > > / etc/rc.localecho "echo' never' > / sys/kernel/mm/transparent _ hugepage/defrag "> > / etc/rc.local#Disable firewall and selinuxsed-I'/ SELINUX/s/enforcing/disabled/' / etc/selinux/config systemctl disable firewalld.service#Setting Handles Number and Processcat > > / etc/security/limits.conf / data/mongodb/27017/mongodb.conf
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: 292
*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
Log in to angularJSPlease sign in < / h3 > Email addressPasswordRemeber meSign in
© 2024 shulou.com SLNews company. All rights reserved.