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--
Environment introduction:
192.168.1.250 Master port=27408
192.168.1.250 Arbitration port=27409
192.168.1.251 standby port=27408
[root@HE4 ~] # tar xvf mongodb-linux-x86_64-2.6.10.tgz
[root@HE4] # mkdir-p / export/mongodb
[root@HE4] # mkdir-p / export/mongodb/bin
[root@HE4] # mkdir-p / export/mongodb/conf
[root@HE4] # mkdir-p / export/mongodb/log
[root@HE4] # mkdir-p / export/mongodb/data
[root@HE4 bin] # cd / root/mongodb-linux-x86_64-2.6.10/bin
[root@HE4 bin] # cp / root/mongodb-linux-x86_64-2.6.10 Candle * / export/mongodb/bin/
[root@HE1 bin] # vi / export/mongodb/conf/mongod.conf
Port=27408dbpath=/export/mongodb/datalogpath=/export/mongodb/log/mongod.logfork=truelogappend=truekeyFile=/export/mongodb/key/mongodnohttpinterface=truereplSet=shard1 [root@HE1 bin] # vi / export/mongodb/conf/arbiter.confport=27409dbpath=/export/mongodb/arbiterlogpath=/export/mongodb/log/arbiter.logfork=truelogappend=truekeyFile=/export/mongodb/key/arbiternohttpinterface=truereplSet=shard1
Keyfile files include:
Mongod,arbiter
Create a script that generates keyfile
Vi create_key.sh
Cat / dev/urandom | LC_ALL=C tr-dc "[: alnum:]" | fold-w 10 | head-1 > / tmp/key.txtkeystring= `cat / tmp/ key.txt`echo $keystring > / export/mongodb/key/mongodecho $keystring > / export/mongodb/key/arbiterchmod 600 / export/mongodb/key/*
Start the server in the master
[root@HE3] # / export/mongodb/bin/mongod-f / export/mongodb/conf/mongod.conf
[root@HE3] # / export/mongodb/bin/mongod-f / export/mongodb/conf/arbiter.conf
From
[root@HE4] # / export/mongodb/bin/mongod-f / export/mongodb/conf/mongod.conf
> config= {_ id:'shard1',members: [{_ id:0,host:'192.168.1.248:27408'}, {_ id:1,host:'192.168.1.249:27408'}, {_ id:2,host:'192.168.1.248:27409',arbiterOnly:true}]}
> rs.initiate (config)
Initialize rs.initiate (config), config is the name previously defined
After the master and backup database is configured, query the standby database.
Shard1:SECONDARY > use testswitched to db testshard1:SECONDARY > db.t1.find () error: {"$err": "not master and slaveOk=false", "code": 13435} shard1:SECONDARY > rs.slaveOk () shard1:SECONDARY > db.t1.find () {"_ id": ObjectId ("5704c11d3e0651733bfdea23"), "x": 1}
Rs.stauts () can look at the status, health:1 stands for health, stateStr who is our arbitration
If you want to downgrade the master library to a slave library, rs.stepDown ()
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.