November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

Categories

November 2024
M T W T F S S
 123
45678910
11121314151617
18192021222324
252627282930  

CentOS 7 MongoDB 3.4

nstall MongoDB 3.4 process on yum under CentOS 7 system.

The first step to see if there is a MongoDB configuration yum source

Switch to the yum directory cd /etc/yum.repos.d/

View the file ls

The second part does not exist to add yum source

Create the file touch mongodb-3.4.repo

Edit this file vi mongodb-3.4.repo

content:

Cat /etc/yum.repos.d/mongodb-3.4.repos

[mongodb-org-3.4]

Name=MongoDB Repository

Baseurl=https://repo.mongodb.org/yum/ RedHat /$releasever/mongodb-org/3.4/x86_64/

Gpgcheck=1

Enabled=1

Gpgkey=https://www.mongodb.org/static/pgp/server-3.2.asc

You can modify gpgcheck=0 here to save gpg verification

Update all packages before installation: yum update (optional operation)

Then install: yum install -y mongodb-org

Check the mongo installation location whereis mongod

Check the modified configuration file: vi /etc/mongod.conf

Start mongod :systemctl start mongod.service

Stop mongod :systemctl stop mongod,service

External network access needs to shut down the firewall:

CentOS 7.0 uses firewall as the firewall by default, and it is changed to iptables firewall.

Close the firewall:

Systemctl stop firewalld.service #stop firewall

Systemctl disable firewalld.service #Disable firewall startup

Use mongodb : mongo 192.168.60.102:27017

>use admin

>show dbs

>show collections

After restarting Mongodb, log in to the admin account and create a super-privileged user

Use admin

db.createUser({user:’root’,pwd:’root’,roles:[{ “role” : “root”, “db” : “admin” }]});

Configuration

Fork=true ## allows programs to run in the background

#auth=true ## Start Authentication

Logpath=/data/db/mongodb/logs/mongodb.log logappend=true # Write log mode: set to true to append. The default is to override dbpath=/data/db/mongodb/data/ ## data storage directory

Pidfilepath=/data/db/mongodb/logs/mongodb.pid # Process ID. If not specified, there will be no PID file when starting. Default default.

Port=27017

#bind_ip=192.168.2.73 # Bind addresses. The default is 127.0.0.1. You can only change the data directory storage mode by setting the local connection # to true. Each database file is stored in a different folder in the DBPATH specified directory. # With this option, MongoDB can be configured to store data on different disk devices to increase write throughput or disk capacity. The default is false. # suggest to configure sub-options from the beginning

Directoryperdb=true # Disable log # Enable the operation log for the journal to ensure write consistency and data consistency. Create a journal directory in the dbpath directory

Nojournal = true ##

Max connections # The maximum number of connections. Default: Depends on system (ie ulimit and file descriptor) restrictions. # MongoDB does not limit its own connection. When the setting is greater than the system limit, it is invalid and the system limit prevails. # Set the value of this value higher than the size of the connection pool and the total number of connections to prevent connections at peak times. # Note: This value cannot be set greater than 20000. maxConns=1024

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong>