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

Mongodb master-slave replication configuration

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

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

Master-slave replication is the most commonly used replication method in mongodb, which is very flexible. Can be used for backup, fault recovery, read expansion and so on. The most basic way to set up is to establish a master node and one or more slave nodes, each slave node should know the address of the master node. We realize the master and subordinate in two ways.

Here we use one master and one slave to copy mongodb.

Configuration file method:

1. Mainframe

Mongodb-master 10.48.255.244 master

Mongodb-slave 10.48.255.243 slave

two。 Apply the above installation process to the two hosts mongodb, and change the configuration file slightly

On mongodb-master, the profile is added

Master=trueoplogSize=2048 # is similar to mysql's log scrolling, in m

On mongodb-slave, the profile is added:

Slave=truesource=10.48.100.1:27017 # specifies master mongodb serverslavedelay=10 # delay replication in seconds autoresync=true # when it is found that the data from the slave server is not up-to-date, request synchronization data from the master server

Start mongodb on both hosts: mongod-f / etc/mongodb/mongod.conf

Command method:

1) Experimental environment

Master: 192.168.0.14

From: 192.168.0.64

2) time synchronization

Time synchronization between two machines

[root@zabbix_server src] # ntpdate time.windows.com

3) start the service

Master:192.168.0.14

Start command

/ usr/local/mongodb/bin/mongod-master-dbpath=/usr/local/mongodb/data-logpath=/usr/local/mongodb/logs-logappend-port=27017-fork

Slave:192.168.0.64

Start command

/ usr/local/mongodb/bin/mongod-- slave-- source 192.168.0.14 source 27017-- dbpath=/usr/local/mongodb/data-- logpath=/usr/local/mongodb/logs-- logappend-- port=27017-- fork

View the master-slave service status command from the slave host:

Db.printReplicationInfo ()

Master-slave: http://blog.chinaunix.net/uid-24250828-id-3770298.html

Http://linuxme.blog.51cto.com/1850814/965184

Http://kupig.blog.51cto.com/8929318/1697635

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

Database

Wechat

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

12
Report