5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Macで最新版MongoDBをインストールして初期設定をする

Last updated at Posted at 2018-07-17

 概要

バイナリーからMacにmongoDBをインストールした際の手順をまとめておきます。

動作環境

MacOS High Sierra (バージョン10.13.6)

インストールの手順

  • MongoDB公式サイトからファイル一式をダウンロード
  • バイナリーファイルの移動
  • データ/ログフォルダの生成
  • 起動

MongoDB公式サイトからファイル一式をダウンロード

下記のMongoDBの公式ホームページから必要ファイルをダウンロードします。
https://www.mongodb.com/download-center#community

~
wget https://fastdl.mongodb.org/osx/mongodb-osx-ssl-x86_64-4.0.0.tgz

tar -zxvf mongodb-osx-ssl-x86_64-4.0.0.tgz  #フォルダを解凍する

バイナリーファイルの移動

解凍したフォルダ内にあるbinフォルダのバイナリーを/usr/local/binに移動します。

移動例
***というファイルを/usr/local/binに移動します。

~
mv *** /usr/local/bin 

データ/ログフォルダの生成

~
sudo mkdir /var/lib/mongodb
sudo touch /var/log/mongodb.log

データを格納するフォルダと、ログを出力するファイルを生成します。

起動

先程作成したデータ格納用ディレクトリとログファイルを指定してデータベース側のMongoDBを起動します。起動するとターミナルで待ち受け状態になります。

~
sudo mongod --dbpath /var/lib/mongodb --logpath /var/log/mongodb.log

別のシェルを起動し、クライアント側のmongoを起動します。

~
$ mongo
MongoDB shell version v4.0.0
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 4.0.0
Server has startup warnings:
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten]
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] ** WARNING: You are running this process as the root user, which is not recommended.
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten]
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] ** WARNING: This server is bound to localhost.
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] **          Remote systems will be unable to connect to this server.
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] **          Start the server with --bind_ip <address> to specify which IP
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] **          addresses it should serve responses from, or with --bind_ip_all to
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] **          bind to all interfaces. If this behavior is desired, start the
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten] **          server with --bind_ip 127.0.0.1 to disable this warning.
2018-07-17T15:16:21.962+0900 I CONTROL  [initandlisten]
---
Enable MongoDB's free cloud-based monitoring service to collect 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 created for you. Anyone you share the URL with will also be able to
view this page. 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()
---

>

無事起動し、最新版のMongoDB v4.0がインストールできました。

参考
MongoDB公式サイト:https://docs.mongodb.com/manual/tutorial/install-mongodb-on-os-x/

5
6
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
5
6

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?