In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-17 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
Nosql: non-relational, distributed, does not provide ACID
Simple data model
Separation of metadata and application data
Weak consistency
Advantages:
Avoid unnecessary complexity
High throughput
High-level scalability and low-end hardware clusters
Do not use object-relational mapping
Disadvantages:
ACID feature is not supported
Simple function
There is no unified data query model
ACID:atomicity atomicity, consistency consistency, isolation isolation, durability persistence
Nosql classification:
Column database (managed by column)
Key value storage
Document database (each line is treated as an entity, a separate file)
A graph storage database (a graph storage object with complex relationships), which is used to store complex relationships between people on social networking sites.
Data Storage Model of nosql
Column database (managed by column)
Data model: data is stored in columns, and the same column of data is stored together
Advantages: fast search, strong expansibility, easy to realize distributed
Disadvantages: the function is limited compared to sql
Application scenarios: distributed file system or distributed storage
Examples: bigtable, cassandra, HBase, hypertable (massive data storage)
Running on a distributed file system
Key-value storage (data model: key-value storage)
Advantage: find it quickly
Disadvantages: data is unstructured and is usually treated only as string or binary data
Application scenarios: content caching
Examples: redis, dynamo
Document database (each line is treated as an entity, a separate file)
Data model: similar to the key-value model, but value points to structured data, with multiple key-value pairs with a container attached to it
Advantages: the data format is not strict and there is no need to define the structure in advance
Adding a field does not need to change its data structure
Disadvantages: low query performance, lack of uniform query syntax
Application scenario: web application
Examples: MongoDB, couchDB
A graph storage database (a graph storage object with complex relationships), which is used to store complex relationships between people on social networking sites.
Data model: Graph structure model
Advantages: using graph structure correlation algorithm, × × × can meet the application requirements of special scenarios.
Disadvantages: it is difficult to achieve distribution, and the function is oriented.
Application scenarios: social network, recommendation system, relationship graph
Example: Neo4J
Mongodb:scalable (Extensible) high-performance (High performance) open source schema free document nosql
Schema free: no need to create data structures beforehand
Read and write in memory
Support for scalability: replication, automatic sharding
Suitable for: web site, cache, high scalability, high volume,low value
Installation of mongodb: rpm package installation is recommended here
Rpm package address: https://repo.mongodb.org/yum/redhat, choose your own version to download
Yum-y localinstall * .rpm
Mkdir-p / mongodb/data: create a data directory and modify the data directory path in the configuration file
Usermod-d / mongodb/data mongod
Chown-R mongod:mongod / mongodb/data: modify the master group of the data catalog
Finally, simply modify the information of the configuration file (data directory, log directory, etc.)
Finally, you can start mongod.
Service mongod start
Check the log record and find the following warning:
Cat / var/log/mongodb/mongod.log checks the log and reports an error as follows:
* * WARNING: soft rlimits too low. Rlimits set to 1024 processes, 64000 files.
Number of processes should be at least 32000: 0.5 times number of files.
Reference: http://blog.csdn.net/kk185800961/article/details/45613267
Mongodb current limit: 1024 processes, 64000 files
Mongodb recommended requirement: processes = 0.5*files=32000 (at least)
So you need to change the processes from 1024 to 32000 or greater.
Modify the configuration file / etc/security/limits.conf to add configuration information:
# for mongodb#
Mongod soft nofile 64000
Mongod hard nofile 64000
Mongod soft nproc 32000
Mongod hard nproc 32000
Then restart mongod, check the log record again, and find that there is no warning, so the installation of mongodb is successful
Simple grud operation of mongodb:
Help (see help)
Db.help () help on db methods
Db.mycoll.help () help on collection methods
Sh.help () sharding helpers
Rs.help () replica set helpers
Help admin administrative help
Help connect connecting to a db help
Help keys key shortcuts
Help misc misc things to know
Help mr mapreduce
Show dbs show database names
Show collections show collections in current database
Show users show users in current database
Show profile show most recent system.profile entries with time > = 1ms
Show logs show the accessible logger names
Show log [name] prints out the last segment of log in memory, 'global' is default
Use set current database
Db.foo.find () list objects in collection foo
Db.foo.find ({a: 1}) list objects in foo where a = = 1
It result of the last line evaluated; use to further iterate
DBQuery.shellBatchSize = x set default number of items to display on shell
Exit quit the mongo shell
View all libraries: show dbs
View all collections (tables in mysql, collections in mongodb): show collections
Switch library: use huangdb (no need to define it before, just use the library)
Insert data into the collection huangcoll: db.huangcoll.insert ({Name: "huang"})
View the data of the collection: db.huangcoll.find (): this is to view all the data of the collection huangcoll
Find data by criteria: db.huangcoll.find ({Name: "huang"}): find documents whose Name is huang
Create index: db.huangcoll.ensureIndex ({Name:1}): create an index on the field Name
View index: db.huangcoll.getIndexes (): view all indexes under the current collection
For more mongo command operations, refer to the documentation:
Https://docs.mongodb.com/manual/crud/
Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.
Views: 0
*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.