Linux installation MongoDB startup and common problem solving

Linux installation MongoDB startup and common problem solving

MongoDB installation process and problem records

1. MongoDB installation

Download MongoDB

Official address: https://www.mongodb.com/download-center/community

You may need to register. I am using Centos7 system, so I chose RHEL7.0 TGZ. You can choose other systems by yourself.

If you don't want to register, you can download it here: https://www.mongodb.org/dl/linux

Download steps:

[root@localhost ~]# curl -O https://fastdl.mongodb.org/linux/mongodb-linux-x86_64-rhel70-4.2.6.tgz # Download [root@localhost ~]# tar -zxvf mongodb-linux-x86_64-rhel70-4.2.6.tgz # Unzip [root@localhost ~]# mv mongodb-linux-x86_64-rhel70-4.2.6/ /usr/local/mongodb # Move to /usr/local/mongodb
: : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : : :
auth=true # Start with permission bind_ip=0.0.0.0
[root@localhost bin]# ./mongod -f ./mongodb.conf # Start MongoDB
[root@localhost bin]# ps -ef|grep mongodb # Check the running status root 34125 1 0 09:43 ? 00:00:08 ./mongod -f ./mongodb.conf
root 53204 33869 0 10:23 pts/0 00:00:00 grep --color=auto mongodb

The running status is as shown in the figure:

Visit:

2. MongoDB background startup

What we use here is to start MongoDB with the background systemctl

First, add MongoDB to the service

vim /lib/systemd/system/mongodb.service

Write

[Unit]
Description=redis
After=network.target

[Service]
Type=forking
ExecStart=/usr/local/mongodb/bin/mongod -f /usr/local/mongodb/bin/mongodb.conf
ExecReload=/bin/kill -s HUP $MAINPID
ExecStop=/bin/kill -s QUIT $MAINPID
PrivateTmp=true

[Install]
WantedBy=multi-user.target

wq save and exit

Then run the following, remember to terminate the previously opened MongoDB process

[root@localhost redis-6.0.1]# systemctl enable mongodb.service # Add to boot [root@localhost redis-6.0.1]# systemctl is-enabled mongodb.service # Check whether the boot is successful enabled

[root@localhost redis-6.0.1]# systemctl start mongodb # Start mongoDB service [root@localhost redis-6.0.1]# systemctl status mongodb # View mongoDB running status

If there is a problem with the startup, you can view the log repair through systemctl status mongodb. As shown in the figure, it has been successfully started.

Finally, make a soft connection to facilitate operation

[root@localhost bin]# ln -s /usr/local/mongodb/bin/mongo /usr/bin/mongo
[root@localhost bin]# mongo
MongoDB shell version v4.2.6
connecting to: mongodb://127.0.0.1:27017/?compressors=disabled&gssapiServiceName=mongodb
Implicit session: session { "id" : UUID("6924698e-44ae-4d01-a0ab-013210c61330") }
MongoDB server version: 4.2.6
> ^C
bye

The above is the full content of this article. I hope it will be helpful for everyone’s study. I also hope that everyone will support 123WORDPRESS.COM.

You may also be interested in:
  • 2021 latest version of Windows 10 system MongoDB database installation and configuration environment
  • MongoDB simple introductory tutorial (installation, basic concepts, creating users)
  • Detailed steps to install Docker mongoDB 4.2.1 and collect springboot logs
  • MongoDB4.2.5 installation steps
  • Detailed explanation of how to install mongodb using docker on linux
  • Detailed installation tutorial of Pycharm connecting to MongoDB database
  • Analysis of the process of installing mongodb on ubuntu, creating accounts and libraries, and adding coordinate indexes
  • Detailed steps for installing mongodb with Centos7 yum
  • Tutorial on installing MongoDB 3.4 on CentOS7.2
  • Installation steps of MongoDB database

<<:  Native JavaScript to achieve the effect of carousel

>>:  Three implementation methods of Mysql copy table and grant analysis

Recommend

Native JS music player

This article example shares the specific code of ...

Detailed steps for building Portainer visual interface with Docker

In order to solve the problem mentioned last time...

Detailed explanation of writing multiple conditions of CSS: not

The :not pseudo-class selector can filter element...

Detailed explanation of four solutions to floating problems in CSS layout

1. Cause: The effect after the subbox is set to f...

How to view the IP address of the Docker container

I always thought that Docker had no IP address. I...

Basic knowledge: What does http mean before a website address?

What is HTTP? When we want to browse a website, w...

HTML Tutorial: Definition List

<br />Original text: http://andymao.com/andy...

Two problems encountered when deploying rabbitmq with Docker

1. Background The following two problems are enco...

A brief introduction to Tomcat's overall structure

Tomcat is widely known as a web container. It has...

Problems and solutions of using TweenMax animation library in angular

I have nothing to do recently, so I tinker with C...

Implementation code for using CSS text-emphasis to emphasize text

1. Introduction In the past, if you wanted to emp...

21 MySQL standardization and optimization best practices!

Preface Every good habit is a treasure. This arti...

Detailed tutorial on installing Python 3.6.6 from scratch on CentOS 7.5

ps: The environment is as the title Install possi...

Detailed explanation of the interaction between React Native and IOS

Table of contents Prerequisites RN passes value t...