MongoDB Master-Slave construction
--- xudong He (maintenance engineer of a listed company)
With the heart of Thanksgiving, return everyone ( year 7 months )
Directory
MongoDB Master-Slave construction ... 1
Environment Introduction ... 1
Note: ... 1
master server configuration file ... 1
from the server configuration file ... 2
Connection Test ... 2
Primary server for write testing ... 2
View status from server ... 2
Environment Introduction
service / version |
Ip address |
hostname |
MongoDB main /3.0.4 |
192.168.200.185 |
Mongodb.1.hxd |
MongoDB from /3.0.4 |
192.168.200.185 |
Mongodb.2.hxd |
Note:
Firewall
SELinux
master server configuration file
[Email protected] run]# cat/etc/mongodb.conf
Port = 27017
DBPath =/usr/local/mongodb/data/
LogPath =/usr/local/mongodb/logs/mongodb.log
Logappend = True
Journal = True
#pidfile =/var/run/mongodb.pid
Fork = True
Master = True
from the server configuration file
[Email protected] ~]# cat/etc/mongodb.conf
Port = 27017
DBPath =/usr/local/mongodb/data/
LogPath =/usr/local/mongodb/logs/mongodb.log
Logappend = True
Journal = True
#pidfile =/var/run/mongodb.pid
Fork = True
Master = True
Connection Test
Mongod-f/etc/mongodb.conf
You can view the mongod–help Help file in detail
Primary server for write testing
Db.test.save ({a:1})
View status from server
> Show DBS;
Local 2.077GB
Test 0.078GB
> Use test
Switched to DB test
> Show Collections;
System.indexes
Test
> Db.test.find ()
{"_id": ObjectId ("55a48bfb03a8ff3c6a51e14d"), "a": 1}
This article from the "Clear Sky" blog, declined reprint!
Mongodb-(1) Master-slave