如何在Linux,Ubuntu,Debian,CentOS,Fedora上安装和配置MongoDB NoSQL数据库

SQL is a very powerful language to query, insert, delete, modify data. In recent years the IT industry has developed some alternative ways to store and retrieve data. NoSQL type database servers become very popular. MongoDB is a NoSQL database server to store and retrieve data. In this tutorial, we will look at how to install MongoDB on Linux and distributions like Ubuntu, Debian, CentOS, Fedora, RedHat.

SQL是一种非常强大的语言,可以查询,插入,删除,修改数据。 近年来,IT行业开发了一些替代方法来存储和检索数据。 NoSQL类型的数据库服务器变得非常流行。 MongoDB是用于存储和检索数据的NoSQL数据库服务器。 在本教程中,我们将研究如何在Linux和Ubuntu,Debian,CentOS,Fedora,RedHat等发行版上安装MongoDB。

Fedora,CentOS,RedHat (Fedora, CentOS, RedHat)

We will use yum or DNF package managers to install MongoDB. Alternatively, we can download the installation package from the MongoDB website.

我们将使用yum或DNF软件包管理器来安装MongoDB。 另外,我们可以从MongoDB网站下载安装包。

$ sudo dnf install mongodb-server

Ubuntu,Debian (Ubuntu, Debian)

We will  use apt package manager

我们将使用apt包管理器

$ sudo apt install mongodb-server

检查服务状态 (Check Service Status)

After the installation, we need to start the MongoDB service which is named mongod . The first step is checking the mongod service status.

安装后,我们需要启动名为mongod的MongoDB服务。 第一步是检查mongod服务状态。

$ sudo systemctl status mongod.service

$ sudo systemctl状态mongod.service

As we can see it is stopped.

如我们所见,它已停止。

使用Systemctl启动MongoDB服务 (Start MongoDB Service with Systemctl)

Systemctl is de facto and a new tool to manage services in Linux. We will use command systemctl start to start the MongoDB service. We need root privileges to start and stop services.

Systemctl实际上是在Linux中管理服务的新工具。 我们将使用命令systemctl start启动MongoDB服务。 我们需要root特权才能启动和停止服务。

$ sudo systemctl start mongod.service

检查MongoDB端口 (Check MongoDB Ports)

One of the most occurred problems is a firewall that prevents accessing MongoDB database server ports. We can access with telnet from a remote host like below.

发生最多的问题之一是防火墙,该防火墙阻止访问MongoDB数据库服务器端口。 我们可以从如下所示的远程主机使用telnet访问。

First we will look on MongoDB server which ports are listened. We will use netstat -tl command. MongoDB generally and by default uses port range 27017-27018 .

首先,我们将在MongoDB服务器上查看要侦听哪些端口。 我们将使用netstat -tl命令。 MongoDB通常且默认情况下使用端口范围27017-27018。

$ netstat -tln
$ telnet localhost 27017

We can see that we have no problem with network connection. If we get a message like “Connection refused” this means we have a problem with the network connection to the remote host.

我们可以看到网络连接没有问题。 如果我们收到“连接被拒绝”之类的消息,则表明我们与远程主机的网络连接有问题。

LEARN MORE  How To Define, Add, Create User For Postgres or PostgreSQL Server?
了解更多如何为Postgres或PostgreSQL服务器定义,添加,创建用户?

翻译自: https://www.poftut.com/how-to-install-and-configure-mongodb-nosql-database-to-linux-ubuntu-debian-centos-fedora/

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值