Architect Journal--mongodb Introduction and installation Usage

Source: Internet
Author: User
Tags install mongodb unix domain socket uuid yum install mongodb
What's MongoDB?

MongoDB is an open-source, document-oriented NoSQL (not only SQL) database written using C + +, and one of the most popular NoSQL databases.
A relational database is record-oriented, and an item in a relational database is a record, and in a relational database an item is a document, for example

Age
UUID name
1 U1 Zhangsan

In NoSQL is {"UUID": 1, "userId": "U1", "Name": Zhangsan} NoSQL Introduction

NoSQL means "Not just SQL", is the current popular "non-relational database" collectively.
Common NoSQL database such as: Redis, CouchDB, MongoDB, HBase, Cassandra, etc. why need nosql.

Simply put, is to solve in the web2.0 era, the emergence of three high requirements:
1: High concurrent read and write requirements for the database
2: The need for efficient storage and access to massive amounts of data
3: High scalability and high availability requirements for the database
Some of the features inside the RDB often become less important in web2.0, such as:
1: Database Transaction consistency
2: Real-time database reading and writing
3: Complex SQL queries, especially the CAP theorem for multiple table association queries , also known as the brewer theorem (Eric Brewer)

It points out that for a distributed computing system, the following three points cannot be met simultaneously:
1: Strong consistency (consistency): The system is still consistent after performing an operation, in a distributed system, all users should read the latest values after the successful execution of the update operation, such system is considered strong consistency
2: Availability (availability): Each operation is always able to return results within a certain amount of time
3: Partition fault tolerance (Partition tolerance): The system can still accept requests and processes in the presence of a network partition, where the network partition refers to the network being partitioned into isolated areas for some reason, and the regions are disconnected from each other. According to the CAP principle, the database is divided into three categories: meeting the CA principle, satisfying CP principle and satisfying AP principle.

1:CA: Single point cluster, satisfying consistency, usability, usually not very strong in scalability, such as Rdb
2:CP: Meet consistency and partitioning fault tolerance, usually not particularly high performance, such as distributed database
3:AP: To meet availability and partitioning fault tolerance, it is often possible to lower consistency requirements, such as most NoSQL BASE (basically available,soft-state,eventual consistency)

1: Basic available (basically Available): The system can basically run, always provide services.
2: Soft State (Soft-state): The system does not require constant strong consistent state.
3: Final consistency (eventual consistency): system needs to achieve consistency after a certain moment the advantages of NoSQL are simple and convenient, especially horizontal scaling (vertical expansion refers to the use of a stronger machine; horizontal scaling means spreading data across multiple machines) Read-write fast and efficient, most will be mapped to the low cost of memory operation, with a common machine, distributed clustering can be data model flexibility, no fixed data model NoSQL's shortcomings do not provide support for SQL existing products are not mature and stable, function has yet to be strengthened MongoDB features high performance, ease of use, easy to expand, feature-rich oriented collection storage, mode free support dynamic query, support JavaScript expression query support index support replica set replication and automatic failback Automatic processing fragmentation support for binary and large object data The file storage format is Bson (an extension of JSON) installed MongoDB

Ubuntu

sudo apt-get install MongoDB

CentOS

sudo yum install MongoDB
Start Mongodb-server
Mongod
Start Mongodb-client
Mongo
Close MongoDB
Pkill Mongod

Or start mongodb-client, enter

Use admin
db.shutdownserver ()

Startup parameter Configuration
When you start Mongodb-server, you can add many parameters after Mongod, as follows–quiet# quiet Output–port Arg# Specify the service port number, default port 27017–bind_ip Arg# Binding Service IP, if bound 127.0.0.1, only native access, do not specify default local all IP–logpath Arg# Specify MongoDB log file, note that the specified file is not a directory–logappend# Write logs with an Append method–pidfilepath Arg# The full path of PID file, if not set, then no PID files–keyfile Arg# The full path of the private key of the cluster, valid only for the replica Set schema–unixsocketprefix Arg# UNIX domain Socket substitution directory, (default/TMP)–fork# run MongoDB as a daemon, creating a server process–auth# Enable authentication–cpu# Show CPU utilization and iowait on a regular basis–dbpathARG # Specify the database path–diaglog Arg# diaglog option 0=off 1=w 2=r 3=both 7=w+some–directoryperdb# Set each database will be saved in a separate directory–journal# Enable logging option, MONGODB data operations will be written to the file in the Journal folder–journaloptionsARG # Enable Logging diagnostics option–ipv6# Enable IPV6 option–jsonp# Allow JSONP to be accessed via HTTP (with security implications)–maxconnsARG # Maximum simultaneous connection number default 2000–noauth# Do not enable validation–nohttpinterface# Close HTTP interface, turn off 27018 port access by default–noprealloc# Disable data file pre-allocation (often impacting performance)–noscripting# Disable script engine–notablescan# Do not allow table scans–nounixsocket# Disable UNIX socket sniffing–nssize Arg(=16) # Set letter database. ns file Size (MB)–objcheck# in receipt of customer data, check the validity,–profile Arg# file Parameters 0=off 1=slow, 2=all–quota# limit the number of files per database, set defaults to 8–quotafiles Arg# Number of files Allower per db, Requires–quota–rest# Open a simple rest API–repair# Repair all database run repair on all DBS–repairpath Arg# The directory of the files generated by the repair library, which defaults to the directory name DBPath–slowms Arg (=100)# Slow values for configuration files and console logs–smallfiles# Use a smaller default file–syncdelay Arg (=60)# Number of seconds to write data to disk (0=never, not recommended)–sysinfo# Print some diagnostic system Information–upgrade# If you need to upgrade your database
Replicaton Parameters –fastsync# from a DBPath the Library Replication service is enabled, and the DBPath database is a snapshot of the master library, which can be used to quickly enable synchronization–autoresync# If you sync data from the library to the main library, you'll automatically resynchronize,–oplogsize Arg# Set the size of the Oplog (MB)
master/From Parameters –master# Main Library Mode–slave# from Library mode–sourceARG # from the Library port number–only Arg# Specify a single database replication–slavedelayARG # Sets the delay time for synchronizing the main library from the library
Replica Set (replica set) option: –replset Arg# set the replica set name
Sharding (fragmentation) options –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

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.