LoginSignup
8
2

More than 1 year has passed since last update.

.NETがIBM Powerでサポートされたので試してみる

Last updated at Posted at 2022-11-15

.NET 7.0 で IBM Power のサポート発表

IBM Power上のRHEL(Red Hat Enterprise Linux)で.NET 7.0がサポートされるようになったと発表がありました。
https://devblogs.microsoft.com/dotnet/announcing-dotnet-7/

64-bit IBM Power support
In addition to x64 architecture (64-bit Intel/AMD), ARM64 (64-bit ARM) and s390x (64-bit IBM Z), .NET is now also available for the ppc64le (64-bit IBM Power) architecture targeting RHEL 8.7 and RHEL 9.1.

With the availability to now run natively on Power, the 25,000 plus IBM Power customers can consolidate existing .NET apps on Windows x86 to run on the same Power platform as their IBM i and AIX business apps and databases. Doing so can significantly improve sustainability with up to a 5x smaller carbon footprint combined with on-premises pay-as-you-go scaling for RHEL and OpenShift capacity while delivering industry leading end-to-end-enterprise transaction and data security.

ということで、Powerの上で.NETを動かしてみます。
今回は、Hello Worldを表示する簡単なチュートリアルを試してみます。
https://dotnet.microsoft.com/en-us/learn/dotnet/hello-world-tutorial/intro

RHELのサポートは8.7, 9.1とのことです。 特に言及はないため他のアーキテクチャーで動かすLinuxと同じように使えるのではないかと思います。

.NETのインストール

RHELの場合は、yumから.NETをインストールできるようです。
まずは、yum search でインストール可能なパッケージがあるのか確認してみます。

[root@thel ~]# yum search dotnet
Updating Subscription Management repositories.
メタデータの期限切れの最終確認: 2:55:43 時間前の 2022年11月14日 20時50分55秒 に実施しました。
================================================ 名前 完全一致: dotnet =================================================
dotnet.ppc64le : .NET CLI tools and runtime
================================================== 名前 一致: dotnet ===================================================
dotnet-apphost-pack-7.0.ppc64le : Targeting Pack for Microsoft.NETCore.App 7.0
dotnet-host.ppc64le : .NET command line launcher
dotnet-hostfxr-7.0.ppc64le : .NET command line host resolver
dotnet-runtime-7.0.ppc64le : NET 7.0 runtime
dotnet-sdk-7.0.ppc64le : .NET 7.0 Software Development Kit
dotnet-targeting-pack-7.0.ppc64le : Targeting Pack for Microsoft.NETCore.App 7.0
dotnet-templates-7.0.ppc64le : .NET 7.0 templates

.NET用のパッケージがいくつか見つかりました。
SDKをインストールすると、依存関係で他のパッケージもインストールされるようです。
dotnet-sdk-7.0 をインストールします。

[root@rhel ~]# yum install dotnet-sdk-7.0 -y
Updating Subscription Management repositories.
メタデータの期限切れの最終確認: 2:58:03 時間前の 2022年11月14日 20時50分55秒 に実施しました。
依存関係が解決しました。
========================================================================================================================
 パッケージ                           Arch          バージョン            リポジトリー                            サイズ
========================================================================================================================
インストール:
 dotnet-sdk-7.0                       ppc64le       7.0.100-1.el8_7       rhel-8-for-ppc64le-appstream-rpms        53 M
依存関係のインストール:
 aspnetcore-runtime-7.0               ppc64le       7.0.0-1.el8_7         rhel-8-for-ppc64le-appstream-rpms       2.8 M
 aspnetcore-targeting-pack-7.0        ppc64le       7.0.0-1.el8_7         rhel-8-for-ppc64le-appstream-rpms       1.6 M
 dotnet-apphost-pack-7.0              ppc64le       7.0.0-1.el8_7         rhel-8-for-ppc64le-appstream-rpms       100 k
 dotnet-host                          ppc64le       7.0.0-1.el8_7         rhel-8-for-ppc64le-appstream-rpms       190 k
 dotnet-hostfxr-7.0                   ppc64le       7.0.0-1.el8_7         rhel-8-for-ppc64le-appstream-rpms       175 k
 dotnet-runtime-7.0                   ppc64le       7.0.0-1.el8_7         rhel-8-for-ppc64le-appstream-rpms       7.8 M
 dotnet-targeting-pack-7.0            ppc64le       7.0.0-1.el8_7         rhel-8-for-ppc64le-appstream-rpms       2.9 M
 dotnet-templates-7.0                 ppc64le       7.0.100-1.el8_7       rhel-8-for-ppc64le-appstream-rpms       3.1 M
 netstandard-targeting-pack-2.1       ppc64le       7.0.100-1.el8_7       rhel-8-for-ppc64le-appstream-rpms       1.5 M

トランザクションの概要
========================================================================================================================
インストール  10 パッケージ

ダウンロードサイズの合計: 73 M
インストール後のサイズ: 311 M
パッケージのダウンロード:
(1/10): aspnetcore-targeting-pack-7.0-7.0.0-1.el8_7.ppc64le.rpm                         2.9 MB/s | 1.6 MB     00:00
(2/10): dotnet-host-7.0.0-1.el8_7.ppc64le.rpm                                           338 kB/s | 190 kB     00:00
(3/10): dotnet-runtime-7.0-7.0.0-1.el8_7.ppc64le.rpm                                     11 MB/s | 7.8 MB     00:00
(4/10): aspnetcore-runtime-7.0-7.0.0-1.el8_7.ppc64le.rpm                                9.9 MB/s | 2.8 MB     00:00
(5/10): netstandard-targeting-pack-2.1-7.0.100-1.el8_7.ppc64le.rpm                      5.3 MB/s | 1.5 MB     00:00
(6/10): dotnet-apphost-pack-7.0-7.0.0-1.el8_7.ppc64le.rpm                               395 kB/s | 100 kB     00:00
(7/10): dotnet-templates-7.0-7.0.100-1.el8_7.ppc64le.rpm                                 10 MB/s | 3.1 MB     00:00
(8/10): dotnet-targeting-pack-7.0-7.0.0-1.el8_7.ppc64le.rpm                             9.1 MB/s | 2.9 MB     00:00
(9/10): dotnet-hostfxr-7.0-7.0.0-1.el8_7.ppc64le.rpm                                    786 kB/s | 175 kB     00:00
(10/10): dotnet-sdk-7.0-7.0.100-1.el8_7.ppc64le.rpm                                      41 MB/s |  53 MB     00:01
------------------------------------------------------------------------------------------------------------------------
合計                                                                                     32 MB/s |  73 MB     00:02
トランザクションの確認を実行中
トランザクションの確認に成功しました。
トランザクションのテストを実行中
トランザクションのテストに成功しました。
トランザクションを実行中
  準備             :                                                                                                1/1
  インストール中   : dotnet-host-7.0.0-1.el8_7.ppc64le                                                             1/10
  インストール中   : aspnetcore-targeting-pack-7.0-7.0.0-1.el8_7.ppc64le                                           2/10
  インストール中   : netstandard-targeting-pack-2.1-7.0.100-1.el8_7.ppc64le                                        3/10
  インストール中   : dotnet-apphost-pack-7.0-7.0.0-1.el8_7.ppc64le                                                 4/10
  インストール中   : dotnet-templates-7.0-7.0.100-1.el8_7.ppc64le                                                  5/10
  インストール中   : dotnet-targeting-pack-7.0-7.0.0-1.el8_7.ppc64le                                               6/10
  インストール中   : dotnet-hostfxr-7.0-7.0.0-1.el8_7.ppc64le                                                      7/10
  インストール中   : dotnet-runtime-7.0-7.0.0-1.el8_7.ppc64le                                                      8/10
  インストール中   : aspnetcore-runtime-7.0-7.0.0-1.el8_7.ppc64le                                                  9/10
  インストール中   : dotnet-sdk-7.0-7.0.100-1.el8_7.ppc64le                                                       10/10
  scriptletの実行中: dotnet-sdk-7.0-7.0.100-1.el8_7.ppc64le                                                       10/10
  検証             : dotnet-host-7.0.0-1.el8_7.ppc64le                                                             1/10
  検証             : aspnetcore-targeting-pack-7.0-7.0.0-1.el8_7.ppc64le                                           2/10
  検証             : dotnet-runtime-7.0-7.0.0-1.el8_7.ppc64le                                                      3/10
  検証             : aspnetcore-runtime-7.0-7.0.0-1.el8_7.ppc64le                                                  4/10
  検証             : netstandard-targeting-pack-2.1-7.0.100-1.el8_7.ppc64le                                        5/10
  検証             : dotnet-apphost-pack-7.0-7.0.0-1.el8_7.ppc64le                                                 6/10
  検証             : dotnet-templates-7.0-7.0.100-1.el8_7.ppc64le                                                  7/10
  検証             : dotnet-targeting-pack-7.0-7.0.0-1.el8_7.ppc64le                                               8/10
  検証             : dotnet-sdk-7.0-7.0.100-1.el8_7.ppc64le                                                        9/10
  検証             : dotnet-hostfxr-7.0-7.0.0-1.el8_7.ppc64le                                                     10/10
Installed products updated.

インストール済み:
  aspnetcore-runtime-7.0-7.0.0-1.el8_7.ppc64le           aspnetcore-targeting-pack-7.0-7.0.0-1.el8_7.ppc64le
  dotnet-apphost-pack-7.0-7.0.0-1.el8_7.ppc64le          dotnet-host-7.0.0-1.el8_7.ppc64le
  dotnet-hostfxr-7.0-7.0.0-1.el8_7.ppc64le               dotnet-runtime-7.0-7.0.0-1.el8_7.ppc64le
  dotnet-sdk-7.0-7.0.100-1.el8_7.ppc64le                 dotnet-targeting-pack-7.0-7.0.0-1.el8_7.ppc64le
  dotnet-templates-7.0-7.0.100-1.el8_7.ppc64le           netstandard-targeting-pack-2.1-7.0.100-1.el8_7.ppc64le

完了しました!

インストールが完了しました。
これで.NETが使えるようになっているはずです。
コマンドでインストールされた.NETの情報を確認してみます。

[root@rhel ~]# dotnet --info
.NET SDK:
 Version:   7.0.100
 Commit:    e12b7af219

ランタイム環境:
 OS Name:     rhel
 OS Version:  8
 OS Platform: Linux
 RID:         rhel.8-ppc64le
 Base Path:   /usr/lib64/dotnet/sdk/7.0.100/

Host:
  Version:      7.0.0
  Architecture: ppc64le
  Commit:       d099f075e4

.NET SDKs installed:
  7.0.100 [/usr/lib64/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.0 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.0 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download

チュートリアルの実行

それでは、チュートリアルに沿って試していきます。
新しいアプリを作成します。

[root@rhel ~]# dotnet new console -o MyApp -f net7.0

.NET 7.0 へようこそ!
---------------------
SDK バージョン: 7.0.100

----------------
ASP.NET Core の HTTPS 開発証明書をインストールしました。
証明書を信頼するには、'dotnet dev-certs https --trust' (Windows および macOS のみ) を実行します。
HTTPS の詳細については、https://aka.ms/dotnet-https を参照してください
----------------
最初のアプリを作成するには、https://aka.ms/dotnet-hello-world を参照してください
最新情報については、https://aka.ms/dotnet-whats-new を参照してください
ドキュメントを探索するには、https://aka.ms/dotnet-docs を参照してください
GitHub で問題の報告とソースの検索を行うには、https://github.com/dotnet/core を参照してください
'dotnet --help' を使用して使用可能なコマンドを確認するか、https://aka.ms/dotnet-cli にアクセスしてください
--------------------------------------------------------------------------------------
テンプレート "コンソール アプリ" が正常に作成されました。

作成後の操作を処理しています...
/root/MyApp/MyApp.csproj を復元しています:
  Determining projects to restore...
  Restored /root/MyApp/MyApp.csproj (in 210 ms).
正常に復元されました。

コマンドを実行したディレクトリに MyApp が作成されています。

[root@rhel ~]# ls
MyApp

MyAppの中身を確認すると、以下のファイルが生成されていました。

[root@rhel ~]# cd MyApp/
[root@rhel MyApp]# ls
MyApp.csproj  Program.cs  obj

テンプレートで Program.cs という名前のプログラムが準備されています。
このファイルの中身を確認すると、Consoleに Hello World! を表示する記載がされています。

[root@rhel MyApp]# cat Program.cs
// See https://aka.ms/new-console-template for more information
Console.WriteLine("Hello, World!");

では、実行してみます。dotnet run で実行できます。

[root@rhel MyApp]# dotnet run
Hello, World!

無事、動くことが確認できました。
チュートリアルなので、とても簡単なプログラムの実行でしたが.NETの開発・実行環境が使えるようになりました。

コンテナでも.NET

他にも、Red Hat Ecosystem Catalogに .NETのコンテナイメージも登録されていました。
もちろんPower(ppc64le)版のイメージもありました。
https://catalog.redhat.com/software/containers/rhel8/dotnet-70/633c2b499d5bb2048bbc36ba?architecture=ppc64le

image.png

コンテナを起動してみましたが、同じように使えそうでした。

[root@rhel MyApp]# podman run -it registry.access.redhat.com/ubi8/dotnet-70 bash
Trying to pull registry.access.redhat.com/ubi8/dotnet-70:latest...
WARN[0000] "/run/user/0" directory set by $XDG_RUNTIME_DIR does not exist. Either create the directory or unset $XDG_RUNTIME_DIR.: stat /run/user/0: no such file or directory: Trying to pull image in the event that it is a public image.
Getting image source signatures
Checking if image destination supports signatures
Copying blob 6c256570e90e done
Copying blob 3a396d1417be done
Copying blob 5b27cce89638 done
Copying config 4d57d139a7 done
Writing manifest to image destination
Storing signatures
bash-4.4$ dotnet --info
.NET SDK:
 Version:   7.0.100
 Commit:    e12b7af219

Runtime Environment:
 OS Name:     rhel
 OS Version:  8
 OS Platform: Linux
 RID:         rhel.8-ppc64le
 Base Path:   /usr/lib64/dotnet/sdk/7.0.100/

Host:
  Version:      7.0.0
  Architecture: ppc64le
  Commit:       d099f075e4

.NET SDKs installed:
  7.0.100 [/usr/lib64/dotnet/sdk]

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.0 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.0 [/usr/lib64/dotnet/shared/Microsoft.NETCore.App]

Other architectures found:
  None

Environment variables:
  Not set

global.json file:
  Not found

Learn more:
  https://aka.ms/dotnet/info

Download .NET:
  https://aka.ms/dotnet/download
bash-4.4$ dotnet new console -o MyApp -f net7.0
The template "Console App" was created successfully.

Processing post-creation actions...
Restoring /opt/app-root/src/MyApp/MyApp.csproj:
  Determining projects to restore...
  Restored /opt/app-root/src/MyApp/MyApp.csproj (in 213 ms).
Restore succeeded.


bash-4.4$ cd MyApp/
bash-4.4$ dotnet run
Hello, World!
bash-4.4$
8
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
8
2