Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MongoDB-Manual-Master Reading Notes-introduction and installation

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

MongoDB

1.1 What is MongoDB?

MongoDB is an open source document database that provides high performance, high availability, and high scalability.

1.1.1 Document database

A record in MongoDB is called a document, which can also be understood as a row in a relational database. Documents consist of key-value pairs, similar to JSON objects. Values can consist of documents, arrays, or arrays of documents.

Using documents to store data has the following advantages

Documents (objects) are the native data types of many programming languages.

Embedding documents or arrays reduces costly join operations

No fixed schema

1.1.2 Key characteristics

high performance

Support embedded data models to reduce active IO of database systems

Indexing support makes queries faster, and embedded documents or arrays can also define indexes.

high availability

automatic failover

redundant data storage

high scalability

Data is automatically sharded, storing data across all machines in the cluster.

Replicas can provide low-latency, high-throughput, and ultimately consistent read deployment.

2. MongoDB installation

2.1 supported platforms

2.2 Installing MongoDB on Linux

MongoDB is installed in two ways: rpm installation and Tarball installation.

It is recommended to install MongoDB using RPM because RPM is optimized for specific operating systems and includes TLS/SSL support.

2.2.1 Installing MongoDB using rpm (Red Hat OS)

RPM packages include the following

The mongodb-org package contains various initialization scripts

/etc/rc.d/init.d/mongod is used to start, shut down, and restart MongoDB daemons

/etc/mongod.conf MongoDB startup configuration file

Download RPM package for MongoDB

https://repo.mongodb.org/yum/redhat/6Server/mongodb-org/

Select the appropriate version

https://repo.mongodb.org/yum/redhat/6Server/mongodb-org/3.2/x86_64/RPMS/

download

mongodb-org-3.2.0-1.el6.x86_64.rpm

mongodb-org-mongos-3.2.0-1.el6.x86_64.rpm

mongodb-org-server-3.2.0-1.el6.x86_64.rpm

mongodb-org-shell-3.2.0-1.el6.x86_64.rpm

mongodb-org-tools-3.2.0-1.el6.x86_64.rpm

Upload to server, install rpm package

[root@localhost ~]# rpm -ivh mongodb-org-server-3.2.0-1.el6.x86_64.rpm warning: mongodb-org-server-3.2.0-1.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID ea312927: NOKEYPreparing... ########################################### [100%] 1:mongodb-org-server ########################################### [100%][root@localhost ~]# rpm -ivh mongodb-org-shell-3.2.0-1.el6.x86_64.rpm warning: mongodb-org-shell-3.2.0-1.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID ea312927: NOKEYPreparing... ########################################### [100%] 1:mongodb-org-shell ########################################### [100%][root@localhost ~]# rpm -ivh mongodb-org-mongos-3.2.0-1.el6.x86_64.rpm warning: mongodb-org-mongos-3.2.0-1.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID ea312927: NOKEYPreparing... ########################################### [100%] 1:mongodb-org-mongos ########################################### [100%][root@localhost ~]# rpm -ivh mongodb-org-tools-3.2.0-1.el6.x86_64.rpm warning: mongodb-org-tools-3.2.0-1.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID ea312927: NOKEYPreparing... ########################################### [100%] 1:mongodb-org-tools ########################################### [100%][root@localhost ~]# rpm -ivh mongodb-org-3.2.0-1.el6.x86_64.rpm warning: mongodb-org-3.2.0-1.el6.x86_64.rpm: Header V3 RSA/SHA1 Signature, key ID ea312927: NOKEYPreparing... ########################################### [100%] 1:mongodb-org ########################################### [100%]

Start MongoDB

[root@localhost ~]# service mongod startStarting mongod: [ OK ]

Verify successful startup

[root@localhost ~]# tail -n 1 /var/log/mongodb/mongod.log 2016-01-04T16:19:41.497+0800 I NETWORK [initandlisten] waiting for connections on port 27017

2.2.2 Installing MongoDB with Tarball

Download binary package https://www.mongodb.org/downloads.

Unzip the installation package on the server

tar -zxvf mongodb-linux-x86_64-3.2.0.tgz

Move the installation file to the specified location

mkdir -p mongodbcp -R -n mongodb-linux-x86_64-3.2.0/ mongodb

Declaring environment variables

export PATH=/bin:$PATH

running MongoDB

Create a data repository directory

mkdir -p /data/db

Start MongoDB

mongod --dbpath /data/db

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.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report