Configure MongoDB3.04 cluster shards

Source: Internet
Author: User
Tags install mongodb

Configure MongoDB3.04 cluster shards

Most of the network is sharded by the ipv2.x cluster, so I wrote a 3.04 error.
Because the company uses redundant storage of disk arrays, data backup is not considered as a simple partition storage data for testing.
Configuration Structure

Server Configuration:
Dual-core cpu, 8 GB memory, And/shard directory mount a GB hard disk.

Server LIST:

IP Functions
192.168.6.117 Config, mongos
192.168.6.118 Client
192.168.6.119 Client
192.168.6.147 Client
192.168.6.160 Client

First, open these five machines and execute the same command:

Wget https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-3.0.4.tgz
Tar zxvf mongodb-linux-x86_64-3.0.4.tgz
Cp-rf mongodb-linux-x86_64-3.0.4/usr/local/

Open machines 118, 119, 147, and 160 in sequence and execute the following command (Note: Replace the specified 118 with 119 ):

Mkdir/shard/shard11 9
Chmod-R 777/shard/shard119
/Usr/local/mongodb-3.0.4/bin/mongod-shardsvr-port 27017-dbpath =/shard/shard119/-- storageEngine wiredTiger-logpath =/shard/shard119.log -- fork

Then start. Run the following command on the terminal to check whether the Mongod process is successfully started:

Ps aux | grep mongo

If none of them are successfully started, repeat the above until you find the cause.

OK. Now we have successfully started one mongod instance on four computers, and mongod is the process of actually storing data. A configuration server is also required in the cluster to store the configuration information shared by each node and the METADATA of the data [METADATA], as shown in the preceding config.

Open Server 117 and execute the following command:

Mkdir/data/config

/Usr/local/mongodb-3.0.4/bin/mongod-configsvr-dbpath =/data/config-port 20000-logpath =/data/config. log -- fork

When all of the above are successfully started, we can enable the mongos service. Mongo is also executed on 117.

/Usr/local/mongodb-3.0.4/bin/mongos-configdb 192.168.6.117: 20000-port 30000-chunkSize 100-logpath =/data/mongos. log -- fork

Note: the ip address and port corresponding to configdb should be the ip address and port set in config. -ChunkSize: the default Host size is 200. We can set it to 100 or 100 MB.

If the process runs smoothly, you can see the processes running on the two mongo in 117, and run the command: ps-ef | grep mong. Indicates that the mongo multipart installation is complete.

Configure mongo shards as follows:

Connect to the database:

/Usr/local/mongodb-3.0.4/bin/mongo 192.168.6.117: 30000/admin

Note: The following operations are completed under the mongo command line:

Add a partition server:
Db. runCommand ({"addshard": "192.168.6.118: 27017 "})
Db. runCommand ({"addshard": "192.168.6.119: 27017 "})
Db. runCommand ({"addshard": "192.168.6.147: 27017 "})
Db. runCommand ({"addshard": "192.168.6.160: 27017 "})

Set the sharded database:
Db. runCommand ({"enablesharding": "qiaodazhao "})

Database usage:
Use qiaodazhao

Set table sharding Based on Field hash:
Sh. shardCollection ("qiaodazhao. resume_meta_data", {_ id: "hashed "})

Set table sharding Based on fields (note that this form works the same as above ):
Db. runCommand ({"shardcollection": "qiaodazhao. things", "key": {"_ id": 1 }})

Print the database shard information:
Db. printShardingStatus ()

Print Server Information:
Db. serverStatus ()

Create a table index:
Db. resume_meta_data.ensureIndex ({"org_name": 1 },{ "background": true })

View table indexes:
Db. resume_meta_data.getIndexes ()

Print the information here.

Sort out common MongoDB operation commands

MongoDB 3.0 official version released and downloaded

CentOS compilation and installation of MongoDB

CentOS compilation and installation of php extensions for MongoDB and mongoDB

CentOS 6 install MongoDB and server configuration using yum

Install MongoDB2.4.3 in Ubuntu 13.04

MongoDB beginners must read (both concepts and practices)

MongoDB Installation Guide for Ubunu 14.04

MongoDB authoritative Guide (The Definitive Guide) in English [PDF]

Nagios monitoring MongoDB sharded cluster service practice

Build MongoDB Service Based on CentOS 6.5 Operating System

MongoDB details: click here
MongoDB: click here

This article permanently updates the link address:

Related Article

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.