MongoDB Master-Slave synchronization settings
about MongoDB installation and start-up parameter description can refer to my previous reprint of the "Ubuntu installation MongoDB" and "mongodb Start command Mongod parameters description"
Master and subordinate settings
master:192.168.111.103 port:8001
slave:192.168.111.104 port:8001
Start Master
Copy Code code as follows:
Mongod--dbpath/data/masterdb/--master--oplogsize---port 8001--fork--logpath/var/logs/mongodb/mongod.log
Start slave
Copy Code code as follows:
Mongod--dbpath/data/slavedb/--slave--source 192.168.111.103:8001--oplogsize--port 8001--fork--logpath/var/logs /mongodb/mongod.log
View slave log to see that the data has been replicated from master
Tail-f/var/logs/mongodb/mongod.log
Thu Feb 22:18:20 repl:main@192.168.111.103:8001 Thu Feb-22:18:20 repl
: Sleep 2sec before next pass
Thu Feb 22:18:22 repl:main@192.168.111.103:8001 Thu Feb-
22:18:22 repl:sleep 2sec before next pass
Thu Feb 22:18:24 repl:main@192.168.111.103:8001 Thu
Feb/22:18:24 repl:sleep 2sec bef Ore next pass
Thu Feb 22:18:26 repl:main@192.168.111.103:8001 Thu Feb/22:18:26 repl:sleep
2sec before next Pass
Thu Feb 22:18:28 repl:main@192.168.111.103:8001 Thu Feb-
22:18:28 repl:sleep 2sec before next pass
thu Feb 22:18:30 repl:main@192.168.111.103:8001
Thu Feb-22:18:30 repl:sleep 2sec before next pass
Th U Feb 22:18:32 repl:main@192.168.111.103:8001
Thu Feb 22:18:32 repl:sleep 2sec before next pass
Deactivate MongoDB
Mongo-port 8001 Use
admin
db.shutdownserver ()
exit
Repair MongoDB
Mongod--dbpath/data/masterdb/repair
Mongod--dbpath/data/slavedb/repair
MongoDB Start Command mongod parameter description
The main parameters of Mongod are:
Basic Configuration
--------------------------------------------------------------------------------
--quiet # Quiet Output
--port ARG # Specify the service port number, default port 27017
--BIND_IP ARG # Binding service IP, if binding 127.0.0.1, only native access, do not specify default local all IP
--logpath arg # Specifies MONGODB log file, note that the specified file is not a directory
--logappend # Use an Append method to write a log
The full path of the--pidfilepath ARG # PID file, and if not set, no PID files
The full path of the private key of the--keyfile arg # Cluster, valid only for the replica Set schema
--unixsocketprefix arg # UNIX domain socket alternate directory, (Default/TMP)
--fork # runs MongoDB as a daemon, creating a server process
--auth # Enable authentication
--CPU # Displays CPU utilization and iowait on a regular basis
--dbpath arg # Specify Database path
--diaglog arg # diaglog option 0=off 1=w 2=r 3=both 7=w+some reads
--DIRECTORYPERDB # Settings Each database will be saved in a separate directory
--journal # Enable logging options, MONGODB data operations will be written to files in the Journal folder
--journaloptions ARG # Enable logging diagnostics option
--ipv6 # Enable IPV6 option
--JSONP # allows JSONP to be accessed via HTTP (with security implications)
--maxconns ARG # Maximum simultaneous connection number default 2000
--noauth # does not enable validation
--nohttpinterface # Close HTTP interface, turn off 27018 port access by default
--noprealloc # Disables data file pre-allocation (often affecting performance)
--noscripting # Disable script engine
--notablescan # does not allow table scans
--nounixsocket # disables UNIX socket sniffing
--nssize Arg (=16) # Set letter database. ns file Size (MB)
--objcheck # in receipt of customer data, check the validity,
--profile arg # file Parameters 0=off 1=slow, 2=all
--quota # Limit the number of files per database, set defaults to 8
--quotafiles arg # Number of files Allower per db, requires--quota
--rest # Open a simple rest API
--repair # Repair All database run repair on all DBS
Directory of files generated by the--repairpath arg # Repair library, default to directory name DBPath
--slowms Arg (=100) # Value of slow for profile and console log
--smallfiles # Use a smaller default file
--syncdelay Arg (=60) # Number of seconds to write to disk (0=never, not recommended)
--sysinfo # Print Some diagnostic system Information
--upgrade # If you need to upgrade the database * Replicaton parameters
--------------------------------------------------------------------------------
--fastsync # from a dbpath the Library Replication service is enabled, and the DBPath database is a snapshot of the main library that can be used to quickly enable synchronization
--autoresync # If you are synchronizing data from a library to the main library, automatically resynchronize,
--oplogsize ARG # Set the size of the Oplog (MB) * Main/from parameter
--------------------------------------------------------------------------------
--master # Main Library mode
--slave # from Library mode
--source Arg # from library port number
--only ARG # Specifies a single database replication
--slavedelay ARG # Set delay time from library synchronization master Replica set (replica set) option:
--------------------------------------------------------------------------------
--replset ARG # set replica set name * Sharding (fragment) option
--------------------------------------------------------------------------------
--configsvr # declares that this is a cluster config service, default port 27019, default directory/data/configdb
--shardsvr # declares that this is a cluster of fragments, default port 27018
--nomoveparanoia # Off bigotry for movechunk data save
# All of the above parameters can be written to the mongod.conf configuration document for example:
DBPath =/data/mongodb
logpath =/data/mongodb/mongodb.log
Logappend = true
port = 27017 Fork
= True
Auth = True
e.g:
Copy Code code as follows:
./mongod-shardsvr-replset Shard1-port 16161-dbpath/data/mongodb/data/shard1a-oplogsize 100-logpath/data/mongodb/l Ogs/shard1a.log-logappend-fork-rest