パッケージ管理システムSnappy
Contents
パッケージ管理システムSnappyとは
Snappyとはカノニカルが設計・開発したパッケージ管理システム。Snappyのパッケージは 'Snap' と呼ばれ、Snapを使うツールは 'Snapd' と呼ばれる。Snapは様々なLinuxディストリビューションで動作するので、ディストリビューションの上流のソフトウェアデプロイメントに依存しない。
snapがプリインストールされたディストリビューション
KDE Neon
Manjaro
Solus 3 and above
Ubuntu 20.10 and Ubuntu 21.04
Ubuntu 22.04 LTS (Jammy Jellyfish)
Ubuntu 20.04 LTS (Focal Fossa)
Ubuntu 18.04 LTS (Bionic Beaver)
Most Ubuntu flavours
Zorin OS
snapがプリインストールされていないが利用可能なディストリビューション
Arch Linux
Debian
Fedora
Kali Linux
Linux Mint
openSUSE
Pop!_OS
Red Hat Enterprise Linux (RHEL)
Solus
CentOS
elementary OS
GalliumOS
Kubuntu
Lubuntu
Parrot Security OS
Raspberry Pi OS
Rocky Linux
Xubuntu
参考:公式ドキュメント
LinuxにSnapdをインストール
1. Linuxディストリビューションごとのsnapdパッケージのインストール方法
......Debian and Ubuntu......
1 2 |
$ sudo apt update $ sudo apt install snapd |
......Fedora Linux......
1 |
# dnf install snapd |
......CentOS & RHEL......
1 2 |
# yum install epel-release # yum install snapd |
......openSUSE_Leap_15.0......
1 2 3 4 5 6 |
$ sudo zypper addrepo --refresh \ https://download.opensuse.org/repositories/system:/snappy/openSUSE_Leap_15.3 \ snappy $ sudo zypper --gpg-auto-import-keys refresh $ sudo zypper dup --from snappy $ sudo zypper install snapd |
2.snapdをインストールした後、メインのsnap通信ソケットを管理するsystemdユニットを有効にする
1 |
$ sudo systemctl enable --now snapd.socket |
3.起動確認
1 2 |
$ sudo systemctl is-active snapd.socket active |
1 |
$ sudo systemctl status snapd.socket |
1 2 3 4 5 6 7 8 9 10 11 |
● snapd.socket - Socket activation for snappy daemon Loaded: loaded (/usr/lib/systemd/system/snapd.socket; enabled; vendor pres> Active: active (running) since Sat 2022-10-29 15:15:23 JST; 30min ago Until: Sat 2022-10-29 15:15:23 JST; 30min ago Triggers: ● snapd.service Listen: /run/snapd.socket (Stream) /run/snapd-snap.socket (Stream) Tasks: 0 (limit: 10944) Memory: 0B CPU: 333us CGroup: /system.slice/snapd.socket |
1 2 |
$ sudo systemctl is-enabled snapd.socket enabled |
4./ var/lib/snapd/snapと/ snapの間にシンボリックリンクを作成
1 |
$ sudo ln -s /var/lib/snapd/snap /snap |
5.snapdおよびsnapコマンドラインツールのバージョンを確認
1 2 |
$ snap version certbot 1.31.0 |
6.パッケージをインストール
例として、Canonical社が開発しているKubernetes環境構築ツールMicroK8sをイントールします
1 2 3 4 5 |
$ sudo snap install microk8s –classic Run service command "restart" for services ["daemon-apiserver-prox Run service command "restart" for services ["daemon-apiserver-prox Run service command "restart" for services ["daemon-apiserver-prox microk8s (1.25/stable) v1.25.3 from Canonical? installed |
Snapでは環境の分離レベルが定義されており、「--classic」は従来のaptなどのパッケージと同じものになります
7.インストールされているパッケージを確認
1 2 3 4 5 6 7 8 9 |
$ snap list オプション「--all」で、無効になっているパッケージも表示することができる $ snap list --all Name Version Rev Tracking Publisher Notes certbot 1.31.0 2414 latest/stable certbot-eff? classic core18 20220831 2566 latest/stable canonical? base core20 20220826 1623 latest/stable canonical? base microk8s v1.25.3 4094 1.25/stable canonical? classic snapd 2.57.4 17336 latest/stable canonical? snapd |
8.パッケージの情報を見る
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 |
$ snap info microk8s name: microk8s summary: Kubernetes for workstations and appliances publisher: Canonical? store-url: https://snapcraft.io/microk8s contact: https://github.com/canonical/microk8s license: unset description: | MicroK8s is a small, fast, secure, certified Kubernetes distribution that installs on just about any Linux box. It provides the functionality of core Kubernetes components, in a small footprint, scalable from a single node to a high-availability production multi-node cluster. Use it for offline developments, prototyping, testing, CI/CD. It's also great for appliances - develop your IoT apps for K8s and deploy them to MicroK8s on your boxes. commands: - microk8s.add-node - microk8s.addons - microk8s.cilium - microk8s.config - microk8s.ctr - microk8s.dashboard-proxy - microk8s.dbctl - microk8s.disable - microk8s.enable - microk8s.helm - microk8s.helm3 - microk8s.images - microk8s.inspect - microk8s.istioctl - microk8s.join - microk8s.kubectl - microk8s.leave - microk8s.linkerd - microk8s - microk8s.refresh-certs - microk8s.remove-node - microk8s.reset - microk8s.start - microk8s.status - microk8s.stop - microk8s.version services: microk8s.daemon-apiserver-kicker: simple, enabled, active microk8s.daemon-apiserver-proxy: simple, enabled, inactive microk8s.daemon-cluster-agent: simple, enabled, active microk8s.daemon-containerd: notify, enabled, active microk8s.daemon-etcd: simple, enabled, inactive microk8s.daemon-flanneld: simple, enabled, inactive microk8s.daemon-k8s-dqlite: simple, enabled, active microk8s.daemon-kubelite: simple, enabled, active snap-id: EaXqgt1lyCaxKaQCU349mlodBkDCXRcg tracking: 1.25/stable refresh-date: today at 15:47 JST channels: 1.25/stable: v1.25.3 2022-10-22 (4094) 174MB classic 1.25/candidate: v1.25.3 2022-10-15 (4094) 174MB classic 1.25/beta: v1.25.3 2022-10-15 (4094) 174MB classic 1.25/edge: v1.25.3 2022-10-14 (4094) 174MB classic latest/stable: v1.25.3 2022-10-23 (4094) 174MB classic latest/candidate: v1.25.3 2022-10-14 (4090) 175MB classic latest/beta: v1.25.3 2022-10-14 (4090) 175MB classic latest/edge: v1.25.3 2022-10-27 (4120) 175MB classic dqlite/stable: ? dqlite/candidate: ? dqlite/beta: ? dqlite/edge: v1.16.2 2019-11-07 (1038) 189MB classic 1.26/stable: ? 1.26/candidate: ? 1.26/beta: ? 1.26/edge: v1.26.0-alpha.1 2022-09-23 (4006) 173MB classic 1.25-strict/stable: v1.25.2 2022-09-30 (4049) 174MB - 1.25-strict/candidate: v1.25.2 2022-09-29 (4049) 174MB - 1.25-strict/beta: v1.25.2 2022-09-29 (4049) 174MB - 1.25-strict/edge: v1.25.3 2022-10-21 (4108) 174MB - 1.24/stable: v1.24.6 2022-09-30 (4023) 229MB classic 1.24/candidate: v1.24.6 2022-09-29 (4023) 229MB classic 1.24/beta: v1.24.6 2022-09-29 (4023) 229MB classic 1.24/edge: v1.24.6 2022-09-28 (4023) 229MB classic 1.23-eksd/stable: v1.23-5 2022-09-30 (4025) 167MB classic 1.23-eksd/candidate: v1.23-7 2022-10-27 (4119) 167MB classic 1.23-eksd/beta: v1.23-7 2022-10-27 (4119) 167MB classic 1.23-eksd/edge: v1.23-7 2022-10-27 (4119) 167MB classic 1.23/stable: v1.23.12 2022-09-30 (4022) 216MB classic 1.23/candidate: v1.23.12 2022-09-29 (4022) 216MB classic 1.23/beta: v1.23.12 2022-09-29 (4022) 216MB classic 1.23/edge: v1.23.12 2022-10-01 (4063) 216MB classic 1.22-eksd/stable: v1.22-10 2022-09-30 (4024) 164MB classic 1.22-eksd/candidate: v1.22-12 2022-10-26 (4115) 164MB classic 1.22-eksd/beta: v1.22-12 2022-10-26 (4115) 164MB classic 1.22-eksd/edge: v1.22-12 2022-10-26 (4115) 164MB classic 1.22/stable: v1.22.15 2022-09-30 (4046) 191MB classic 1.22/candidate: v1.22.15 2022-09-29 (4046) 191MB classic 1.22/beta: v1.22.15 2022-09-29 (4046) 191MB classic 1.22/edge: v1.22.15 2022-09-28 (4046) 191MB classic 1.21/stable: v1.21.13 2022-07-20 (3410) 191MB classic 1.21/candidate: v1.21.13 2022-07-09 (3410) 191MB classic 1.21/beta: v1.21.13 2022-07-09 (3410) 191MB classic 1.21/edge: v1.21.13 2022-06-08 (3410) 191MB classic 1.20/stable: v1.20.13 2021-12-08 (2760) 221MB classic 1.20/candidate: v1.20.13 2021-12-07 (2760) 221MB classic 1.20/beta: v1.20.13 2021-12-07 (2760) 221MB classic 1.20/edge: v1.20.14 2022-01-11 (2843) 217MB classic 1.19/stable: v1.19.15 2021-09-30 (2530) 216MB classic 1.19/candidate: v1.19.15 2021-09-29 (2530) 216MB classic 1.19/beta: v1.19.15 2021-09-29 (2530) 216MB classic 1.19/edge: v1.19.16 2022-01-07 (2820) 212MB classic 1.18/stable: v1.18.20 2021-07-12 (2271) 198MB classic 1.18/candidate: v1.18.20 2021-07-12 (2271) 198MB classic 1.18/beta: v1.18.20 2021-07-12 (2271) 198MB classic 1.18/edge: v1.18.20 2021-11-03 (2647) 198MB classic 1.17/stable: v1.17.17 2021-01-15 (1916) 177MB classic 1.17/candidate: v1.17.17 2021-01-14 (1916) 177MB classic 1.17/beta: v1.17.17 2021-01-14 (1916) 177MB classic 1.17/edge: v1.17.17 2021-01-13 (1916) 177MB classic 1.16/stable: v1.16.15 2020-09-12 (1671) 179MB classic 1.16/candidate: v1.16.15 2020-09-04 (1671) 179MB classic 1.16/beta: v1.16.15 2020-09-04 (1671) 179MB classic 1.16/edge: v1.16.15 2020-09-02 (1671) 179MB classic 1.15/stable: v1.15.11 2020-03-27 (1301) 171MB classic 1.15/candidate: v1.15.11 2020-03-27 (1301) 171MB classic 1.15/beta: v1.15.11 2020-03-27 (1301) 171MB classic 1.15/edge: v1.15.11 2020-03-26 (1301) 171MB classic 1.14/stable: v1.14.10 2020-01-06 (1120) 217MB classic 1.14/candidate: ↑ 1.14/beta: ↑ 1.14/edge: v1.14.10 2020-03-26 (1303) 217MB classic 1.13/stable: v1.13.6 2019-06-06 (581) 237MB classic 1.13/candidate: ↑ 1.13/beta: ↑ 1.13/edge: ↑ 1.12/stable: v1.12.9 2019-06-06 (612) 259MB classic 1.12/candidate: ↑ 1.12/beta: ↑ 1.12/edge: ↑ 1.11/stable: v1.11.10 2019-05-10 (557) 258MB classic 1.11/candidate: ↑ 1.11/beta: ↑ 1.11/edge: ↑ 1.10/stable: v1.10.13 2019-04-22 (546) 222MB classic 1.10/candidate: ↑ 1.10/beta: ↑ 1.10/edge: ↑ installed: v1.25.3 (4094) 174MB classic |
9.パッケージをアップデート
パッケージ単位にアップデートする場合
1 |
$ sudo snap refresh microk8s |
インストールされているすべてのパッケージをアップデートする場合
1 |
$ sudo snap refresh |
自動アップデートも行われており、デフォルトでは4時間おきに行われます
1 2 3 4 |
# snap refresh --time timer: 00:00~24:00/4 last: today at 22:06 JST next: tomorrow at 02:06 JST |
詳細は公式ドキュメント
10.サービスの管理
現在稼働しているサービスを確認
1 2 3 4 5 6 7 8 9 10 11 |
$ snap services Service Startup Current Notes certbot.renew enabled inactive timer-activated microk8s.daemon-apiserver-kicker enabled active - microk8s.daemon-apiserver-proxy enabled inactive - microk8s.daemon-cluster-agent enabled active - microk8s.daemon-containerd enabled active - microk8s.daemon-etcd enabled inactive - microk8s.daemon-flanneld enabled inactive - microk8s.daemon-k8s-dqlite enabled active - microk8s.daemon-kubelite enabled active - |
サービスの停止
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
$ sudo snap stop microk8s Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Run service command "stop" for services ["daemon-apiserver-kicker" "daemon-apise Stopped |
サービスの起動
1 2 |
$ sudo snap restart microk8s Restarted. |
サービスの自動起動を有効化する
1 2 3 4 5 6 7 8 9 10 11 12 |
$ sudo snap start --enable microk8s Run service command "start" for services ["daemon-apiserver-kicker" "daemon-apis Run service command "start" for services ["daemon-apiserver-kicker" "daemon-apis Run service command "start" for services ["daemon-apiserver-kicker" "daemon-apis Run service command "start" for services ["daemon-apiserver-kicker" "daemon-apis Run service command "start" for services ["daemon-apiserver-kicker" "daemon-apis Run service command "start" for services ["daemon-apiserver-kicker" "daemon-apis Run service command "start" for services ["daemon-apiserver-kicker" "daemon-apis Run service command "start" for services ["daemon-apiserver-kicker" "daemon-apis Run service command "start" for services ["daemon-apiserver-kicker" "daemon-apis Run service command "start" for services ["daemon-apiserver-kicker" "daemon-apis Started |
自動起動を無効にするには、「snap stop」に「--disable」オプションをつける
1 |
$ sudo snap stop --disable microk8s |
11.パッケージの有効/無効
パッケージを無効にするには、「snap disable」を使う
1 |
$ sudo snap disable microk8s |
有効にするには、「snap enable」を使う
1 |
$ sudo snap enable microk8s |
12.パッケージをアンインストールする
1 |
$ sudo snap remove microk8s |
完全に削除する場合は、「--purge」オプションを付ける
1 |
$ sudo snap remove microk8s --purge |