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

CSS uses the autoflow attribute to achieve seat selection effect

1. Autoflow attribute, if the length and width of...

Instructions for using the database connection pool Druid

Replace it with the optimal database connection p...

Detailed explanation of the use of find_in_set() function in MySQL

First, let’s take an example: There is a type fie...

How to configure Bash environment variables in Linux

Shell is a program written in C language, which i...

CSS3 to achieve dynamic background gradient effect

Learning CSS3 is more about getting familiar with...

XHTML introductory tutorial: text formatting and special characters

<br />This section introduces how to impleme...

Summary of the top ten problems of MySQL index failure

Table of contents background 1. The query conditi...

Summary of new usage of vi (vim) under Linux

I have used the vi editor for several years, but ...

Several specific methods of Mysql space cleaning

Table of contents Preface 1. Check the file disk ...

Simple implementation method of Linux process monitoring and automatic restart

Purpose: Under Linux, the server program may be d...

mysql method to view the currently used configuration file my.cnf (recommended)

my.cnf is the configuration file loaded when MySQ...

vue3 timestamp conversion (without using filters)

When vue2 converts timestamps, it generally uses ...

The easiest way to debug stored procedures in Mysql

A colleague once told me to use a temporary table...

Join operation in Mysql

Types of joins 1. Inner join: The fields in the t...