--------------------------------------------------------------------------------
--configsvr
# Declare this is a cluster config service, default port 27019, default directory/data/configdb
--shardsvr
# Declare this to be a cluster fragment, default port 27018
--nomoveparanoia
# off paranoia for movechunk data save
# All of the above parameters can be written to the mongod.conf configuration document for example:
default)-U [--username] arg usernam e-p [--password] arg password--dbpath arg directly access Mongod database files in the given path, Instead of connecting to a Mongod server-needs to lock the data directory, so cannot be used If a mongod is currently accessing the same path--directoryperdb
preparatory work
Software Environment
Os:oracle Linux 6.5
mongodb:mongodb3.2.3
Deploy schema
Analog has three servers
10.1.5.123:28001 Master Node
10.1.5.123:28002 from Node
10.1.5.123:28003 election node
Replica set Schema: one master, one from, one election node
Download Installation
Download Address: Https://www.mongodb.org/downloads
Mongodb-linux-x86_64-rhel62-3.2.3.tgz
Deployment Steps 1. Create Directories and Users
[Root@devtest mongodb]# mkdir conf data log
[Root@devtest data]# m
interfacesnet: port: 27017 bindIp: 0.0.0.0 # Listen to local interface only, comment to listen on all interfaces.#security:#operationProfiling:replication: replSetName: kgcrs #sharding:## Enterprise-Only Options#auditLog:#snmp:The port parameter in mongodb2.conf is then configured to 27018,mongodb3.conf in the port parameter in the configuration to 27019,mongodb4.conf with the port parameter configured to 27020. The DBPath and LogPath param
This is a creation in
Article, where the information may have evolved or changed.
MongoDB Linux Installation
Download
Cd/usr/local/src
wget http://fastdl.mongodb.org/linux/mongodb-linux-i686-2.4.9.tgz
TAR-XZVF mongodb-linux-i686-2.4.9.tgzMV mongodb-linux-i686-2.4.9. /mongodbchmod 755/usr/local/mongodb/bin//-Rln-s/usr/local/mongodb/bin/mongo/usr/bin/mongoln-s/usr/local/mongodb/bin/mongod/usr/bin/mongod
the router process that the MongoDB is equipped with. It routes all requests and then aggregates the results. It does not itself store data or configuration information but caches information about the configuration server.
C. Configuring the server configuration server stores the configuration information for the cluster: data and slice correspondence. MONGOs does not store data permanently, so it needs a place to store the configuration of the Shard.
It gets the synchronization data from
mongodump.exe backup is to get the current server snapshot through a query and write the snapshot into the disk. Therefore, this method is not saved in real time, because after obtaining the snapshot, the server also has data writing. To ensure backup security, we can also use the fsync lock to temporarily write server data into the cache.
Backup command:
... Bin> mongodump-d test-O backup // (backup is the Backup Directory, which is created in the bin directory by default)
Recovery comma
CopyMongoDB replication is important, especially now that the storage engine does not support click Persistence. Not only can replication be used to deal with failover, data integration, but also read extensions, hot backups, or data sources as offline batches.
1. master-Slave copyingMaster-slave replication is the most common way of MongoDB replication. Can be used for backup, failover, read extension, and more.The basic is to build a master node and one or more from nodes, each from the node
-D: A database instance that needs to be backed up, such as: Test -O: The location where the data is backed up, for example: C:\data\dump, of course, the directory needs to be established in advance, After the backup is complete, the system automatically establishes a test directory under the Dump directory, which contains the backup data for the database instance. Mongodump official note (available through Mongodump--help): Options:--help produce help message-v [--verbose] being more Verbos E
advance, after the backup is completed, the system automatically set up a test directory in the Dump directory, which contains the database instance of the backup data.
Official description of the Mongodump (available through Mongodump--help): Options:--help produce help message-v [--verbose] being more Verbos E (include multiple times for more verbosity e.g.-vvvvv)--version Print the program ' s version and exit-h [--host] arg MONGO host to connect to (/S1,S2 for sets)--port ARG server port. C
= True #noauth: Users are not allowed to recognize Certificate, default True Noauth = True #cpu: Set to True will force MongoDB to report CPU utilization and IO waits every 4s, write log information to standard output or log file.
The default is False. CPU = True #dbpath: Data storage directory. Default:/data/db/dbpath=/home/mongo/mongodb-2.6.8/data/#diaglog: Create a very detailed troubleshooting andDiagn
du can see the changes in the cluster in real time through the rs.status () command. Sharding Similar to replica set, a quorum node is required, but sharding also needs to configure nodes and routing nodes. This is the most complex of the three ways to build a cluster. The deployment diagram is as follows: 1. Start the Data node [Plain]View Plaincopy
./mongod--fork--dbpath.. /data/set1/--logpat
4096 Jul 13:26 bin
drwxr-xr-x 2 root root 4096 Jul 13:34 data
-rw-r--r--1 root ro OT 0 Jul 13:34 logs
3.4 Creating a Linux user
[root@ser6-51 mongodb]# groupadd mongodb
[root@ser6-51 mongodb]# useradd-g mongodb mongodb
[root@ser6-51 mongodb]# chown-r mongodb:mongodb/data/mongodb
[root@ser6-51 ~]# passwd mongodb
changing password for user mong oDB.
New password: Bad
Password:it was based on a dictionary word bad
password:is too simple
retype new password:
quickly filled up, secondary too late to synchronize data, primary members will oplog in the log, so, Secondary members will become obsolete (Stale). It is recommended to have primary members use larger oplog to save enough log of operations. Iv. Creating a configuration document 1. Create a Mongod-initiated configuration file Create a profile on each server and store the configuration file in directory C:\data\. All members in the same replica set m
1, the start of Mongod1.1. Mongod Startup optionsMongod has a number of configurable options, run Mongod--help on the command line to see all the options, and the common options are as follows:
Serial number
Options
Meaning
1
--dbpath
Specifies the data directory, the default value is/data/db (Windows is C:\data\db)
A cluster consists of the following three services:
Shards server: each shard is composed of one or more mongod processes used to store data.
Config server: used to store the metadata information of a cluster, including the information of each shard and chunks.
Route server: used to provide the routing service, connected by the client, so that the entire cluster looks like a single DB Server
In addition, chunks are continuous data blocks in Mongo
A cluster consists of the following three services:
Shards Server: each shard is composed of one or more mongod processes used to store data.Config Server: used to store the Metadata information of a cluster, including the information of each Shard and chunks.Route Server: used to provide the routing service, connected by the Client, so that the entire Cluster looks like a single DB ServerIn addition, Chunks are continuous data blocks in MongoDB. The
installation file/bin path at the end of path:
[Root@ser6-51 init.d]# Su-mongodb
[Mongodb@ser6-51 ~]$ Vi. Bash_profile
Path= $PATH: $HOME/bin:/usr/local/mongodb/bin
[mongodb@ser6-51 ~]$ Source Bash_profile
So you can not go into the/usr/local/mongodb/bin path to use the MONGO command, directly enter the MONGO command.
#root用户省略Three: Start MongoDB
#验证是否安装成功
[mongodb@ser6-51 ~]$ mongod--dbpath=/usr/lo
Tags: mongdb quick StartStatement: The article is mainly from the "MongoDB actual Combat" a book, the main want to learn MongoDB knowledge through the book, deepen understanding, so write in their own blog, as a record, in the final chapter, there will be a collection of MongoDB database application Java EE Web application.The MongoDB Shell is an interactive JavaScript shell that comes with MongoDB and is used to manipulate and manage MongoDB.Use the./mongo--help to view the relevant connection
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.