In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-31 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
About MongDB 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. 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. MongoDB features high performance, easy to deploy, easy to use, and it is very convenient to store data.
For collection storage, it is easy to store data of object type.
Mode freedom.
Dynamic query is supported.
Full indexing is supported, including internal objects.
Query is supported.
Replication and failure recovery are supported.
Use efficient binary data storage, including large objects such as video, etc.
Automatically handle fragments to support scalability at the cloud computing level.
Support for RUBY,PYTHON,JAVA,C++,PHP,C# and other languages.
The file is stored in BSON (an extension of JSON).
Can be accessed through the network. This case environment: operating system: CentOS 7.3x86x64 install MongoDB: 1. Configure YUM source repository: vim / etc/yum.repos.d/mongodb-org.repo [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.as2. Install MongoDB: yum install-y mongodb-orgsystemctl start mongod.service # enable service systemctl start mongod.service # enable service [root@localhost ~] # mongo # enter database MongoDB shell version v3.6.6connecting to: mongodb://127.0.0.1:27017MongoDB server version: 3.6.6 configure MongoDB stand-alone multi-instance 1. Copy the MongoDB configuration file: cp-p / etc/mongod.conf / etc/mongod2.confvim / etc/mongodb2.confsystemLog: destination: file logAppend: true path: / data/logs/mongod2.log # log file location. Storage: dbPath: / data/mongodb/mongodb2 # data file location journal:.net: port: 27018 # modify port number bindIp: 127.0.0.1 mkdir-p / data/mongodb/mongodb2 # create data file location mkdir-p / data/logs/ # create log file location touch / data/logs/mongodb2.log # create log file chmod-R 777 / data/logs/mongodb2.log # permission to add log files [root@localhost] # mongod-f / etc/mongod2.conf # Open instance about to fork child process Waiting until server is ready for connections.forked process: 23824child process started successfully Parent exiting [root@localhost ~] # mongo-- port 27018 # enter the instance MongoDB shell version v3.6.6connecting to: mongodb://127.0.0.1:27018/MongoDB server version: 3.6.6 [root@localhost ~] # mongod-f / etc/mongod2.conf-- shutdown # close the instance killing process with pid: 23824MongoDB basic Operation description show dbs View the list of databases under the current instance show users displays the current number of user use switches According to the library db.help () display database operation command show collections display current database collection db.foo.help () display collection operation command Foo is the collection under the current database. Db.foo.find () searches the foo collection in the current database to create and delete the database format: use DATABASE_NAME # switch the database if there is a switch No mongos > use abcswitched to db abc format is created: db.dropDatabase () # delete database mongos > use abcswitched to db abcmongos > db.dropDatabase () {"info": "database does not exist", "ok": 1} insert, delete, and modify data mongos > db.test.insert ({"id": 1) "name": "zhangsan"}) # inserting data into the test collection without test collection automatically creates WriteResult ({"nInserted": 1}) mongos > db.test.insert ({"id": 2, "name": "lisi"}) WriteResult ({"nInserted": 1}) mongos > db.test.find () # View the collection content {"_ id": ObjectId ("5b4eb95659122739e2695613") "id": 1, "name": "zhangsan"} {"_ id": ObjectId ("5b4eb96759122739e2695614"), "id": 2, "name": "lisi"} mongos > db.test.remove ({"id": 1}) # Delete data WriteResult ({"nRemoved": 1}) mongos > db.test.find () {"_ id": ObjectId ("5b4eb96759122739e2695614"), "id": 2 from the test collection "name": "lisi"} mongos > db.test.update ({"id": 2}, {$set: {"name": "wangwu"}) # modify data WriteResult ({"nMatched": 1, "nUpserted": 0, "nModified": 1}) mongos > db.test.find () {"_ id": ObjectId ("5b4eb96759122739e2695614"), "id": 2 "name": "wangwu"} data import and export [root@localhost bin] #. / mongoexport-d abc-c test-o / opt/test.json # export file format is json2018-07-18T12:07:50.297+0800 connected to: localhost2018-07-18T12:07:50.299+0800 exported 2 records [root@localhost bin] #. / mongoimport-d abc-c test-file test.json # Import database 2018-07-18T12: 09no such file or directory2018 09.8800800 Failed: open test.json: no such file or directory2018-07-18T12:09:09.881+0800 imported 0 documents parameter description-d: indicates the name of the database-c: indicates the name of the collection-o: indicates the file name to be exported
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.