Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Mongdb replica set deployment

2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

Two machines

1. Write in the / etc/hosts file

192.168.255.133 worker1

192.168.255.134 worker2

two。 Modify configuration file / etc/mongdb.conf

BindIp: 0.0.0.0 # for all machines to access

Replication:

ReplSetName: rs # name the replica set rs

3. Start

Mongod

4. Initialize replica set

Rs.initiate ()

5. Add member nod

Rs.add ("worker2:27017")

Rs.addArb ("182.48.115.239VR 27017") # add an arbitration node

6. Go to mongodb shell to view the configuration

> > rs.conf () MongoDB Enterprise rs:PRIMARY > rs.conf () {"_ id": "rs", "version": 2, "protocolVersion": NumberLong (1), "writeConcernMajorityJournalDefault": true, "members": [{"_ id": 0, "host": "worker1:27017" "arbiterOnly": false, "buildIndexes": true, "hidden": false, "priority": 1, "tags": {}, "slaveDelay": NumberLong (0) "votes": 1}, {"_ id": 1, "host": "worker2:27017", "arbiterOnly": false, "buildIndexes": true "hidden": false, "priority": 1, "tags": {}, "slaveDelay": NumberLong (0), "votes": 1}] "settings": {"chainingAllowed": true, "heartbeatIntervalMillis": 2000, "heartbeatTimeoutSecs": 10, "electionTimeoutMillis": 10000, "catchUpTimeoutMillis":-1, "catchUpTakeoverDelayMillis": 30000, "getLastErrorModes": {} "getLastErrorDefaults": {"w": 1, "wtimeout": 0}, "replicaSetId": ObjectId ("5dd12530c247798c40d9cfef")}}

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.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report