Build MongoDB (3.6.6 version) based on CentOS7

Source: Internet
Author: User
Tags mongodb mongodb server

Based on CentOS7 to build MongoDB (3.6.6 version) MongoDB Introduction

Mongodb, a distributed document storage database, written in the C + + language, is designed to provide scalable, high-performance data storage solutions for Web applications. MongoDB is a high-performance, open-source, modeless document-based database that is a popular one in the current NoSQL database. It can be used in many scenarios to replace the traditional relational database or key/value storage methods. MONGO is developed using C + +.
MongoDB is a product between a relational database and a non-relational database, and is the most versatile and most like relational database in a non-relational database. The data structure he supports is very loose and is a JSON-like Bson format, so you can store more complex data types. MONGO's biggest feature is that the query language he supports is very powerful, and its syntax is a bit like an object-oriented query language that almost implements most of the functionality of a relational database single-table query, and also supports indexing of data.

MongoDB Features

It is characterized by high performance, easy to deploy, easy to use, and easy to store data. The main features are:

* For collection storage, easy to store object type data.
MongoDB Cluster Reference
MongoDB Cluster Reference

* Free mode.

* Support Dynamic Query.

* Full index support, including internal objects.

* Support Query.

* Supports replication and recovery.

* Use efficient binary data storage, including large objects (such as video, etc.).

* Automatically handles fragmentation to support scalability at the cloud level.

* Support multiple languages such as ruby,python,java,c++,php,c#.

* File storage format is Bson (an extension of JSON).

* Can be accessed via the Internet.

The following is a description of the use of the Yum repository to install the MongoDB database on CentOS7

Configuring the Yum Repository

Vim/etc/yum.repos.d/mongodb-org.repo

[mongodb-org]name=MongoDB Repository  baseurl=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.asc
After configuring the Yum Repository, use the Yum list to load

Yum List

Installing MONGGODB using the Yum Warehouse
yum  install -y mongodb-org
Modify the MongoDB configuration file
port: 27017            //监听端口 bindIp: 0.0.0.0  # Listen to local interface only, comment to listen on all interfaces.         //监听的地址修改为0.0.0.0,监听所有地址
Shutting down firewalls and SELinux
systemctl stop firewalld.servicesetenforce 0
Open the MongoDB database service
systemctl start mongod.servicenetstat -ntap | grep 27017tcp        0      0 0.0.0.0:27017           0.0.0.0:*               LISTEN      17001/mongod    
Enter the database

/usr/bin/mongo
MongoDB Shell version v3.6.6
Connecting to:mongodb://127.0.0.1:27017
MongoDB Server version:3.6.6
Welcome to the MongoDB shell.
For interactive help, type ' help '.
For more comprehensive documentation, see
http://docs.mongodb.org/
Questions? Try the Support group
Http://groups.google.com/group/mongodb-user
Server has startup warnings:
2018-07-16t22:26:41.343+0800 I CONTROL [Initandlisten]
2018-07-16t22:26:41.343+0800 I CONTROL [Initandlisten]Warning:access control is not an enabled for the database.
2018-07-16t22:26:41.343+0800 I CONTROL [Initandlisten]
Read and write access to data and configuration is unrestricted.
2018-07-16t22:26:41.343+0800 I CONTROL [Initandlisten]
2018-07-16t22:26:41.344+0800 I CONTROL [Initandlisten]
2018-07-16t22:26:41.344+0800 I CONTROL [Initandlisten]WARNING:/sys/kernel/mm/transparent_hugepage/enabled is ' always '.
2018-07-16t22:26:41.344+0800 I CONTROL [Initandlisten]
We suggest setting it to ' never '
2018-07-16t22:26:41.344+0800 I CONTROL [Initandlisten]
2018-07-16t22:26:41.344+0800 I CONTROL [Initandlisten]WARNING:/sys/kernel/mm/transparent_hugepage/defrag is ' always '.
2018-07-16t22:26:41.344+0800 I CONTROL [Initandlisten]
We suggest setting it to ' never '
2018-07-16t22:26:41.344+0800 I CONTROL [Initandlisten]
>

MongoDB Open Multi-instance
cp -p /etc/mongod.conf /etc/mongod2.conf         #复制生成第二个实例的配置文件mkdir -p /data/mongodb/cd /data/mongodb/mkdir mongo                  #创建数据存放文件touch mongod2.log        #创建日志文件chmod 777 mongod2.log       #给予权限    vim /etc/mongod2.conf     #修改第二个实例的配置文件path: /data/mongodb/mongod2.log   #日志文件地址dbPath: /data/mongodb/mongo     #数据文件地址port: 27018    #监听端口
  mongod -f /etc/mongod2.conf         #开启多实例  mongo --port 27018        #指定第二个实例的端口         >                               #这样就进入第二个实例了
MongoDB Basic Operations
> db.version()            #查看mongodb的版本信息 3.6.6> show dbs;              #查看表空间admin   0.000GBconfig  0.000GBlocal   0.000GB     > db.getMongo()        #查看当前数据库机器的连接地址和端口信息connection to 127.0.0.1:27017    > use school;                         #不存在会创建,不建立集合又会删除switched to db school    > db.createCollection(‘info‘)         #创建集合info{ "ok" : 1 }    > db.info.insert({"id":1,"name":"zhangsan"})                 #集合插入数据 WriteResult({ "nInserted" : 1 })> db.info.insert ({"name":"zhangsan","scorce":88,"hobby":["game","talk","sport"]})     #集合插入第二个数据> db.info.find()             #查看集合info空间{ "_id" : ObjectId("5b4cb18a472dfe3e1ca25d34"), "id" : 1, "name" : "zhangsan" }

Build MongoDB (3.6.6 version) based on CentOS7

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.