Ubuntu 22.04 LTS上でMongoDB 5.0 Community Editionをインストールする

スポンサーリンク

Ubuntu 22.04 LTS上でMongoDB 5.0 Community Editionをインストールしてみます。

なお、この記事は「AWS EC2の「Ubuntu Server」インスタンスにSSHクライアント「PuTTY」を用いてSSHで接続する」という記事の続きでもあります。

■PC環境

Windows10(Google Chrome)

AWS インスタンス作成済み(Ubuntu 22.04 LTS (GNU/Linux 5.15.0-1011-aws x86 64))

■SSHクライアント「PuTTY」を用いてSSHで接続する

MongoDB 5.0 Community Editionをインストールしてみます。まず、その前に「AWS マネジメントコンソール」にログインし、「EC2」サービスへ移動します。移動後、「EC2 Management Console」内の左メニューの「インスタンス」の「インスタンス」をクリックすると、作成した「インスタンス」が一覧で表示されます。

今回作成した「Ubuntu Server」インスタンスの「インスタンス状態」が「実行中」であることを確認します。確認後、SSHクライアント「PuTTY」を用いて、SSHで接続を行います。

Welcome to Ubuntu 22.04 LTS (GNU/Linux 5.15.0-1011-aws x86 64)
* Documentation: https://help.ub 
* Management: https://landscape.canonical.com 
* Support: https://ubuntu.com/advantage
System information as of Fri Jul 8 00:49:50 UTC 2022
System load: 0.0 Usage of 7: 22.6% of 7.58GB Memory usage: 234 Swap usage: 0%
Processes:
100 Users logged in: IPv4 address for etho: ***.**.**.**
* Ubuntu Pro delivers the most comprehensive open source security and,
compliance features.

Ubuntu Pro for AWS | Ubuntu
Ubuntu Pro for AWS, the Ubuntu image optimised for production and professional use on public cloud. Including broad secu...
42 updates can be applied immediately. 22 of these updates are standard security updates. To see these additional updates run: apt list --upgradable

SSHで接続すると、上記のようなメッセージが出力されます。

ubuntu@ip-**-**-**-**(ipアドレス):~$

出力後、上記のように出力されれば、接続は完了となります。

■MongoDB 5.0 Community Editionのパッケージを確認する

接続後、MongoDB 5.0 Community Editionをインストールします。

$ wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add -

インストールするために、まずは上記のコマンドを入力し、Enterキーを押します。「wget」コマンドを用いて、MongoDBパブリックGPG(GNU Privacy Guard,公開鍵)キーをhttps://www.mongodb.org/static/pgp/server-5.0.ascからインポートします。

Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).
OK

Enterキーを押すと、「Warning: apt-key is deprecated. Manage keyring files in trusted.gpg.d instead (see apt-key(8)).(警告: apt-key は非推奨です。代わりに trusted.gpg.d でキーリングのファイルを管理します (apt-key(8) を参照)。)」というメッセージが出力されます。これは警告でありエラーではないので、そのままインストールの作業を進めます。

$ echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list

MongoDBパブリックGPG(GNU Privacy Guard,公開鍵)キーをインポート後、上記のコマンドを入力し、Enterキーを押します。これでMongoDBのリストファイルを作成します。

deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse

Enterキーを押すと、上記のように表示されます。これで「sources.list.d」ディレクトリに「mongodb-org-5.0.list」というファイルが作成されます。

$ sudo apt-get update

作成後、上記のコマンドを入力し、Enterキーを押します。sudo権限で、ローカルパッケージのデータベースをリロードします。Enterキーを押すと、リロードが開始され、しばらくすると完了となります。

$ sudo apt-get install -y mongodb-org

リロード後、MongoDBパッケージの最新の安定バージョンをインストールします。インストールするために、上記のコマンドを入力し、Enterキーを押します。

Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
Some packages could not be installed. This may mean that you have
requested an impossible situation or if you are using the unstable
distribution that some required packages have not yet been created
or been moved out of Incoming.
The following information may help to resolve the situation:

The following packages have unmet dependencies:
 mongodb-org-mongos : Depends: libssl1.1 (>= 1.1.1) but it is not installable
 mongodb-org-server : Depends: libssl1.1 (>= 1.1.1) but it is not installable
 mongodb-org-shell : Depends: libssl1.1 (>= 1.1.1) but it is not installable
E: Unable to correct problems, you have held broken packages.

Enterキーを押すと、「Some packages could not be installed.(いくつかのパッケージはインストールできませんでした。)」と出力され、「E: Unable to correct problems, you have held broken packages.(E: 問題を修正できません。壊れたパッケージを保持しています。)」というエラーが発生し、インストールができない。インストールできない原因を調べてみると、Ubuntu 22.04ではlibsslを3にアップグレードしてしまうので、libsslのバージョン1.1にする必要があるということで、下記の各コマンドを入力し、Enterキーを押していく(https://askubuntu.com/questions/1403619/mongodb-install-fails-on-ubuntu-22-04-depends-on-libssl1-1-but-it-is-not-insta)。

echo "deb http://security.ubuntu.com/ubuntu impish-security main" | sudo tee /etc/apt/sources.list.d/impish-security.list

sudo apt-get update
sudo apt-get install libssl1.1

Enterキーを押していくと「libssl1.1」のインストールが完了となります。

$ sudo apt-get install -y mongodb-org

完了後、再度、MongoDBパッケージのインストールするために、上記のコマンドを入力し、Enterキーを押します。Enterキーを押すと、今度はインストールが開始され、しばらくすると完了となります。

■インストールの確認

$ sudo apt show mongodb-org

インストール完了後、実際にインストールされているかの確認のために、上記のコマンドを入力し、Enterキーを押します。

Package: mongodb-org
Version: 5.0.9
Priority: optional
Section: database
Maintainer: MongoDB Packaging <packaging@mongodb.com>
Installed-Size: 8192 B
Depends: mongodb-org-database, mongodb-org-tools, mongodb-mongosh
Conflicts: mongo-10gen, mongo-10gen-enterprise, mongo-10gen-enterprise-server, mongo-10gen-server, mongo-10gen-unstable, mongo-10gen-unstable-enterprise, mongo-10gen-unstable-enterprise-mongos, mongo-10gen-unstable-enterprise-server, mongo-10gen-unstable-enterprise-shell, mongo-10gen-unstable-enterprise-tools, mongo-10gen-unstable-mongos, mongo-10gen-unstable-server, mongo-10gen-unstable-shell, mongo-10gen-unstable-tools, mongo18-10gen, mongo18-10gen-server, mongo20-10gen, mongo20-10gen-server, mongodb, mongodb-10gen, mongodb-10gen-enterprise, mongodb-10gen-unstable, mongodb-10gen-unstable-enterprise, mongodb-10gen-unstable-enterprise-mongos, mongodb-10gen-unstable-enterprise-server, mongodb-10gen-unstable-enterprise-shell, mongodb-10gen-unstable-enterprise-tools, mongodb-10gen-unstable-mongos, mongodb-10gen-unstable-server, mongodb-10gen-unstable-shell, mongodb-10gen-unstable-tools, mongodb-clients, mongodb-dev, mongodb-enterprise, mongodb-enterprise-mongos, mongodb-enterprise-server, mongodb-enterprise-shell, mongodb-enterprise-tools, mongodb-enterprise-unstable, mongodb-enterprise-unstable-mongos, mongodb-enterprise-unstable-server, mongodb-enterprise-unstable-shell, mongodb-enterprise-unstable-tools, mongodb-nightly, mongodb-org-unstable, mongodb-org-unstable-mongos, mongodb-org-unstable-server, mongodb-org-unstable-shell, mongodb-org-unstable-tools, mongodb-server, mongodb-stable, mongodb18-10gen, mongodb20-10gen
Homepage: http://www.mongodb.org
Download-Size: 2932 B
APT-Manual-Installed: yes
APT-Sources: https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0/multiverse amd64 Packages
Description: MongoDB open source document-oriented database system (metapackage)
 MongoDB is built for scalability, performance and high availability, scaling from single server deployments to large, complex multi-site architectures. By leveraging in-memory computing, MongoDB provides high performance for both reads and writes. MongoDB?s native replication and automated failover enable enterprise-grade reliability and operational flexibility.
 .
 MongoDB is an open-source database used by companies of all sizes, across all industries and for a wide variety of applications. It is an agile database that allows schemas to change quickly as applications evolve, while still providing the functionality developers expect from traditional databases, such as secondary indexes, a full query language and strict consistency.
 .
 MongoDB has a rich client ecosystem including hadoop integration, officially supported drivers for 10 programming languages and environments, as well as 40 drivers supported by the user community.
 .
 MongoDB features:
 * JSON Data Model with Dynamic Schemas
 * Auto-Sharding for Horizontal Scalability
 * Built-In Replication for High Availability
 * Rich Secondary Indexes, including geospatial
 * TTL indexes
 * Text Search
 * Aggregation Framework & Native MapReduce
 .
 This metapackage will install the mongo shell, import/export tools, other client utilities, server software, default configuration, and init.d scripts.

N: There are 9 additional records. Please use the '-a' switch to see them.

Enterキーを押すと、「Package: mongodb-org」,「Version: 5.0.9」などの情報が出力されました。出力内容からMongoDB 5.0 Community Editionがインストールされていることが確認できました。

コメント

タイトルとURLをコピーしました