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--
Replication set replication set
Replicattion set multiple servers maintain the same copy of data to improve server availability.
The whole process of Replication set setup
0: create a directory
Mkdir-p / data/r0 / data/r1 / data/r2
1: start 3 instances and declare that the instance belongs to a replication set
. / bin/mongod-- port 27017-- dbpath / data/r0-- smallfiles-- replSet rsa-- fork-- logpath / var/log/mongo17.log
. / bin/mongod-- port 27018-- dbpath / data/r1-- smallfiles-- replSet rsa-- fork-- logpath / var/log/mongo18.log
. / bin/mongod-- port 27019-- dbpath / data/r2-- smallfiles-- replSet rsa-- fork-- logpath / var/log/mongo19.log
2: configuration
Rsconf = {
_ id:'rsa'
Members:
[
{_ id:0
Host:'192.168.1.201:27017'
}
]
}
3: initialize according to configuration
Rs.initiate (rsconf)
4: add nodes
Rs.add ('192.168.1.201purl 27018')
Rs.add ('192.168.1.201pur27019')
5: view status
Rs.status ()
6: delete node
Rs.remove ('192.168.1.201pur27019')
7: primary node inserts data
Use test
Db.user.insert ({uid:1,name:'lily'})
8: connect secondary to query synchronization
. / bin/mongo-- port 27019
Use test
Show tables
Rsa:SECONDARY > show tables
Sat Aug 17 16 err 03 err 55.786 JavaScript execution failed: error: {"$err": "not master and slaveOk=false", "code": 13435}
8.1 the above error occurs because slave is not allowed to read or write by default
Rs.slaveOk ()
Show tables
# see data consistent with primary
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.