LoginSignup
0
2

More than 5 years have passed since last update.

MongoDBをバージョンを指定してインストールするメモ for Ubuntu 16.04

Last updated at Posted at 2017-12-22

公式のInstall MongoDB Community Edition on Ubuntuをみながら進めます。Azureの仮想マシンのUbuntu16.04にMongoDBをインストールします。

以下のコマンドを実行していけば基本はOKですが少しエラーがでた。

  • publivk keyの設定
sudo apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 2930ADAE8CAF5059EE73BB4B58712A2291FA4AD5
  • Ubuntu 16.04でリストファイル作成
echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu xenial/mongodb-org/3.6 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.6.list
  • ローカルパッケージの更新
sudo apt-get update
  • MongoDBのインストール

最新が3.6.0らしいのでバージョンを指定してインストール。ここの数字を変えればバージョン指定でいけそう。

$ sudo apt-get install -y mongodb-org=3.6.0 mongodb-org-server=3.6.0 mongodb-org-shell=3.6.0 mongodb-org-mongos=3.6.0 mongodb-org-tools=3.6.0

エラーが出た。

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell
  mongodb-org-tools
0 upgraded, 5 newly installed, 0 to remove and 201 not upgraded.
Need to get 66.8 MB of archives.
After this operation, 276 MB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  mongodb-org-shell mongodb-org-server mongodb-org-mongos mongodb-org-tools
  mongodb-org
E: There were unauthenticated packages and -y was used without --allow-unauthenticated

E: There were unauthenticated packages and -y was used without --allow-unauthenticatedとあるので-yを抜いたら無事にインストール出来ました。

$ sudo apt-get install mongodb-org=3.6.0 mongodb-org-server=3.6.0 mongodb-org-shell=3.6.0 mongodb-org-mongos=3.6.0 mongodb-org-tools=3.6.0

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following NEW packages will be installed:
  mongodb-org mongodb-org-mongos mongodb-org-server mongodb-org-shell
  mongodb-org-tools
0 upgraded, 5 newly installed, 0 to remove and 201 not upgraded.
Need to get 66.8 MB of archives.
After this operation, 276 MB of additional disk space will be used.
WARNING: The following packages cannot be authenticated!
  mongodb-org-shell mongodb-org-server mongodb-org-mongos mongodb-org-tools
  mongodb-org
Install these packages without verification? [y/N] ← yをタイプ

これで無事にインストール出来ました。

mongod --versionでバージョン確認が出来ます。

$ mongod --version
db version v3.6.0
git version: a57d8e71e6998a2d0afde7edc11bd23e5661c915
OpenSSL version: OpenSSL 1.0.2g  1 Mar 2016
allocator: tcmalloc
modules: none
build environment:
    distmod: ubuntu1604
    distarch: x86_64
    target_arch: x86_64

起動

$ sudo service mongod start
0
2
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
0
2