MongoDB master-slave replica set configuration

Source: Internet
Author: User

To create a path:

mkdir  -p  /datassd/mongo_20011/ {data,conf,log}  

Example configuration file:

#mongo.conf dbpath= /datassd/mongo/data/ logpath= /datassd/mongo_20011/log/mongo_20011 .log pidfilepath= /datassd/mongo_20011/mongo_20011 .pid directoryperdb= true logappend= true replSet=testrs port=20011 oplogSize=10000 fork= true noprealloc= true

Parameter explanation:

DBPath: Data Storage Directory

LogPath: Log Storage path

Pidfilepath: Process files, easy to stop MongoDB

Directoryperdb: Set up a folder for each database according to the database name

Logappend: Logging in Append mode

Replset:replica Set's name

IP address that is bound by Bind_ip:mongodb

The port number used by the PORT:MONGODB process, which defaults to 20011

Oplogsize:mongodb the maximum size of the operation log file. The unit is MB, which defaults to 5% of the remaining space on the hard disk. Shard scenes can only be fragmented if they exceed this size

Fork: Run the process in the next stage mode

Noprealloc: No pre-allocated storage

Reference configuration:

Master
config={_id: ' Shard1 ', members:[{_id:0,host: ' 10.2.1.61:20011 '},{_id:1,host: ' 10.2.2.13:20011 '},{_id:2,host: ' 10.2.2.31:20011 ', Arbiteronly:true}]}

#双节点情况下需要有仲裁节点才能实现故障转移, it is also possible to replace the quorum node with another one from

Master
Rs.initiate (config)

#db. Printreplicationinfo ()

#rs. Status ()

Slave
#rs. Slaveok ()

To add a delete node:

Rs.add ("Ip:port")

Rs.remove ("Ip:port")

MongoDB master-slave replica set configuration

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.