In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
When using Master-Slave mode before, once Master is stopped, the Java client will report an exception. At this time, there is no Master. Slave will not automatically take over Master Replica Sets is also a kind of Master-Slave, but it is more robust. Once Master is stopped, one of the Slave will be elected as Master, which is also officially recommended. You can refer to http://www.mongodb.org/display/DOCS/Replica+Sets to test Replica Sets is very simple, on a single server, set up three users to test. To simplify the test, first write the startup script #! / bin/sh # filename start.sh # usage sh start.sh port if [$#! = 1]; then
Echo "USAGE: $0 [port]"
Exit 1
Fi
MONGODB_HOME=$HOME/work/mongodb
DATA_PATH=$MONGODB_HOME/data
LOG_PATH=$MONGODB_HOME/logs/mongodb.log
MONGODB_PORT=$1
$MONGODB_HOME/bin/mongod-rest-replSet=testset-dbpath=$DATA_PATH-port=$MONGODB_PORT-fork-logpath=$LOG_PATH
User 1: db1 > sh start.sh 30000 user 1: db2 > sh start.sh 40000 at this time, there is no relationship between the mongodb of the two users. Log file output Fri Aug 5 23:35:01 [startReplSets] replSet can't get local.system.replset config from self or any seed (EMPTYCONFIG)
Fri Aug 5 23:35:01 [startReplSets] replSet info you may need to run replSetInitiate-- rs.initiate () in the shell means it hasn't been initialized yet. Now let's initialize two mongodb to establish a master-slave relationship under db1 >. / mongo-- port=30000
MongoDB shell version: 1.8.2
Connecting to: 127.0.0.1:30000/test
> use admin
> cfg= {
"_ id": "myset"
"version": 1
"members": [
{
"_ id": 0
"host": "10.16.46.113purl 30000"
}
{
"_ id": 1
"host": "10.16.46.113pur40000"
}
]}
> rs.initiate (cfg) wait for a moment, and you can see the following information in db1's log, indicating that mongodb on db1 has become master Fri Aug 5 23:43:05 [rs Manager] replSet info electSelf 0
Fri Aug 5 23:43:05 [rs Manager] replSet PRIMARY checks the relationship between them in the console through rs.status (). Now add a mongodb to the cluster. Start mongodb > sh start.sh 50000 in user 3: db3 and add the mongodb of db3 to the cluster in master. Testset:PRIMARY > rs.add ("10.16.46.113rs.status 50000")
Wait a moment, check the test master downtime of the node in the cluster through rs.status (), and take a look at the java client call. After stopping, the client will have an exception log, but it does not report an error through rs.status () like the previous master-slave. Another node has become a PRIMARY service node.
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.