In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-02-28 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >
Share
Shulou(Shulou.com)06/03 Report--
Article directory 1, MongoDB: 2, Linux system installation MongoDB: step 1: configure YUM source warehouse step 2: install MongoDB 3, MongoDB basic operation 1, basic commands: 2, backup and restore: 3, security management: 4, process management: 5, MongoDB monitoring: 1, MongoDB:
(1) MongoDB is a database based on distributed file storage. Written in C++ language. Designed to provide scalable high-performance data storage solutions for WEB applications.
(2) MongoDB is a product between relational database and non-relational database, which is the most functional and most like relational database in non-relational database. It supports a very loose data structure, which is similar to json's bson format, so it can store more complex data types. The most important feature of Mongo is that the query language it supports is very powerful, and its syntax is somewhat similar to the object-oriented query language. It can almost achieve most of the functions similar to the single table query of relational database, and also supports the establishment of data indexing.
(3) characteristics:
For collective storage, easy to store data of object type; free schema, support query, support dynamic query; support full index, including internal objects; support replication and fault recovery; use efficient binary data storage, including large objects (such as video, etc.); automatically handle fragmentation to support scalability of cloud computing level; support multiple languages such as RUBY,PYTHON,JAVA,C++,PHP,C# The file is stored in BSON (an extension of JSON); it is accessible over the network. Second, Linux system installation MongoDB: 1, configure YUM source warehouse [mongodb-org] name=MongoDB Repositorybaseurl= https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/3.6/x86_64/gpgcheck=1enabled=1gpgkey=https://www.mongodb.org/static/pgp/server-3.6.asc2, Install MongoDByum install mongodb-org-y modify configuration file: vim / etc/mongod.confbindIp: 0.0.0.0 / / listen address port: 27017 / / listen port open service: systemctl start mongod.service# check service startup netstat-natp | grep 27017 start MongoDB multiple instances: cp-p / etc/mongod.conf / etc/mongod2.confvim / etc/mongod2.conf / / modify the following code: path: / data/mongodb/mongod2.log / / log file directory dbPath: / data/mongodb/mongo / / data storage directory port: 27018 / / server port
Create the directory and log files of the instance: mkdir-p / data/mongodb/cd / data/mongodb/mkdir mongo# create the log file touch mongod2.log# give permission to chmod 777 mongod2.log start the instance: mongod-f / etc/mongod2.conf mongo-- port 27018 / / specify the port netstat-ntap of the instance 3, MongoDB basic operations 1, basic commands:
(1) documents: rows equivalent to relational databases (multiple documents form a collection)
(2) Collection: a table equivalent to a relational database (multiple collections make up the database)
(3) the special function of database name:
Admin: add a user to this library, who inherits all the permissions of the database; local: this library is never copied and can be stored in any collection limited to a single local server; config: when Mongo is used for sharding settings, this library is used internally to store sharding information. Mongo / / enter the database > db.version () / / View version > show dbs; / / View database > db.getMongo () / / View the connection address of the current database machine > db. Collection name .help / / Show collection operation command > show users / / Show user
(4) specific operation:
> use school / / Open the school database. If it does not exist, it will be created. If you do not create a collection, delete > db.createCollection ('info') / / create a collection > db.info.insert ({"id": 1, "name": "zhangsan", "hobby": ["game" "talk"]}) / / add data > db.info.find () / / View all documents in the info collection > show collections / / View all collections in the database > db.info.update ({"id": 10} {$set: {"name": "tom"}) / / change the data > db.info.remove ({"id": 2}) / / remove the data from the id2 in the info collection > db.info.drop () / / delete the info collection > db.dropDatabase () / / delete the database first use to the database to be deleted before deleting > db.info. Count () / / count how many pieces of data there are
(5) MongoDB data type:
String: string, most commonly used, must be utf-8Boolean: Boolean, true or falseInteger: integer Double: floating point Arrays: array or list, multiple values are stored in a key Object: used to embed a document, that is, a value is a document Null: store null values Binary Data: binary data Date: store the current date or time unix time format
(6) View the data type:
> a=db.info.findOne ({"id": 1}) / / find the specified record and give it an alias a > typeof (a.id) / / View attribute type 2, backup, restore:
(1) Import and export:
Export: mongoexport Import: mongoimport Common options:
-d database
-c set
-o directory file ends with .json
-Q derive data filtering conditions
-f which columns are exported for (var item1) I use admin > db.createUser ({"zkc": "root", "pwd": "123"," roles ": [" root "]}) / / create user zkc password 123 assigned to root role > db.auth (" root ") 4. Process management: terminating running processes: db.killOp (opid value), viewing currently running processes: db.currentOp () > db.currentOp () / / View > db.killOp (4872) / / terminating 4872 processes 5, MongoDB monitoring: MongoDB provides some built-in tools to monitor database status information and view database instance status information: db.serverStatus () to view database statistics: db.stats () you can also view system monitoring information through the web interface. You need to add vim / etc/mongod.confhttpinterface=true to the configuration file.
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.