概要
Amazon Linux 2が発表されました。
https://aws.amazon.com/jp/amazon-linux-2/
Amazon Linux 2では、amazon-linux-extras
といというコマンドを使用してレポジトリの追加、削除をおこなうようになっており、これによりどう変わっているのか調べてみました。
amazon-linux-extras
helpを見ると以下のようになっています。
# amazon-linux-extras help
help See list of commands.
info See details of a specific package.
install Enables specified topics and installs their packages.
list Lists topics in the catalog. Some may be enabled.
...
listを実行してみます。
# amazon-linux-extras list
0 ansible2 disabled [ =2.4.2 ]
1 emacs disabled [ =25.3 ]
2 memcached1.5 disabled [ =1.5.1 ]
3 nginx1.12 disabled [ =1.12.2 ]
4 postgresql9.6 disabled [ =9.6.6 ]
5 python3 disabled [ =3.6.2 ]
6 redis4.0 disabled [ =4.0.5 ]
7 R3.4 disabled [ =3.4.3 ]
8 rust1 disabled [ =1.22.1 ]
9 vim disabled [ =8.0 ]
10 golang1.9 disabled [ =1.9.2 ]
11 ruby2.4 disabled [ =2.4.2 ]
12 nano disabled [ =2.9.1 ]
13 php7.2 disabled [ =7.2.0 ]
ここで表示されるバージョンのミドルウェアを追加でインストールすることができるようです。
例えばデフォルトのyumレポジトリでは、
# yum info python
Loaded plugins: langpacks, update-motd
Installed Packages
Name : python
Arch : x86_64
Version : 2.7.5
Release : 58.amzn2
...
で、pythonは2.7.5が入ります。
# amazon-linux-extras install python3
0 ansible2 disabled [ =2.4.2 ]
1 emacs disabled [ =25.3 ]
2 memcached1.5 disabled [ =1.5.1 ]
3 nginx1.12 disabled [ =1.12.2 ]
4 postgresql9.6 disabled [ =9.6.6 ]
5 python3=latest enabled [ =3.6.2 ]
6 redis4.0 disabled [ =4.0.5 ]
7 R3.4 disabled [ =3.4.3 ]
8 rust1 disabled [ =1.22.1 ]
9 vim disabled [ =8.0 ]
10 golang1.9 disabled [ =1.9.2 ]
11 ruby2.4 disabled [ =2.4.2 ]
12 nano disabled [ =2.9.1 ]
13 php7.2 disabled [ =7.2.0 ]
のように、installでpython3の追加レポジトリを有効にすると
# yum info python3
Loaded plugins: langpacks, update-motd
Installed Packages
Name : python3
Arch : x86_64
Version : 3.6.2
Release : 3.amzn2.0.3
Size : 38 k
Repo : installed
From repo : amzn2extra-python3
...
python3がインストール可能になりました。
確認してみると、以下のような追加のyumリポジトリ定義ファイルが追加されていました。
# cat /etc/yum.repos.d/amzn2-extras.repo | grep -v "^$"
### This file is managed with amazon-linux-extras. Please manage with that tool.
[amzn2extra-python3-source]
enabled = 0
name = Amazon Extras source repo for python3
mirrorlist = http://amazonlinux.$awsregion.$awsdomain/$releasever/extras/python3/latest/SRPMS/mirror.list
gpgcheck = 1
[amzn2extra-python3-debuginfo]
enabled = 0
name = Amazon Extras debuginfo repo for python3
mirrorlist = http://amazonlinux.$awsregion.$awsdomain/$releasever/extras/python3/latest/debuginfo/$basearch/mirror.list
gpgcheck = 1
[amzn2extra-python3]
enabled = 1
name = Amazon Extras repo for python3
mirrorlist = http://amazonlinux.$awsregion.$awsdomain/$releasever/extras/python3/latest/$basearch/mirror.list
gpgcheck = 1
amazon-linux-extras list
で追加インストールできるミドルウェアを確認し、amazon-linux-extras install [ミドルウェア名]
でyumレポジトリ定義を追加してから、yum
で追加のミドルウェアのバージョンがインストールできるようになるようです。
ちなみに、amazon-linux-extras list
で表示されるミドルウェアの定義は
/usr/lib/python2.7/site-packages/amazon_linux_extras/cli.py
で、
CATALOG_URL = os.environ.get("CATALOGURL", "http://amazonlinux.{awsregion}.{awsdomain}/{releasever}/extras-catalog.json")
のように定義されています。
releaseverは2012.12
ですので、curlで叩いてみると
# curl http://amazonlinux.ap-northeast-1.amazonaws.com/2017.12/extras-catalog.json
{"motd": "", "status": "ok", "version": 1, "whitelists": [[0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13]], "topics": [
{"n": "ansible2", "inst": ["ansible"], "versions": ["2.4.2"]},
{"n": "emacs", "inst": ["emacs"], "versions": ["25.3"]},
{"n": "memcached1.5", "inst": ["memcached"], "versions": ["1.5.1"], "visible": ["memcached", "memcached-devel"]},
{"n": "nginx1.12", "inst": ["nginx"], "versions": ["1.12.2"]},
{"n": "postgresql9.6", "inst": ["postgresql"], "versions": ["9.6.6"]},
{"n": "python3", "inst": ["python3", "python3-pip", "python3-setuptools", "python3-wheel"], "versions": ["3.6.2"]},
{"n": "redis4.0", "inst": ["redis"], "versions": ["4.0.5"]},
{"n": "R3.4", "inst": ["R"], "versions": ["3.4.3"]},
{"n": "rust1", "inst": ["rust", "cargo"], "versions": ["1.22.1"]},
{"n": "vim", "inst": ["vim-enhanced", "vim-minimal"], "versions": ["8.0"]},
{"n": "golang1.9", "inst": ["golang"], "versions": ["1.9.2"]},
{"n": "ruby2.4", "inst": ["ruby", "ruby-irb", "rubygem-rake", "rubygem-json", "rubygems"], "versions": ["2.4.2"]},
{"n": "nano", "inst": ["nano"], "versions": ["2.9.1"]},
{"n": "php7.2", "inst": ["php-cli", "php-pdo", "php-fpm", "php-json", "php-mysqlnd"], "versions": ["7.2.0"]}
]}
現在追加可能なミドルウェアが確認できました。今後ここが増えていくことを期待したいです。
ちなみに、現行のAmazon Linuxは、レポジトリの追加などなしにyumでインストール可能なミドルウェアのバージョンが非常に多かったです。
例えばPHPだと
# yum search "php" | grep "^php[0-9][0-9].x86_64"
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
php54.x86_64 : PHP scripting language for creating dynamic web sites
php55.x86_64 : PHP scripting language for creating dynamic web sites
php56.x86_64 : PHP scripting language for creating dynamic web sites
php70.x86_64 : PHP scripting language for creating dynamic web sites
php71.x86_64 : PHP scripting language for creating dynamic web sites
で、5.4, 5.5, 5.6, 7.0, 7.1まであり、
# yum info php.x86_64
...
Version : 5.3.29
...
バージョン番号を何も付けないと実は5.3もいけます。
Rubyもすごいです。
# yum search "ruby" | grep "^ruby[0-9][0-9].x86_64"
Repodata is over 2 weeks old. Install yum-cron? Or run: yum makecache fast
ruby18.x86_64 : An interpreter of object-oriented scripting language
ruby19.x86_64 : An interpreter of object-oriented scripting language
ruby20.x86_64 : An interpreter of object-oriented scripting language
ruby21.x86_64 : An interpreter of object-oriented scripting language
ruby22.x86_64 : An interpreter of object-oriented scripting language
ruby23.x86_64 : An interpreter of object-oriented scripting language
ruby24.x86_64 : An interpreter of object-oriented scripting language
この辺が非常に助かっていたのですが、Amazon Linux 2では、
PHP
デフォルトのamzn2-coreレポジトリ
# yum info php
Loaded plugins: langpacks, update-motd
Available Packages
Name : php
Arch : x86_64
Version : 5.4.16
...
amazon-linux-extrasで追加したレポジトリ
# yum info php
Loaded plugins: langpacks, update-motd
Available Packages
Name : php
Arch : x86_64
Version : 7.2.0
Release : 3.amzn2.1
Size : 2.9 M
Repo : amzn2extra-php7.2/2017.12/x86_64
...
Ruby
デフォルトのamzn2-coreレポジトリ
# yum info ruby
Loaded plugins: langpacks, update-motd
Available Packages
Name : ruby
Arch : x86_64
Version : 2.0.0.648
...
amazon-linux-extrasで追加したレポジトリ
# yum info ruby
Loaded plugins: langpacks, update-motd
Installed Packages
Name : ruby
Arch : x86_64
Version : 2.4.2
Release : 84.amzn2.0.1
Size : 72 k
Repo : installed
From repo : amzn2extra-ruby2.4
...
しか無いようでした。
残念。。