Diagram of MongoDB principles (II)

Source: Internet
Author: User
Based on the basic introduction in the previous article "graphic MongoDB principles", this article takes the specific operation as an example to continue in-depth analysis of mongodb. All the services demonstrated are on one machine. My directory is F: JAVAMongoDBcluster. The file structure is as follows: Note: One configuration service node and one routing service node, three partition nodes. VcD4KPHA + PHN0cm9u

Based on the basic introduction in the previous article "graphic MongoDB principles", this article takes the specific operation as an example to continue in-depth analysis of mongodb. All the services demonstrated are on one machine. My directory is F: \ JAVA \ MongoDB \ cluster. The file structure is as follows: Description: 1 configuration service node, one routing service node and three partition nodes. VcD4KPHA + PHN0cm9u

Based on the basic introduction in the previous article "graphic MongoDB principles", this article takes the specific operation as an example to continue in-depth analysis of mongodb.

All the services demonstrated are on one machine. My directory is F: \ JAVA \ MongoDB \ cluster. The file structure is as follows:

Note: One configuration service node, one routing service node, and three partition nodes.
<喎?http: www.2cto.com kf ware vc " target="_blank" class="keylink"> VcD4KPHA + signature + zvE8L3A + signature/Signature + signature/L + dPQt9bGrLf + zvE8L3A + signature/7O8TwvcD4KPHA + signature + Signature signature + signature + Cn08L3A + CjxwPjihorbUyv2 + 3b/Signature + signature + CjxwPjmhorLp0a/L + signature + Cn08YnI + c1_vcd4kpha + signature + Signature shard = "t find a shard to put new db on ",
"Code": 10185
} At src/mongo/shell/query. js: 128

When the previous task is not completed, an error is returned:

Mongos> db. runCommand ({removeshard: "127.0.0.1: 27032 "})
{"OK": 0, "errmsg": "Can't have more than one draining shard at a time "}

MongoVUE connection test

The connection interface is as follows:

View parts:

Size of each chunk (unit: MB ):

Effect of storing data in a single shard:

The Balancer operation process after shard2 and shard3 is added:

Split data:

View all databases. If partitioned is set to True, shards are set for this database.


Config database structure:

Check the service status. The maximum number of connections supported by MongoDB is 20000:

Mongod startup parameters

When an error is reported for the startup parameter, a message is displayed, which can be explained in English:

General options:
-H [-- help] show this usage information
-- Version show version information
-F [-- config] arg configuration file specifying additional options
-V [-- verbose] be more verbose (include multiple times for more
Verbosity e.g.-vvvvv)
-- Quiet quieter output
-- Port arg specify port number-27017 by default
-- Bind_ip arg comma separated list of ip addresses to listen on
-All local ips by default
-- MaxConns arg max number of simultaneous connections-20000
Default
-- Logpath arg log file to send write to instead of stdout-has
To be a file, not directory
-- Logappend append to logpath instead of over-writing
-- Pidfilepath arg full path to pidfile (if not set, no pidfile is
Created)
-- KeyFile arg private key for cluster authentication
-- SetParameter arg Set a parameter able parameter
-- Auth run with security
-- Cpu periodically show cpu and iowait utilization
-- Dbpath arg directory for datafiles-defaults to \ data \ db \
-- Diaglog arg 0 = off 1 = W 2 = R 3 = both 7 = W + some reads
-- Directoryperdb each database will be stored in a separate
Directory
-- Ipv6 enable IPv6 support (disabled by default)
-- Journal enable journaling
-- JournalCommitInterval arg how often to group/batch commit (MS)
-- JournalOptions arg journal diagnostic options
-- Jsonp allow JSONP access via http (has security
Implications)
-- Noauth run without security
-- Nohttpinterface disable http interface
-- Nojournal disable journaling (journaling is on by default
For 64 bit)
-- Noprealloc disable data file preallocation-will often hurt
Performance
-- Noscripting disable scripting engine
-- Notablescan do not allow table scans
-- Nssize arg (= 16). ns file size (in MB) for new databases
-- Profile arg 0 = off 1 = slow, 2 = all
-- Quota limits each database to a certain number of files
(8 default)
-- QuotaFiles arg number of files allowed per db, requires -- quota
-- Repair run repair on all dbs
-- Repairpath arg root directory for repair files-defaults
Dbpath
-- Rest turn on simple rest api
-- Slowms arg (= 100) value of slow for profile and console log
-- Smallfiles use a smaller default file size
-- Syncdelay arg (= 60) seconds between disk syncs (0 = never, but not
Recommended)
-- Sysinfo print some diagnostic system information
-- Upgrade db if needed

Windows Service Control Manager options:
-- Install Windows service
-- Remove Windows service
-- Reinstall Windows service (equivalent to -- remove
Followed by -- install)
-- ServiceName arg Windows service name
-- ServiceDisplayName arg Windows service display name
-- ServiceDescription arg Windows service description
-- ServiceUser arg account for service execution
-- ServicePassword arg password used to authenticate serviceUser

Replication options:
-- OplogSize arg size to use (in MB) for replication op log. default is
5% of disk space (I. e. large is good)

Master/slave options (old; use replica sets instead ):
-- Master mode
-- Slave mode
-- Source arg when slave: specify master
-- Only arg when slave: specify a single database to replicate
-- Slavedelay arg specify delay (in seconds) to be used when applying
Master ops to slave
-- Autoresync automatically resync if slave data is stale

Replica set options:
-- ReplSet arg is [/ ]
-- ReplIndexPrefetch arg specify index prefetching behavior (if secondary)
[None "_ id_only | all]

Sharding options:
-- Configsvr declare this is a config db of a cluster; default port
27019; default dir/data/configdb
-- Shardsvr declare this is a shard db of a cluster; default port
27018

Mongos startup parameters

General options:
-H [-- help] show this usage information
-- Version show version information
-F [-- config] arg configuration file specifying additional options
-V [-- verbose] be more verbose (include multiple times for more
Verbosity e.g.-vvvvv)
-- Quiet quieter output
-- Port arg specify port number-27017 by default
-- Bind_ip arg comma separated list of ip addresses to listen on-all
Local ips by default
-- MaxConns arg max number of simultaneous connections-20000
Default
-- Logpath arg log file to send write to instead of stdout-has to be
A file, not directory
-- Logappend append to logpath instead of over-writing
-- Pidfilepath arg full path to pidfile (if not set, no pidfile is
Created)
-- KeyFile arg private key for cluster authentication
-- SetParameter arg Set a parameter able parameter
-- Nohttpinterface disable http interface

Windows Service Control Manager options:
-- Install Windows service
-- Remove Windows service
-- Reinstall Windows service (equivalent to -- remove
Followed by -- install)
-- ServiceName arg Windows service name
-- ServiceDisplayName arg Windows service display name
-- ServiceDescription arg Windows service description
-- ServiceUser arg account for service execution
-- ServicePassword arg password used to authenticate serviceUser

Sharding options:
-- Configdb arg 1 or 3 comma separated config servers
-- LocalThreshold arg ping time (in MS) for a node to be considered local
(Default 15 ms)
-- Test just run unit tests
-- Upgrade meta data version
-- ChunkSize arg maximum amount of data per chunk
-- Ipv6 enable IPv6 support (disabled by default)
-- Jsonp allow JSONP access via http (has security implications)
-- Noscripting disable scripting engine

Partition + Master/Slave installation command

The master-slave deployment does not have the automatic failover function, and the deployment of the replica set supports failover.

Primary data node:
Mongod-shardsvr-master-port 27001-dbpath F: \ JAVA \ MongoDB \ cluster \ shard \ data
Slave Data Node:
Mongod-shardsvr-slave-source 127.0.0.1: 27001-port 27002-dbpath F: \ JAVA \ MongoDB \ cluster \ shards \ data

Multipart + replica set installation

To install the replica set, you must set each shard. Use mongo to directly connect to the shard and execute rs. initiate (cfg) to set the shard. After setting the shard, you must add each shard to the config. Related functions include:

Rs. status () {replSetGetStatus: 1} checks repl set status
Rs. initiate () {replSetInitiate: null} initiates set with default settings
Rs. initiate (cfg) {replSetInitiate: cfg} initiates setwith configuration cfg
Rs. conf () get the current configuration object from local. system. replset
Rs. reconfig (cfg) updates the configuration of a running replica set with cfg (disconnects)
Rs. add (hostportstr) add a new member to the set with default attributes (disconnects)
Rs. add (membercfgobj) add a new member to the set with extra attributes (disconnects)
Rs. addArb (hostportstr) add a new member which is arbiterOnly: true (disconnects)
Rs. stepDown ([secs]) step down as primary (momentarily) (disconnects)
Rs. syncFrom (hostportstr) make a secondary to sync from the givenmember
Rs. freeze (secs) make a node ineligible to become primary for the time specified
Rs. remove (hostportstr) remove a host from the replica set (disconnects)
Rs. slaveOk () shorthand for db. getMongo (). setSlaveOk ()

Start command

Route node:
Mongos-configdb 127.0.0.1: 20000-port 30000-chunkSize 5

Configuration node:

Mongod-configsvr-dbpath F: \ JAVA \ MongoDB \ cluster \ config \ data-port 20000-rest

Part 1:
Mongod-shardsvr-replSet shard1/127.0.0.1: 27051,127.0 .0.1: 27041-port 27031-dbpath F: \ JAVA \ MongoDB \ cluster \ repa_shard1 \ data

Shard 1 replica Set B:
Mongod-shardsvr-replSet shard1/127.0.0.1: 27051-port 27041-dbpath F: \ JAVA \ MongoDB \ cluster \ repb_shard1 \ data

Shard 1 replica set c:
Mongod-shardsvr-replSet shard1/127.0.0.1: 27041-port 27051-dbpath F: \ JAVA \ MongoDB \ cluster \ repc_shard1 \ data

Part 2:
Mongod-shardsvr-replSet shard2/127.0.0.1: 27052,127.0 .0.1: 27042-port 27032-dbpath F: \ JAVA \ MongoDB \ cluster \ repa_shard2 \ data

Shard 2 replica Set B:
Mongod-shardsvr-replSet shard2/127.0.0.1: 27052-port 27042-dbpath F: \ JAVA \ MongoDB \ cluster \ repb_shard2 \ data

Shard 2 replica set c:
Mongod-shardsvr-replSet shard2/127.0.0.1: 27042-port 27052-dbpath F: \ JAVA \ MongoDB \ cluster \ repc_shard2 \ data

WEB Console

The Slice service and the Configuration Service's mongod plus-rest will have a web Console, the specific address will be available in the startup output, as shown below


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.