mirror of
https://github.com/LCTT/TranslateProject.git
synced 2026-08-23 04:03:29 +08:00
Merge remote-tracking branch 'LCTT/master'
This commit is contained in:
@@ -1,238 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to Install MongoDB on Ubuntu)
|
||||
[#]: via: (https://itsfoss.com/install-mongodb-ubuntu)
|
||||
[#]: author: (Sergiu https://itsfoss.com/author/sergiu/)
|
||||
|
||||
How to Install MongoDB on Ubuntu
|
||||
======
|
||||
|
||||
**This tutorial presents two ways to install MongoDB on Ubuntu and Ubuntu-based Linux distributions.**
|
||||
|
||||
[MongoDB][1] is an increasingly popular free and open-source NoSQL database that stores data in collections of JSON-like, flexible documents, in contrast to the usual table approach you’ll find in SQL databases.
|
||||
|
||||
You are most likely to find MongoDB used in modern web applications. Its document model makes it very intuitive to access and handle with various programming languages.
|
||||
|
||||
![mongodb Ubuntu][2]
|
||||
|
||||
In this article, I’ll cover two ways you can install MongoDB on your Ubuntu system.
|
||||
|
||||
### Installing MongoDB on Ubuntu based Distributions
|
||||
|
||||
1. Install MongoDB using Ubuntu’s repository. Easy but not the latest version of MongoDB
|
||||
2. Install MongoDB using its official repository. Slightly complicated but you get the latest version of MongoDB.
|
||||
|
||||
|
||||
|
||||
The first installation method is easier, but I recommend the second method if you plan on using the latest release with official support.
|
||||
|
||||
Some people might prefer using snap packages. There are snaps available in the Ubuntu Software Center, but I wouldn’t recommend using them; they’re outdated at the moment and I won’t be covering that.
|
||||
|
||||
#### Method 1. Install MongoDB from Ubuntu Repository
|
||||
|
||||
This is the easy way to install MongoDB on your system, you only need to type in a simple command.
|
||||
|
||||
##### Installing MongoDB
|
||||
|
||||
First, make sure your packages are up-to-date. Open up a terminal and type:
|
||||
|
||||
```
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
```
|
||||
|
||||
Go ahead and install MongoDB with:
|
||||
|
||||
```
|
||||
sudo apt install mongodb
|
||||
```
|
||||
|
||||
That’s it! MongoDB is now installed on your machine.
|
||||
|
||||
The MongoDB service should automatically be started on install, but to check the status type
|
||||
|
||||
```
|
||||
sudo systemctl status mongodb
|
||||
```
|
||||
|
||||
![Check if the MongoDB service is running.][3]
|
||||
|
||||
You can see that the service is **active**.
|
||||
|
||||
##### Running MongoDB
|
||||
|
||||
MongoDB is currently a systemd service, so we’ll use **systemctl** to check and modify it’s state, using the following commands:
|
||||
|
||||
```
|
||||
sudo systemctl status mongodb
|
||||
sudo systemctl stop mongodb
|
||||
sudo systemctl start mongodb
|
||||
sudo systemctl restart mongodb
|
||||
```
|
||||
|
||||
You can also change if MongoDB automatically starts when the system starts up ( **default** : enabled):
|
||||
|
||||
```
|
||||
sudo systemctl disable mongodb
|
||||
sudo systemctl enable mongodb
|
||||
```
|
||||
|
||||
To start working with (creating and editing) databases, type:
|
||||
|
||||
```
|
||||
mongo
|
||||
```
|
||||
|
||||
This will start up the **mongo shell**. Please check out the [manual][4] for detailed information on the available queries and options.
|
||||
|
||||
**Note:** Depending on how you plan to use MongoDB, you might need to adjust your Firewall. That’s unfortunately more involved than what I can cover here and depends on your configuration.
|
||||
|
||||
##### Uninstall MongoDB
|
||||
|
||||
If you installed MongoDB from the Ubuntu Repository and want to uninstall it (maybe to install using the officially supported way), type:
|
||||
|
||||
```
|
||||
sudo systemctl stop mongodb
|
||||
sudo apt purge mongodb
|
||||
sudo apt autoremove
|
||||
```
|
||||
|
||||
This should completely get rid of your MongoDB install. Make sure to **backup** any collections or documents you might want to keep since they will be wiped out!
|
||||
|
||||
#### Method 2. Install MongoDB Community Edition on Ubuntu
|
||||
|
||||
This is the way the recommended way to install MongoDB, using the package manager. You’ll have to type a few more commands and it might be intimidating if you are newer to the Linux world.
|
||||
|
||||
But there’s nothing to be afraid of! We’ll go through the installation process step by step.
|
||||
|
||||
##### Installing MongoDB
|
||||
|
||||
The package maintained by MongoDB Inc. is called **mongodb-org** , not **mongodb** (this is the name of the package in the Ubuntu Repository). Make sure **mongodb** is not installed on your system before applying this steps. The packages will conflict. Let’s get to it!
|
||||
|
||||
First, we’ll have to import the public key:
|
||||
|
||||
```
|
||||
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
|
||||
```
|
||||
|
||||
Now, you need to add a new repository in your sources list so that you can install MongoDB Community Edition and also get automatic updates:
|
||||
|
||||
```
|
||||
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
|
||||
```
|
||||
|
||||
To be able to install **mongodb-org** , we’ll have to update our package database so that your system is aware of the new packages available:
|
||||
|
||||
```
|
||||
sudo apt update
|
||||
```
|
||||
|
||||
Now you can ether install the **latest stable version** of MongoDB:
|
||||
|
||||
```
|
||||
sudo apt install -y mongodb-org
|
||||
```
|
||||
|
||||
or a **specific version** (change the version number after **equal** sign)
|
||||
|
||||
```
|
||||
sudo apt install -y mongodb-org=4.0.6 mongodb-org-server=4.0.6 mongodb-org-shell=4.0.6 mongodb-org-mongos=4.0.6 mongodb-org-tools=4.0.6
|
||||
```
|
||||
|
||||
If you choose to install a specific version, make sure you change the version number everywhere. If you only change it in the **mongodb-org=4.0.6** part, the latest version will be installed.
|
||||
|
||||
By default, when updating using the package manager ( **apt-get** ), MongoDB will be updated to the newest updated version. To stop that from happening (and freezing to the installed version), use:
|
||||
|
||||
```
|
||||
echo "mongodb-org hold" | sudo dpkg --set-selections
|
||||
echo "mongodb-org-server hold" | sudo dpkg --set-selections
|
||||
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
|
||||
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
|
||||
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
|
||||
```
|
||||
|
||||
You have now successfully installed MongoDB!
|
||||
|
||||
##### Configuring MongoDB
|
||||
|
||||
By default, the package manager will create **/var/lib/mongodb** and **/var/log/mongodb** and MongoDB will run using the **mongodb** user account.
|
||||
|
||||
I won’t go into changing these default settings since that is beyond the scope of this guide. You can check out the [manual][5] for detailed information.
|
||||
|
||||
The settings in **/etc/mongod.conf** are applied when starting/restarting the **mongodb** service instance.
|
||||
|
||||
##### Running MongoDB
|
||||
|
||||
To start the mongodb daemon **mongod** , type:
|
||||
|
||||
```
|
||||
sudo service mongod start
|
||||
```
|
||||
|
||||
Now you should verify that the **mongod** process started successfully. This information is stored (by default) at **/var/log/mongodb/mongod.log**. Let’s check the contents of that file:
|
||||
|
||||
```
|
||||
sudo cat /var/log/mongodb/mongod.log
|
||||
```
|
||||
|
||||
![Check MongoDB logs to see if the process is running properly.][6]
|
||||
|
||||
As long as you get this: **[initandlisten] waiting for connections on port 27017** somewhere in there, the process is running properly.
|
||||
|
||||
**Note: 27017** is the default port of **mongod.**
|
||||
|
||||
To stop/restart **mongod** enter:
|
||||
|
||||
```
|
||||
sudo service mongod stop
|
||||
sudo service mongod restart
|
||||
```
|
||||
|
||||
Now, you can use MongoDB by opening the **mongo shell** :
|
||||
|
||||
```
|
||||
mongo
|
||||
```
|
||||
|
||||
##### Uninstall MongoDB
|
||||
|
||||
Run the following commands
|
||||
|
||||
```
|
||||
sudo service mongod stop
|
||||
sudo apt purge mongodb-org*
|
||||
```
|
||||
|
||||
To remove the **databases** and **log files** (make sure to **backup** what you want to keep!):
|
||||
|
||||
```
|
||||
sudo rm -r /var/log/mongodb
|
||||
sudo rm -r /var/lib/mongodb
|
||||
```
|
||||
|
||||
**Wrapping Up**
|
||||
|
||||
MongoDB is a great NoSQL database, easy to integrate into modern projects. I hope this tutorial helped you to set it up on your Ubuntu machine! Let us know how you plan on using MongoDB in the comments below.
|
||||
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/install-mongodb-ubuntu
|
||||
|
||||
作者:[Sergiu][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/sergiu/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.mongodb.com/
|
||||
[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/03/mongodb-ubuntu.jpeg?resize=800%2C450&ssl=1
|
||||
[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/mongodb_check_status.jpg?fit=800%2C574&ssl=1
|
||||
[4]: https://docs.mongodb.com/manual/tutorial/getting-started/
|
||||
[5]: https://docs.mongodb.com/manual/
|
||||
[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/mongodb_org_check_logs.jpg?fit=800%2C467&ssl=1
|
||||
@@ -1,165 +0,0 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (robsean)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to Upgrade Debian 9 (Stretch) to Debian 10 (Buster) via Command Line)
|
||||
[#]: via: (https://www.linuxtechi.com/upgrade-debian-9-to-debian-10-command-line/)
|
||||
[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/)
|
||||
|
||||
How to Upgrade Debian 9 (Stretch) to Debian 10 (Buster) via Command Line
|
||||
======
|
||||
|
||||
Hello All!!!, Good to See you! So we saw how to install [Debian 10(Buster)][1] in the previous article. Today, we are going to learn how to upgrade from Debian 9 to Debian 10. Since we have already seen about Debian 10 and its features, let’s not go deep into it. But readers who didn’t have the chance to read that article, let’s give a quick update about Debian 10 and its new features.
|
||||
|
||||
<https://www.linuxtechi.com/wp-content/uploads/2019/07/Upgrade-Debian-9-to-Debian-10.jpg>
|
||||
|
||||
After almost two years of development, the team at Debian has finally released a stable version of Buster, code name for Debian 10. Buster is a LTS (Long Term Support) version and hence will be supported for the next 5 years by Debian.
|
||||
|
||||
### Debian 10 (Buster) – New Features
|
||||
|
||||
Debian 10 (Buster) comes packed with a lot of new features which could be rewarding to most of the Debian fans out there. Some of the features include:
|
||||
|
||||
* GNOME Desktop 3.30
|
||||
* AppArmor enabled by default
|
||||
* Supports Linux Kernel 4.19.0-4
|
||||
* Supports OpenJDk 11.0
|
||||
* Moved from Nodejs 4-8 to Nodejs 10.15.2
|
||||
* Iptables replaced by NFTables
|
||||
|
||||
|
||||
|
||||
and a lot more.
|
||||
|
||||
### Step by Step Guide to Upgrade from Debian 9 to Debian 10
|
||||
|
||||
Before we start upgrading to Debian 10, let’s look at the prerequisites needed for the upgrade:
|
||||
|
||||
### Step 1) Debian upgrade prerequisites
|
||||
|
||||
* A good internet connection
|
||||
* Root user permission
|
||||
* Data backup
|
||||
|
||||
|
||||
|
||||
It is extremely important to backup all your application code bases, data files, user account details, configuration files, so that you can always revert to the previous version if anything goes wrong during the upgrade.
|
||||
|
||||
### Step 2) Upgrade Debian 9 Existing Packages
|
||||
|
||||
Next step is to upgrade all your existing packages as any packages that are tagged as held back cannot be upgraded and there is a possibility the upgrade from Debian 9 to Debian 10 may fail or cause some issues. So, let’s not take any chances and better upgrade the packages. Use the following code to upgrade the packages:
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ sudo apt update && sudo apt upgrade -y
|
||||
```
|
||||
|
||||
### Step 3) Modify Package Repository file (/etc/sources.list)
|
||||
|
||||
Next step is to modify package repository file “/etc/sources.list” where you need to replace the text “Stretch” with the text “Buster”.
|
||||
|
||||
But before you change anything, make sure to create a backup of the sources.list file as shown below:
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
```
|
||||
|
||||
Now use below sed commands to replace the text ‘**stretch**‘ with ‘**buster**‘ in package repository file, example is shown below,
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list
|
||||
root@linuxtechi:~$ sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list.d/*.list
|
||||
```
|
||||
|
||||
Once the text is updated, you need to update the package index like shown below:
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ sudo apt update
|
||||
```
|
||||
|
||||
Before start upgrading your existing Debian OS , let’s verify the current version using the following command,
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ cat /etc/*-release
|
||||
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
|
||||
NAME="Debian GNU/Linux"
|
||||
VERSION_ID="9"
|
||||
VERSION="9 (stretch)"
|
||||
ID=debian
|
||||
HOME_URL="https://www.debian.org/"
|
||||
SUPPORT_URL="https://www.debian.org/support"
|
||||
BUG_REPORT_URL="https://bugs.debian.org/"
|
||||
root@linuxtechi:~$
|
||||
```
|
||||
|
||||
### Step 4) Upgrade from Debian 9 to Debian 10
|
||||
|
||||
Once you made all the changes, it is time to upgrade from Debian 9 – Debian 10. But before that, make sure to update your packages again as shown below:
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ sudo apt update && sudo apt upgrade -y
|
||||
```
|
||||
|
||||
During packages upgrade you will be prompted to start the services, so choose your preferred option
|
||||
|
||||
Once all the packages are updated in your system, it is time to upgrade your distribution package. Use the following code to upgrade the distribution:
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ sudo apt dist-upgrade -y
|
||||
```
|
||||
|
||||
The upgrade process may take a few minutes depending upon your internet connection. Remember during the upgrade process, you’ll also be asked a few questions whether you need to restart the services during the packages are upgraded and whether you need to keep the existing configurations files. If you don’t want to make any custom changes, simply type “Y” and let the upgrade process continue.
|
||||
|
||||
### Step 5) Verify Upgrade
|
||||
|
||||
Once the upgrade process is completed, reboot your machine and check the version using the following command:
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ lsb_release -a
|
||||
```
|
||||
|
||||
If you get the output as shown below:
|
||||
|
||||
```
|
||||
Distributor ID: Debian
|
||||
Description: Debian GNU/Linux 10 (buster)
|
||||
Release: 10
|
||||
Codename: buster
|
||||
root@linuxtechi:~$
|
||||
```
|
||||
|
||||
Yes, you have successfully upgraded from Debian 9 to Debian 10.
|
||||
|
||||
Alternate way to verify upgrade
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ cat /etc/*-release
|
||||
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
|
||||
NAME="Debian GNU/Linux"
|
||||
VERSION_ID="10"
|
||||
VERSION="10 (buster)"
|
||||
VERSION_CODENAME=buster
|
||||
ID=debian
|
||||
HOME_URL="https://www.debian.org/"
|
||||
SUPPORT_URL="https://www.debian.org/support"
|
||||
BUG_REPORT_URL="https://bugs.debian.org/"
|
||||
root@linuxtechi:~$
|
||||
```
|
||||
|
||||
### Conclusion
|
||||
|
||||
Hope the above step by step guide provided you with all the information needed to upgrade from Debian 9(Stretch) to Debian 10 (Buster) easily. Please give us your feedback, suggestions and your experiences with the all new Debian 10 in the comments section. For more such Linux tutorials and articles, keep visiting LinuxTechi.com every now and then.
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linuxtechi.com/upgrade-debian-9-to-debian-10-command-line/
|
||||
|
||||
作者:[Pradeep Kumar][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[译者ID](https://github.com/译者ID)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.linuxtechi.com/author/pradeep/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.linuxtechi.com/debian-10-buster-installation-guide/
|
||||
@@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: ( )
|
||||
[#]: translator: (robsean)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
|
||||
239
translated/tech/20190304 How to Install MongoDB on Ubuntu.md
Normal file
239
translated/tech/20190304 How to Install MongoDB on Ubuntu.md
Normal file
@@ -0,0 +1,239 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (geekpi)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to Install MongoDB on Ubuntu)
|
||||
[#]: via: (https://itsfoss.com/install-mongodb-ubuntu)
|
||||
[#]: author: (Sergiu https://itsfoss.com/author/sergiu/)
|
||||
|
||||
如何在 Ubuntu 上安装 MongoDB
|
||||
======
|
||||
|
||||
**本教程介绍了在 Ubuntu 和基于 Ubuntu 的 Linux 发行版上安装 MongoDB 的两种方法。**
|
||||
|
||||
[MongoDB][1]是一个越来越流行的免费和开源的 NoSQL 数据库,它将数据存储在类似 JSON 的灵活文档集中,这与 SQL 数据库中常见的表格形式形成对比。
|
||||
|
||||
你很可能发现在现代 Web 应用中使用 MongoDB。它的文档模型使得使用各种编程语言能非常直观地访问和处理它。
|
||||
|
||||
![mongodb Ubuntu][2]
|
||||
|
||||
在本文中,我将介绍两种在 Ubuntu 上安装 MongoDB 的方法。
|
||||
|
||||
### 在基于 Ubuntu 的发行版上安装 MongoDB
|
||||
|
||||
1. 使用 Ubuntu 仓库安装 MongoDB。简单但不是最新版本的 MongoDB
|
||||
2. 使用其官方仓库安装 MongoDB。稍微复杂,但你能得到最新版本的 MongoDB。
|
||||
|
||||
|
||||
|
||||
第一种安装方法更容易,但如果你计划使用官方支持的最新版本,那么我建议使用第二种方法。
|
||||
|
||||
S有些人可能更喜欢使用 snap 包。Ubuntu 软件中心提供了 snap,但我不建议使用它们,因为现在已经过时了,因此我这里不会提到。
|
||||
|
||||
#### 方法 1:从 Ubuntu 仓库安装 MongoDB
|
||||
|
||||
这是在系统中安装 MongoDB 的简便方法,你只需输入一个命令即可。
|
||||
|
||||
##### 安装 MongoDB
|
||||
|
||||
首先,确保你的包是最新的。打开终端并输入:
|
||||
|
||||
```
|
||||
sudo apt update && sudo apt upgrade -y
|
||||
```
|
||||
|
||||
继续安装 MongoDB:
|
||||
|
||||
```
|
||||
sudo apt install mongodb
|
||||
```
|
||||
|
||||
这就完成了!MongoDB 现在安装到你的计算机上了。
|
||||
|
||||
MongoDB 服务应该在安装时自动启动,但要检查服务状态:
|
||||
|
||||
```
|
||||
sudo systemctl status mongodb
|
||||
```
|
||||
|
||||
![Check if the MongoDB service is running.][3]
|
||||
|
||||
你可以看到该服务是**活动**的。
|
||||
|
||||
##### 运行 MongoDB
|
||||
|
||||
MongoDB 目前是一个 systemd 服务,因此我们使用 **systemctl** 来检查和修改它的状态,使用以下命令:
|
||||
|
||||
```
|
||||
sudo systemctl status mongodb
|
||||
sudo systemctl stop mongodb
|
||||
sudo systemctl start mongodb
|
||||
sudo systemctl restart mongodb
|
||||
```
|
||||
|
||||
你也可以修改 MongoDB 是否自动随系统启动(**默认**:启用):
|
||||
|
||||
```
|
||||
sudo systemctl disable mongodb
|
||||
sudo systemctl enable mongodb
|
||||
```
|
||||
|
||||
要开始使用(创建和编辑)数据库,请输入:
|
||||
|
||||
```
|
||||
mongo
|
||||
```
|
||||
|
||||
这将启动 **mongo shell**。有关查询和选项的详细信息,请查看[手册][4]。
|
||||
|
||||
**注意:**根据你计划使用 MongoDB 的方式,你可能需要调整防火墙。不幸的是,这超出了本篇的内容,并且取决于你的配置。
|
||||
|
||||
##### 卸载 MongoDB
|
||||
|
||||
如果你从 Ubuntu 仓库安装 MongoDB 并想要卸载它(可能要使用官方支持的方式安装),请输入:
|
||||
|
||||
```
|
||||
sudo systemctl stop mongodb
|
||||
sudo apt purge mongodb
|
||||
sudo apt autoremove
|
||||
```
|
||||
|
||||
这应该会完全卸载 MongoDB。确保**备份**你可能想要保留的任何集合或文档,因为它们将被删除!
|
||||
|
||||
#### 方法 2:在 Ubuntu 上安装 MongoDB 社区版
|
||||
|
||||
这是推荐的安装 MongoDB 的方法,它使用包管理器。你需要多打几条命令,对于 Linux 新手而言,这可能会感到害怕。
|
||||
|
||||
但没有什么可怕的!我们将一步步说明安装过程。
|
||||
|
||||
##### 安装 MongoDB
|
||||
|
||||
由 MongoDB Inc. 维护的包称为 **mongodb-org** ,而不是 **mongodb**(这是 Ubuntu 仓库中包的名称)。在开始之前,请确保系统上未安装 **mongodb**。因为包之间会发生冲突。让我们开始吧!
|
||||
|
||||
首先,我们必须导入公钥:
|
||||
|
||||
```
|
||||
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 9DA31620334BD75D9DCB49F368818C72E52529D4
|
||||
```
|
||||
|
||||
现在,你需要在源列表中添加一个新的仓库,以便你可以安装 MongoDB 社区版并获得自动更新:
|
||||
|
||||
```
|
||||
echo "deb [ arch=amd64 ] https://repo.mongodb.org/apt/ubuntu $(lsb_release -cs)/mongodb-org/4.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-4.0.list
|
||||
```
|
||||
|
||||
为了安装 **mongodb-org**,我们需要我们的包数据库,以便系统知道可用的新包:
|
||||
|
||||
```
|
||||
sudo apt update
|
||||
```
|
||||
|
||||
现在你可以安装**最新稳定版**的 MongoDB:
|
||||
|
||||
```
|
||||
sudo apt install -y mongodb-org
|
||||
```
|
||||
|
||||
或者某个**特定版本**(在**等号**后面修改版本号)
|
||||
|
||||
```
|
||||
sudo apt install -y mongodb-org=4.0.6 mongodb-org-server=4.0.6 mongodb-org-shell=4.0.6 mongodb-org-mongos=4.0.6 mongodb-org-tools=4.0.6
|
||||
```
|
||||
|
||||
如果你选择安装特定版本,请确保在所有位置都修改了版本号。如果你修改了 **mongodb-org=4.0.6**,你将安装最新版本。
|
||||
|
||||
|
||||
默认情况下,使用包管理器(**apt-get**)更新时,MongoDB 将更新为最新的版本。要阻止这种情况发生(并冻结为已安装的版本),请使用:
|
||||
|
||||
```
|
||||
echo "mongodb-org hold" | sudo dpkg --set-selections
|
||||
echo "mongodb-org-server hold" | sudo dpkg --set-selections
|
||||
echo "mongodb-org-shell hold" | sudo dpkg --set-selections
|
||||
echo "mongodb-org-mongos hold" | sudo dpkg --set-selections
|
||||
echo "mongodb-org-tools hold" | sudo dpkg --set-selections
|
||||
```
|
||||
|
||||
你现在已经成功安装了 MongoDB!
|
||||
|
||||
##### 配置 MongoDB
|
||||
|
||||
默认情况下,包管理器将创建 **/var/lib/mongodb** 和 **/var/log/mongodb**,MongoDB 将使用 **mongodb** 用户帐户运行。
|
||||
|
||||
我不会去更改这些默认设置,因为这超出了本指南的范围。有关详细信息,请查看[手册][5]。
|
||||
|
||||
**/etc/mongod.conf** 中的设置在启动/重新启动 **mongodb** 服务实例时生效。
|
||||
|
||||
|
||||
##### 运行 MongoDB
|
||||
|
||||
要启动 mongodb 的守护进程 **mongod**,请输入:
|
||||
|
||||
```
|
||||
sudo service mongod start
|
||||
```
|
||||
|
||||
现在你应该验证 **mongod** 进程是否已成功启动。此信息(默认情况下)保存在 **/var/log/mongodb/mongod.log** 中。我们来看看文件的内容:
|
||||
|
||||
```
|
||||
sudo cat /var/log/mongodb/mongod.log
|
||||
```
|
||||
|
||||
![Check MongoDB logs to see if the process is running properly.][6]
|
||||
|
||||
只要你在某处看到:**[initandlisten] waiting for connections on port 27017**,就说明进程正常运行。
|
||||
|
||||
**注意:27017** 是 **mongod** 的默认端口。
|
||||
|
||||
要停止/重启 **mongod**,请输入:
|
||||
|
||||
```
|
||||
sudo service mongod stop
|
||||
sudo service mongod restart
|
||||
```
|
||||
|
||||
现在,你可以通过打开 **mongo shell** 来使用 MongoDB:
|
||||
|
||||
```
|
||||
mongo
|
||||
```
|
||||
|
||||
##### 卸载 MongoDB
|
||||
|
||||
运行以下命令
|
||||
|
||||
```
|
||||
sudo service mongod stop
|
||||
sudo apt purge mongodb-org*
|
||||
```
|
||||
|
||||
要删除**数据库**和**日志文件**(确保**备份**你要保留的内容!):
|
||||
|
||||
```
|
||||
sudo rm -r /var/log/mongodb
|
||||
sudo rm -r /var/lib/mongodb
|
||||
```
|
||||
|
||||
**总结**
|
||||
|
||||
MongoDB 是一个很棒的 NoSQL 数据库,它易于集成到现代项目中。我希望本教程能帮助你在 Ubuntu 上安装它!在下面的评论中告诉我们你计划如何使用 MongoDB。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://itsfoss.com/install-mongodb-ubuntu
|
||||
|
||||
作者:[Sergiu][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[geekpi](https://github.com/geekpi)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://itsfoss.com/author/sergiu/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.mongodb.com/
|
||||
[2]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/03/mongodb-ubuntu.jpeg?resize=800%2C450&ssl=1
|
||||
[3]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/mongodb_check_status.jpg?fit=800%2C574&ssl=1
|
||||
[4]: https://docs.mongodb.com/manual/tutorial/getting-started/
|
||||
[5]: https://docs.mongodb.com/manual/
|
||||
[6]: https://i1.wp.com/itsfoss.com/wp-content/uploads/2019/02/mongodb_org_check_logs.jpg?fit=800%2C467&ssl=1
|
||||
@@ -0,0 +1,165 @@
|
||||
[#]: collector: (lujun9972)
|
||||
[#]: translator: (robsean)
|
||||
[#]: reviewer: ( )
|
||||
[#]: publisher: ( )
|
||||
[#]: url: ( )
|
||||
[#]: subject: (How to Upgrade Debian 9 (Stretch) to Debian 10 (Buster) via Command Line)
|
||||
[#]: via: (https://www.linuxtechi.com/upgrade-debian-9-to-debian-10-command-line/)
|
||||
[#]: author: (Pradeep Kumar https://www.linuxtechi.com/author/pradeep/)
|
||||
|
||||
如何通过命令行升级 Debian 9 (Stretch) 为 Debian 10 (Buster)
|
||||
======
|
||||
|
||||
大家好!!!,很高兴见到你!我们已经在先前的文章中看到如何安装 [Debian 10(Buster)][1]。今天,我们将学习如何从 Debian 9 升级为 Debian 10,虽然我们已将看到 Debian 10 和它的特色a,让我们不要深入它。但是读者没有机会来读那篇文章,让我们给予一个快速更新 Debian 10 和它的新功能。
|
||||
|
||||
<https://www.linuxtechi.com/wp-content/uploads/2019/07/Upgrade-Debian-9-to-Debian-10.jpg>
|
||||
|
||||
在差不多两年的开发后,Debian 小组最终发布一个稳定版本, Debian 10 的代码名称是Buster。Buster 是一个 LTS (长期支持支持)版本,因此未来将由 Debian 支持5年。
|
||||
|
||||
### Debian 10 (Buster) – 新的特色
|
||||
|
||||
Debian 10 (Buster) 带来大量打包好的新的特色,对大多数的 Debian 粉丝是有益的。一些特色包括:
|
||||
|
||||
* GNOME 桌面 3.30
|
||||
* AppArmor 默认启用
|
||||
* 支持 Linux 内核 4.19.0-4
|
||||
* 支持 OpenJDk 11.0
|
||||
* Moved from.15.2
|
||||
* Iptables 替换为 NFTables
|
||||
|
||||
|
||||
|
||||
还有很多。
|
||||
|
||||
### 从 Debian 9 到 Debian 10 的逐步升级指南
|
||||
|
||||
在我们开始升级 Debian 10前,让我们看看升级需要的必备条件:
|
||||
|
||||
### 步骤 1) Debian 升级必备条件
|
||||
|
||||
* 一个良好的网络连接
|
||||
* Root 用户权限
|
||||
* 数据备份
|
||||
|
||||
|
||||
|
||||
备份你所有的应用程序代码库,数据文件,用户账号详细信息,配置文件是极其重要的,以便在升级期间出错时,你可以总是可以还原到先前的版本。
|
||||
|
||||
### 步骤 2) 升级 Debian 9 现有的软件包
|
||||
|
||||
接下来的步骤是升级你所有现有的软件包,因为一些软件包被标志为保留不能升级,从 Debian 9 升级为 Debian 10 有失败或引发一些问题的可能性。所以,我们不冒任何风险,更好地升级软件包。使用下面的代码来升级软件包:
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ sudo apt update && sudo apt upgrade -y
|
||||
```
|
||||
|
||||
### 步骤 3) 修改软件包存储库文件 (/etc/sources.list)
|
||||
|
||||
接下来的步骤是修改软件包存储库文件 “/etc/sources.list” ,你需要用文本 “Buster” 替换 “Stretch”
|
||||
|
||||
但是,在你更改任何东西前,确保如下创建一个 sources.list 文件的备份:
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak
|
||||
```
|
||||
|
||||
现在使用下面的 sed 命令来在软件包存储库文件中使用 ‘**buster**‘ 替换 ‘**stretch**‘ ,示例如下显示,
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list
|
||||
root@linuxtechi:~$ sudo sed -i 's/stretch/buster/g' /etc/apt/sources.list.d/*.list
|
||||
```
|
||||
|
||||
一旦文本更新,你需要如下更新软件包存储库索引:
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ sudo apt update
|
||||
```
|
||||
|
||||
在开始升级你现有的 Debian 操作系统前,让我们使用下面的命令验证当前版本,
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ cat /etc/*-release
|
||||
PRETTY_NAME="Debian GNU/Linux 9 (stretch)"
|
||||
NAME="Debian GNU/Linux"
|
||||
VERSION_ID="9"
|
||||
VERSION="9 (stretch)"
|
||||
ID=debian
|
||||
HOME_URL="https://www.debian.org/"
|
||||
SUPPORT_URL="https://www.debian.org/support"
|
||||
BUG_REPORT_URL="https://bugs.debian.org/"
|
||||
root@linuxtechi:~$
|
||||
```
|
||||
|
||||
### 步骤 4) 从 Debian 9 升级到 Debian 10
|
||||
|
||||
一旦你做完所有的更改,是时候从 Debian 9 升级到 Debian 10 。但是在这之前,再次如下确保更新你的软件包:
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ sudo apt update && sudo apt upgrade -y
|
||||
```
|
||||
|
||||
在软件包升级期间,你将被提示启动服务,所以选择你较喜欢的选项
|
||||
|
||||
一旦你系统的所有软件包升级完成,是时候升级你的发行版的软件包。使用下面的代码来升级发行版:
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ sudo apt dist-upgrade -y
|
||||
```
|
||||
|
||||
升级过程可能花费一些时间,取决于你的网络速度。记住在升级过程中,你将被问道一些问题,在软件包升级后是否需要重启服务,你是否需要保留现存的配置文件。如果你不想进行一些自定义更改,简单地键入 “Y” ,来让升级过程继续。
|
||||
|
||||
### 步骤 5) 验证升级
|
||||
|
||||
一旦升级过程完成,重启你的机器,并使用下面的方法检测版本:
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ lsb_release -a
|
||||
```
|
||||
|
||||
如果你获得如下输出:
|
||||
|
||||
```
|
||||
Distributor ID: Debian
|
||||
Description: Debian GNU/Linux 10 (buster)
|
||||
Release: 10
|
||||
Codename: buster
|
||||
root@linuxtechi:~$
|
||||
```
|
||||
|
||||
是的,你已经成功地从 Debian 9 升级到 Debian 10。
|
||||
|
||||
验证升级的备用方法
|
||||
|
||||
```
|
||||
root@linuxtechi:~$ cat /etc/*-release
|
||||
PRETTY_NAME="Debian GNU/Linux 10 (buster)"
|
||||
NAME="Debian GNU/Linux"
|
||||
VERSION_ID="10"
|
||||
VERSION="10 (buster)"
|
||||
VERSION_CODENAME=buster
|
||||
ID=debian
|
||||
HOME_URL="https://www.debian.org/"
|
||||
SUPPORT_URL="https://www.debian.org/support"
|
||||
BUG_REPORT_URL="https://bugs.debian.org/"
|
||||
root@linuxtechi:~$
|
||||
```
|
||||
|
||||
### 结束
|
||||
|
||||
希望上面的逐步指南为你提供从 Debian 9(Stretch) 简单地升级为 Debian 10 (Buster) 的所有信息。在评论部分,请给予你使用 Debian 10 的反馈,建议,体验,更多 Linux 教程和文章,保持时时访问 LinuxTechi.com 。
|
||||
|
||||
--------------------------------------------------------------------------------
|
||||
|
||||
via: https://www.linuxtechi.com/upgrade-debian-9-to-debian-10-command-line/
|
||||
|
||||
作者:[Pradeep Kumar][a]
|
||||
选题:[lujun9972][b]
|
||||
译者:[robsean](https://github.com/robsean)
|
||||
校对:[校对者ID](https://github.com/校对者ID)
|
||||
|
||||
本文由 [LCTT](https://github.com/LCTT/TranslateProject) 原创编译,[Linux中国](https://linux.cn/) 荣誉推出
|
||||
|
||||
[a]: https://www.linuxtechi.com/author/pradeep/
|
||||
[b]: https://github.com/lujun9972
|
||||
[1]: https://www.linuxtechi.com/debian-10-buster-installation-guide/
|
||||
Reference in New Issue
Block a user