Ubuntu 22.04 LTS上でインストールしたMongoDBサービスの開始とMongoDB Shellの起動

スポンサーリンク

Ubuntu 22.04 LTS上でインストールしたMongoDBサービスの開始とMongoDB Shellの起動を行ってみます。

なお、この記事は「Ubuntu 22.04 LTS上でMongoDB 5.0 Community Editionをインストールする」という記事の続きです。

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

Ubuntu 22.04 LTS上でインストールしたMongoDBサービスの開始とMongoDB Shellの起動を行う前に、まず、「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のサービス開始

$ sudo systemctl start mongod.service

接続後、インストールしたMongoDB 5.0 Community Editionのサービスを開始します。開始するために、上記のコマンドを入力し、Enterキーを押します。「systemctl」コマンドを用いてMongoDBサービスを開始します。systemctlは、広く採用されているinitシステムとサービスマネージャーsystemdの制御インターフェイスおよび検査ツールです。systemdは、Linux初期化システムおよびサービスマネージャーであり、デーモン(バックグラウンドで実行される通常のプログラム)のオンデマンド起動、マウントおよび自動マウントポイントのメンテナンスなどの機能を含みます。Enterキーを押すと何も出力されませんが、MongoDBサービスが開始されます。

$ sudo systemctl status mongod

開始後、実際にMongoDBサービスが開始されたのかを確認してみます。確認の際には上記のコマンドを入力し、Enterキーを押します。「systemctl」コマンドを用いて「mongod」の「status(状態)」を確認します。

??ongod.service - MongoDB Database Server
     Loaded: loaded (/lib/systemd/system/mongod.service; disabled; vendor prese>
     Active: active (running) since Mon 2022-07-11 23:32:08 UTC; 2min 9s ago
       Docs: https://docs.mongodb.org/manual
   Main PID: 27971 (mongod)
     Memory: 66.9M
        CPU: 1.221s
     CGroup: /system.slice/mongod.service
             ??27971 /usr/bin/mongod --config /etc/mongod.conf

Jul 11 23:32:08 ip-***-**-**-*** systemd[1]: Started MongoDB Database Server.

Enterキーを押すと、「MongoDB Database Server(mongod)」の状態が出力されます。出力内容を確認すると、「Active: active (running)(アクティブ(動作中))」と書かれていますので、サービスが開始されていることが確認できました。

■MongoDB Shellの起動

$ mongosh

確認後、MongoDB Shellの起動を行います。起動するために、上記のコマンドを入力し、Enterキーを押します。このコマンドでMongoDB Shellの起動を行います。

Current Mongosh Log ID: **********
Connecting to:          mongodb://127.0.0.1:27017/?directConnection=true&serverSelectionTimeoutMS=2000&appName=mongosh+1.5.0
Using MongoDB:          5.0.9
Using Mongosh:          1.5.0

For mongosh info see: https://docs.mongodb.com/mongodb-shell/


To help improve our products, anonymous usage data is collected and sent to MongoDB periodically (https://www.mongodb.com/legal/privacy-policy).
You can opt-out by running the disableTelemetry() command.

------
   The server generated these startup warnings when booting
   2022-07-11T23:32:08.717+00:00: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine. See http://dochub.mongodb.org/core/prodnotes-filesystem
   2022-07-11T23:32:09.475+00:00: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted
------

------
   Enable MongoDB's free cloud-based monitoring service, which will then receive and display
   metrics about your deployment (disk utilization, CPU, operation statistics, etc).

   The monitoring data will be available on a MongoDB website with a unique URL accessible to you
   and anyone you share the URL with. MongoDB may use this information to make product
   improvements and to suggest MongoDB products and deployment options to you.

   To enable free monitoring, run the following command: db.enableFreeMonitoring()
   To permanently disable this reminder, run the following command: db.disableFreeMonitoring()
------

test>

Enterキーを押すと、上記のメッセージが出力されます。これでMongoDB Shellの起動は完了となります。

コメント

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