Home PC Games Linux Windows Database Network Programming Server Mobile  
           
  Home \ Database \ MongoDB fragmentation (Cluster)     - CentOS 6 compiling httpd-2.4.10 (Server)

- Linux, C programming language library file handling and preparation of Makefile (Programming)

- VMware ghost Linux card error (Linux)

- Use OpenSSL carried BASE64 encoding and decoding (Linux)

- 10 really interesting Linux command (Linux)

- Linux kernel to achieve soft RPS network to receive soft interrupt load balancing to distribute (Linux)

- CentOS 7.0 running Docker kernel error solution (Server)

- Distributed transaction management Spring declarative transactions (Programming)

- Oracle Client Easy Connection error ORA-12154, TNS-03505 (Database)

- Firewall settings oracle remote connection in Linux systems (Linux)

- Ubuntu 14.04 LTS installed Hadoop 1.2.1 (distributed cluster mode) (Server)

- hadoop 2.7.1 High Availability Setup Deployment (Server)

- Compiled version of Android Opus audio codec library method (Programming)

- Java Collections Framework interfaces map (Programming)

- Ubuntu and Derivative Edition users install LMMS 0.4.15 (Linux)

- History and Statistics tuptime use tools to view Linux server system boot time (Server)

- Netcat Example (Linux)

- build Android environment on Ubuntu 12.04 (Server)

- Linux command line to put on your coat GUI (Linux)

- How to Install Winusb in Ubuntu 14.04 (Linux)

 
         
  MongoDB fragmentation (Cluster)
     
  Add Date : 2018-11-21      
         
         
         
  Basic environment:

Because of resource constraints, only the relationship between the three virtual machines, only two replicaSet, each machine configuration are as follows:

10.10.1.55 machine installation Primary1, configServer1, Arbiter1

10.10.1.56 installation Primary2, configServer2, Arbiter2

10.10.1.57 installation Secondary1, Secondary2, configServer3, mongos

1.55 machine configuration file as follows:

Primary1 the conf file:

dbpath = / data / mongodb / rs0_0
logpath = / data / mongodb / log / rs0_0.log
logappend = true
port = 40000
bind_ip = 192.168.11.55,10.10.1.55
oplogSize = 10000
fork = true
journal = true
#noprealloc = true
replSet = rs0
directoryperdb = true
Arbiter1 profile:

dbpath = / data / mongodb / rs0_arbiter
logpath = / data / mongodb / log / rs0_arbiter.log
logappend = true
port = 40002
bind_ip = 192.168.11.55,10.10.1.55
oplogSize = 10000
fork = true
journal = true
#noprealloc = true
replSet = rs0
directoryperdb = true
ConfigServer1 profile:

dbpath = / data / mongodb / rs0_conf
logpath = / data / mongodb / log / rs0_conf.log
logappend = true
port = 40006
bind_ip = 192.168.11.55,10.10.1.55
fork = true
journal = true
#noprealloc = true
configsvr = true
directoryperdb = true
Respectively, to start the process through different mongo mongod --config filename, after a successful start by netstat can be viewed on the machine were assigned Primary1 1.55 port: 40000, Arbiter1 port: 40002, configureServer1 port: 40006

1.56 machine configuration:

Primary2 profile:

dbpath = / data / mongodb / rs1_primary
logpath = / data / mongodb / log / rs1_p.log
logappend = true
bind_ip = 192.168.11.56,10.10.1.56
directoryperdb = true
port = 40003
oplogSize = 10000
fork = true
journal = true
noprealloc = true
replSet = rs1
Arbiter2 profile:

dbpath = / data / mongodb / rs1_arbiter
logpath = / data / mongodb / log / rs1_a.log
logappend = true
bind_ip = 192.168.11.56,10.10.1.56
directoryperdb = true
port = 40005
oplogSize = 10000
fork = true
journal = true
noprealloc = true
replSet = rs1
ConfigureServer2 profile:

dbpath = / data / mongodb / rs1_conf
logpath = / data / mongodb / log / rs1_conf.log
logappend = true
bind_ip = 192.168.11.56,10.10.1.56
directoryperdb = true
port = 40007
oplogSize = 10000
fork = true
journal = true
noprealloc = true
configsvr = true
Respectively, to start the process through different mongo mongod --config filename, after a successful start by netstat can be viewed on the machine were assigned Primary2 1.55 port: 40003, Arbiter2 port: 40005, configureServer2 port: 40007

1.56 machine configuration:

rs0_Secondary1 configuration:

dbpath = / data / mongodb / rs0_secondary1
logpath = / data / mongodb / log / rs0_secondary1.log
logappend = true
port = 40001
bind_ip = 192.168.11.57,10.10.1.57
oplogSize = 10000
fork = true
journal = true
#noprealloc = true
replSet = rs0
directoryperdb = true
rs1_Secondary1 configuration:

dbpath = / data / mongodb / rs1_secondary1
logpath = / data / mongodb / log / rs1_secondary1.log
logappend = true
bind_ip = 192.168.11.57,10.10.1.57
directoryperdb = true
port = 40004
oplogSize = 10000
fork = true
journal = true
noprealloc = true
replSet = rs1
configureServer3 configuration:

dbpath = / data / mongodb / confSvr3
logpath = / data / mongodb / log / conf3.log
logappend = true
bind_ip = 192.168.11.57,10.10.1.57
directoryperdb = true
port = 40008
oplogSize = 10000
fork = true
journal = true
configsvr = true
mongos configuration :( start mongos router to pay attention to more than one server time must be synchronized, otherwise an error)

logpath = / data / mongodb / log / mongos.log
port = 40009
configdb = 10.10.1.55: 40006,10.10.1.56: 40007,10.10.1.57: 40008
fork = true
Respectively, to start the process through different mongo mongod --config filename, after a successful start by netstat can be viewed on the machine were assigned rs0_secondary1 1.55 port: 40001, rs1_secondary1 port: 40004, configureServer3 port: 40008, mongos routing port: 40009

Now with the mongo shell login primary1 configuration replicaSet0, follow these steps:

cfg = { "_id": "rs0", "members": [{ "_id": 0, "host": "10.10.1.55:40000"}, { "_id": 1, "host": "10.10. 1.57: 40001 "}]}

rs.initiate (cfg)
rs.status ()

rs.addArb ( "10.10.1.55:40002")


Now with the mongo shell login primary2 configuration replicaSet1, follow these steps:

cfg = { "_id": "rs1", "members": [{ "_id": 0, "host": "10.10.1.56:40003"}, { "_id": 1, "host": "10.10. 1.57: 40004 "}]}

rs.initiate (cfg)
rs.status ()

rs.addArb ( "10.10.1.56:40005")

Login using mongo shell fragments mongos add routing information:

mongo --host 10.10.1.57 --port 40009
mongos> sh.addShard ( "rs0 / 10.10.1.55: 40000,10.10.1.57: 40001")
{ "ShardAdded": "rs0", "ok": 1}
mongos> sh.addShard ( "rs1 / 10.10.1.56: 40003,10.10.1.57: 40004")
{ "ShardAdded": "rs1", "ok": 1}
mongos> sh.status ()
--- Sharding Status ---
  sharding version: {
    "_id": 1,
    "Version": 4,
    "MinCompatibleVersion": 4,
    "CurrentVersion": 5,
    "ClusterId": ObjectId ( "561c7bdd4315b18f9862adb4")
}
  shards:
    { "_id": "Rs0", "host": "rs0 / 10.10.1.55: 40000,10.10.1.57: 40001"}
    { "_id": "Rs1", "host": "rs1 / 10.10.1.56: 40003,10.10.1.57: 40004"}
  databases:
    { "_id": "Admin", "partitioned": false, "primary": "config"}
Now create a new database to test slice:

mongos> use people
switched to db people
mongos> for (var i = 1; i < 10; i ++) db.customers.insert ({name: "jordan" + i, country: "American"})
WriteResult ({ "nInserted": 1})
mongos> for (var i = 1; i < 10; i ++) db.customers.insert ({name: "gaga" + i, country: "American"})
WriteResult ({ "nInserted": 1})
mongos> for (var i = 1; i < 10; i ++) db.customers.insert ({name: "ham" + i, country: "UK"})
WriteResult ({ "nInserted": 1})
mongos> for (var i = 1; i < 10; i ++) db.customers.insert ({name: "brown" + i, country: "UK"})
WriteResult ({ "nInserted": 1})
mongos> for (var i = 1; i < 10; i ++) db.customers.insert ({name: "ramda" + i, country: "Malaysia"})
WriteResult ({ "nInserted": 1})

Start building fragment:

mongos> db.customers.ensureIndex ({country: 1, _id: 1})
{
    "Raw": {
        "Rs0 / 10.10.1.55: 40000,10.10.1.57: 40001": {
            "CreatedCollectionAutomatically": false,
            "NumIndexesBefore": 1,
            "NumIndexesAfter": 2,
            "Ok": 1
        }
    },
    "Ok": 1
}
mongos> sh.shardCollection ( "people.customers", {country: 1, _id: 1})
{ "Collectionsharded": "people.customers", "ok": 1}
mongos> sh.status ()
--- Sharding Status ---
  sharding version: {
    "_id": 1,
    "Version": 4,
    "MinCompatibleVersion": 4,
    "CurrentVersion": 5,
    "ClusterId": ObjectId ( "561c7bdd4315b18f9862adb4")
}
  shards:
    { "_id": "Rs0", "host": "rs0 / 10.10.1.55: 40000,10.10.1.57: 40001"}
    { "_id": "Rs1", "host": "rs1 / 10.10.1.56: 40003,10.10.1.57: 40004"}
  databases:
    { "_id": "Admin", "partitioned": false, "primary": "config"}
    { "_id": "Test", "partitioned": false, "primary": "rs0"}
    { "_id": "People", "partitioned": true, "primary": "rs0"}
        people.customers
            shard key: { "country": 1, "_id": 1}
            chunks:
                rs0 1
            { "Country": { "$ minKey": 1}, "_id": { "$ minKey": 1}} - >> { "country": { "$ maxKey": 1}, "_id": { "$ maxKey": 1}} on: rs0 Timestamp (1, 0)
Now that the data is only a small slice on rs0, by increasing the amount of data to improve fragment:

for (var i = 10; i < 10000; i ++) db.customers.insert ({name: "ham" + i, country: "UK"})
for (var i = 10; i < 10000; i ++) db.customers.insert ({name: "ramda" + i, country: "Malaysia"})
mongos> sh.status ()
--- Sharding Status ---
  sharding version: {
   "_id": 1,
   "Version": 4,
   "MinCompatibleVersion": 4,
   "CurrentVersion": 5,
   "ClusterId": ObjectId ( "561c7bdd4315b18f9862adb4")
}
  shards:
   { "_id": "Rs0", "host": "rs0 / 10.10.1.55: 40000,10.10.1.57: 40001"}
   { "_id": "Rs1", "host": "rs1 / 10.10.1.56: 40003,10.10.1.57: 40004"}
  databases:
   { "_id": "Admin", "partitioned": false, "primary": "config"}
   { "_id": "Test", "partitioned": false, "primary": "rs0"}
   { "_id": "People", "partitioned": true, "primary": "rs0"}
       people.customers
           shard key: { "country": 1, "_id": 1}
           chunks:
               rs1 2
               rs0 1
           { "Country": { "$ minKey": 1}, "_id": { "$ minKey": 1}} - >> { "country": "American", "_id": ObjectId ( "561c7da73af7c7865defefb1") } on: rs1 Timestamp (2, 0)
           { "Country": "American", "_id": ObjectId ( "561c7da73af7c7865defefb1")} - >> { "country": "UK", "_id": ObjectId ( "561c7db63af7c7865defefd4")} on: rs0 Timestamp (3 , 1)
           { "Country": "UK", "_id": ObjectId ( "561c7db63af7c7865defefd4")} - >> { "country": { "$ maxKey": 1}, "_id": { "$ maxKey": 1} } on: rs1 Timestamp (3, 0)


There is a slice on rs0 Now, there are two slices on rs1
     
         
         
         
  More:      
 
- SolrCloud-5.2.1 cluster deployment and testing (Server)
- To get Java class / jar package path (Programming)
- Oracle 12c PDB Analysis (Database)
- Java to achieve local fileCopy (Programming)
- Ubuntu derivative version of the user and how to install SmartGit / HG 6.0.0 (Linux)
- CentOS 5.8 (64) Python 2.7.5 installation error resolved (Linux)
- BCP importing and exporting large amounts of data Practice (Database)
- Partition and file system under Linux (Linux)
- How to Install Apache on Linux servers (Server)
- Linux operation and maintenance of the actual file system, file links (Linux)
- Ubuntu 12.04 commonly use shortcuts finishing Share (Linux)
- VirtualBox modify the size of the virtual machine disk VDI (Linux)
- How to use awk command in Linux (Linux)
- MySQL Parameter Tuning Best Practices (Database)
- WordPress plug-ins installed in Ubuntu, enter the subject of FTP and not create directory problem (Server)
- About Python default character set (Linux)
- Binary search and modification (Programming)
- Linux package management (Linux)
- How to experience Unity 8 Mir on Ubuntu 16.04 (Linux)
- Linux protobuf-c (Linux)
     
           
     
  CopyRight 2002-2022 newfreesoft.com, All Rights Reserved.