Implementation of MongoDB cluster construction and Sharding

Source: Internet
Author: User
Tags install mongodb

MongoDB cluster creation

MongoDB replication cluster type:

· Master-slave mode (master/slave)

· Replica set mode (replica set)

The copy and mode have at least three nodes (one master node and two slave nodes). The slave node is responsible for copying the oplog of the master node to the local node and applying it to the local node to achieve redundancy.

(· Arbiter: only participates in the election, but does not hold any data

· 0 priority: the election can be triggered, but cannot be elected as the master node.

· You can use repiset to define the cluster name)

------------------------------------------------------------------

MongoDB details: click here
MongoDB: click here

MongoDB backup and recovery

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

How to create a new database and set in MongoDB

MongoDB beginners must read (both concepts and practices)

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

------------------------------------------------------------------

1. Compile and install MongDB

Prepare the environment:

System: 64-bit Debian 7.2

Mongodb: mongodb-linux-x86_64-2.4.5.tgz (under the official website)

Root @ namenode1:/usr/local/tools # tar xfmongodb-linux-x86_64-2.4.5.tgz

Root @ namenode1:/usr/local/tools # mv mongodb-linux-x86_64-2.4.5/usr/local/
Root @ namenode1:/usr/local/tools # cd/usr/local/
Root @ namenode1:/usr/local # ln-s/usr/local/mongodb-linux-x86_64-2.4.5 // usr/local/mongodb

Root @ namenode1:/usr/local # ll | grep mongo
Lrwxrwxrwx 1 root staff 38 March 17 15:35 mongodb->/usr/local/mongodb-linux-x86_64-2.4.5/
Drwxr-sr-x 3 root staff 4096 March 17 15:08 mongodb-linux-x86_64-2.4.5

# Create a user

Root @ namenode1 :~ # Groupadd-r development d
Root @ namenode1 :~ # Useradd-M-r-g mongod-d/data/db-s/bin/false-c mongodmongod

# Creating a directory

Root @ namenode1 :~ # Mkdir-p/var/log/mongo/

Root @ namenode1 :~ # Mkdir-p/mongo/data
Root @ namenode1 :~ # Chown mongod/mongo/data/var/log/mongo/

 

Root @ namenode1 :~ # Ll/var/log/| grep mongo

Drwxr-xr-x 2 mongod root 4096 Mar 17 15: 25 mongo
Root @ namenode1 :~ # Ll/mongo/
Total 4
Drwxr-xr-x 2 mongod root 4096 Mar 17 data

# Add LC_ALL = "C" to the environment variable to prevent startup errors

Root @ namenode1 :~ # Echo 'export LC_ALL = "C" '>/etc/profile

# Create a configuration file (copy the configuration file after installing mongodb In the rpm package)

Root @ namenode1 :~ # Cat/etc/mongod. conf
# Mongo. conf

# Where to log
Logpath =/var/log/mongo/mongod. log

Logappend = true

# Fork and run in background
Fork = true

# Port = 27017

Dbpath =/mongo/data

# Location of pidfile
Pidfilepath =/var/run/mongodb/mongod. pid

# Disables write-ahead journaling
# Nojournal = true

# Enables periodic logging of CPU utilization and I/O wait
# Cpu = true

# Turn on/off security. Off is currently the default
# Noauth = true
# Auth = true

# Verbose logging output.
# Verbose = true

# Inspect all client data for validity on receept (useful
# Developing drivers)
# Objcheck = true

# Enable db quota management
# Quota = true

# Set oplogging level where n is
#0 = off (default)
#1 = W
#2 = R
#3 = both
#7 = W + some reads
# Diaglog = 0

# Ignore query hints
# Nohints = true

# Disable the HTTP interface (Defaults to localhost: 27018 ).
# Nohttpinterface = true

# Turns off server-side scripting. This will result in greatly limited
# Functionality
# Noscripting = true

# Turns off table scans. Any query that wocould do a table scan fails.
# Notablescan = true

# Disable data file preallocation.
# Noprealloc = true

# Specify. ns file size for new databases.
# Nssize = <size>

# Accout token for Mongo monitoring server.
# Mms-token = <token>

# Server name for Mongo monitoring server.
# Mms-name = <server-name>

# Ping interval for Mongo monitoring server.
# Mms-interval = <seconds>

# Replication Options

# In replicated mongo databases, specify here whether this is a slave or master
# Slave = true
# Source = master.example.com
# Slave only: specify a single database to replicate
# Only = master.example.com
# Or
# Master = true
# Source = slave.example.com

Start mongodb

Export LC_ALL = "C"

Root @ namenode2:/usr/local/mongodb/bin # mongod-f/etc/mongod. conf

 

2. Install Rockmongo

RockMongo is a MongoDB management tool written in PHP5. Main features: the New BSD License protocol is used for Fast Installation and is similar to phpmyadmin in mysql.

Root @ namenode1 :~ # Apt-get install apache2 php5 php5-dev php5-cli

Root @ namenode1:/etc/apache2 # cd/var/www/
Root @ namenode1:/var/www # wgethttp: // rock-php.googlecode.com/files/rockdesk-v1.0.11.zip
Root @ namenode1:/var/www # unzip rockmongo-v1.0.11.zip

# Php module for secondary Compilation

Root @ namenode1:/var/www/mongo-php-driver-master # phpize
Root @ namenode1:/var/www/mongo-php-driver-master #./configure
Root @ namenode1:/var/www/mongo-php-driver-master # make & makeinstall

# Find the path of the php Module

Root @ namenode1:/var/www/mongo-php-driver-master # php-I | grepextension_dir

Extension_dir =>/usr/lib/php5/20100525 =>/usr/lib/php5/20100525
Root @ namenode1:/var/www/mongo-php-driver-master # ll/usr/lib/php5/20100525

Total 2084
-Rwxr-xr-x 1 root 2016810 Mar 17 mongo. so

-Rw-r -- 1 root 113072 Dec 12 16:53 pdo. so

# The path where php is installed in the debian system is located below. If it is another system, you need to find it based on the relative path.

Root @ namenode1:/var/www/mongo-php-driver-master # ll/etc/php5/apache2/php. ini

-Rw-r -- 1 root 65755 Dec 12 16:53/etc/php5/apache2/php. ini

Root @ namenode1:/var/www/mongo-php-driver-master # vi/etc/php5/apache2/php. ini

Add content in Row 3 and save and exit

733 extension = mongo. so

 

Restart apache and check whether the url is valid

Root @ namenode1:/etc/init. d/apache restart

Visit the following address:

Http: // 172.23.214.50/rockmongo/index. php? Action = index. login

As shown in, the mongodb management logon interface is displayed normally. By default, both the user name and password are admin.

 

Confirm the user name and password. The logon is successful, as shown below:

  • 1
  • 2
  • 3
  • 4
  • 5
  • Next Page

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.