LoginSignup
3
1

More than 1 year has passed since last update.

.NET をIBM Powerで動かしてみた話 #1

Last updated at Posted at 2022-12-20

IBM Power (Linux on Power)で.NETを動かせるようになりました。これでまたひとつ、Power CPUの性能を活かせる場面が増えましたね。IBM Power上でRDBMSなどを動かしている方にとっては、対象のRDBMSへアクセスしにくるx86環境上の.NETアプリケーションを、RDBMSが稼働する同一のPowerノード上に動かせる(集約できる)ようになりました。これにより、データ転送のパフォーマンス・ロスがなくなり、システム全体の性能向上も期待できます。

そして以下の記事を確認すると、.NET 7 on IBM Power では .NET 7のRuntime やSDK がRed Hat Enterprise Linux のAppStream レポジトリに含まれるパッケージとして提供されるようです。またサポートされているのは、RHEL8.7 とRHEL9.1 とのこと。

IBM社のブログ : .NET 7 now includes support for Linux on Power!

This week, Microsoft announced the availability of .NET 7 and for the first time, .NET includes support for Linux on Power (ppc64le)! This milestone was a collaboration between IBM and Red Hat, Microsoft, and the .NET open source community. .NET 7 is targeted for the Red Hat Enterprise Linux (RHEL) distribution.

Where can you get .NET 7 for Linux on Power?

As an open source project, all changes are included upstream here: https://github.com/dotnet. We welcome contributions from the developer community to continue extending support for Linux on Power in .NET.

Fully supported RPM packages and container images built from those sources for ppc64le are provided by Red Hat. Learn more here: https://developers.redhat.com/articles/2022/10/26/net-7-now-available-rhel-and-openshift

For use on RHEL 8.7 and RHEL 9.1:

   ・ .NET 7 is supported on both RHEL and Red Hat OpenShift Container Platform.

   ・ .NET 7 is available as the RPM, dotnet-sdk-7.0. in the AppStream repositories for RHEL 8.7 and RHEL 9.1 The AppStream repositories are enabled by default on RHEL 8 systems.

   ・You can use the ubi8/dotnet-70-runtime image to run a pre-compiled application inside a Linux container. A no-cost Red Hat Enterprise Linux Developer Subscription is available that includes a full suite of tools for container development.

   ・ .NET 7 images are added to OpenShift by importing imagestream definitions from s2i-dotnetcore.
See the RHEL .NET 7 Documentation “Getting Started with .NET 7” , “.NET 7 RPM Release Notes” and “.NET 7 Container Release Notes” for more information.

さて、ここからが本記事の本題です。
上記のブログ情報を見て、Linux on Powerを使用されたことがある方は、以下のようなことを思うのではないでしょうか。

1. 「本当に.NET 7は問題なく動くのか」
2. 「x86環境で作成された.NET アプリケーションはppc64le環境でもそのまま動くのか」
3. 「コンテナ環境でも利用できるのか」

この記事では3回に渡って、実際に.NET 7 をIBM Power 環境で試し、その動作を確認してみたいと思います。

それでは、まず初めの「本当に.NET 7は問題なく動くのか」を見ていきたいと思います。

1. 「本当に.NET 7は問題なく動くのか」

今回は、以下の環境で検証を行ってみたいと思います。簡単に評価環境を作成できるよう、無償で利用可能なOSとしてAlmaLinuxを選択してみました。
これまでRHELの評価環境として利用されることが多かったCentOSですが、CentOS Streamとして生まれ変わったこともあり、私自身もAlmaLinuxを使用してみたかったため、こちらを選びました。

項目 バージョン 備考
OS AlmaLinux 8.7 ダウンロード : AlmaLinux 8.7 ISO
.NET 7.0.101 -

(1) 作業環境の確認

今回導入したAlmaLinux環境は以下となります。
RHEL8.7 相当となるAlmaLinux 8.7 をインストールしています。

[root@dotnet-sample-alma87 ~]# uname -a
Linux dotnet-sample-alma87 4.18.0-425.3.1.el8.ppc64le #1 SMP Tue Nov 8 14:07:43 EST 2022 ppc64le ppc64le ppc64le GNU/Linux
[root@dotnet-sample-alma87 ~]# cat /etc/redhat-release 
AlmaLinux release 8.7 (Stone Smilodon)

本記事とは関係ありませんが、AlmaLinuxは以下のURLより各CPUアーキテクチャのISOイメージをダウンロードすることができます。今回はPower CPUに対応している"ppc64le"版の中から、"8.7" を選択して、ISOイメージを取得しました。

実際に導入してみた感想としては、通常のRHELやこれまでのCentOSと何も変わらない方法でインストールできました。インストール時の画面も、私が触った限りではほとんど同じ(全く同じ?)でしたので、Linux環境をインストールしたことがある方であれば、何も問題なく環境を作成いただけるかと思います。

(2) .NET 7 のインストール

まず.NET関連のパッケージを確認してみます。

[root@dotnet-sample-alma87 ~]# dnf search dotnet
AlmaLinux 8 - BaseOS                                                                                                                               176 kB/s | 2.4 MB     00:14    
AlmaLinux 8 - AppStream                                                                                                                            198 kB/s | 8.6 MB     00:44    
AlmaLinux 8 - Extras                                                                                                                               7.4 kB/s |  18 kB     00:02    
============================================================================== 名前 完全一致: 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

[root@dotnet-sample-alma87 ~]# dnf search aspnetcore
メタデータの期限切れの最終確認: 0:01:02 時間前の 2022年12月20日 01時55分17秒 に実施しました。
========================================================================== 名前 & 概要 一致: aspnetcore ===========================================================================
aspnetcore-targeting-pack-7.0.ppc64le : Targeting Pack for Microsoft.AspNetCore.App 7.0
============================================================================== 名前 一致: aspnetcore ==============================================================================
aspnetcore-runtime-7.0.ppc64le : ASP.NET Core 7.0 runtime

"dotnet-sdk-7.0.ppc64le" の導入で関連パッケージがインストールされるとのことなので、まずはこのパッケージを導入してみます。

[root@dotnet-sample-alma87 ~]# dnf install -y dotnet-sdk-7.0.ppc64le
メタデータの期限切れの最終確認: 0:02:42 時間前の 2022年12月20日 01時55分17秒 に実施しました。
依存関係が解決しました。
===================================================================================================================================================================================
 パッケージ                                               アーキテクチャー                  バージョン                                   リポジトリー                        サイズ
===================================================================================================================================================================================
インストール:
 dotnet-sdk-7.0                                           ppc64le                           7.0.101-1.el8_7                              appstream                            53 M
依存関係のインストール:
 aspnetcore-runtime-7.0                                   ppc64le                           7.0.1-1.el8_7                                appstream                           2.8 M
 aspnetcore-targeting-pack-7.0                            ppc64le                           7.0.1-1.el8_7                                appstream                           1.6 M
 dotnet-apphost-pack-7.0                                  ppc64le                           7.0.1-1.el8_7                                appstream                            99 k
 dotnet-host                                              ppc64le                           7.0.1-1.el8_7                                appstream                           192 k
 dotnet-hostfxr-7.0                                       ppc64le                           7.0.1-1.el8_7                                appstream                           174 k
 dotnet-runtime-7.0                                       ppc64le                           7.0.1-1.el8_7                                appstream                           7.8 M
 dotnet-targeting-pack-7.0                                ppc64le                           7.0.1-1.el8_7                                appstream                           2.9 M
 dotnet-templates-7.0                                     ppc64le                           7.0.101-1.el8_7                              appstream                           3.4 M
 libicu                                                   ppc64le                           60.3-2.el8_1                                 baseos                              8.9 M
 netstandard-targeting-pack-2.1                           ppc64le                           7.0.101-1.el8_7                              appstream                           1.5 M

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

<以降、省略>

完了後、インストールされた.NET 7 の環境情報を確認

[root@dotnet-sample-alma87 ~]# dotnet --info
.NET SDK:
 Version:   7.0.101
 Commit:    5afc08ace5

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

Host:
  Version:      7.0.1
  Architecture: ppc64le
  Commit:       97203d38ba

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

.NET runtimes installed:
  Microsoft.AspNetCore.App 7.0.1 [/usr/lib64/dotnet/shared/Microsoft.AspNetCore.App]
  Microsoft.NETCore.App 7.0.1 [/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

(3) サンプルコードの稼働

今回は、以下のGitHubレポジトリに公開しているサンプルコードを使用して稼働確認をしてみたいと思います。
こちらのレポジトリは、様々なところに公開されている.NET のサンプルコードをこのQiitaの記事用に集めたものとなります。

まずは評価環境上で、gitコマンドを使用できるように必要パッケージをインストールします。

[root@dotnet-sample-alma87 ~]# dnf install -y git

次に、対象のサンプルコードを上記のGitHubレポジトリよりダウンロードします。

[root@dotnet-sample-alma87 ~]# git clone https://github.com/nakaji1106/dotnet-demo.git
Cloning into 'dotnet-demo'...
remote: Enumerating objects: 135, done.
remote: Counting objects: 100% (135/135), done.
remote: Compressing objects: 100% (106/106), done.
remote: Total 135 (delta 23), reused 115 (delta 16), pack-reused 0
Receiving objects: 100% (135/135), 436.89 KiB | 728.00 KiB/s, done.
Resolving deltas: 100% (23/23), done.

このGitHubレポジトリには、"BlazorServerSignalRApp" と"dotnetapp" の2つがあります。
今回は、dotnetappの動作を確認します。

[root@dotnet-sample-alma87 ~]# cd dotnet-demo/
[root@dotnet-sample-alma87 dotnet-demo]# ll
合計 8
drwxr-xr-x. 10 root root 4096 12月 20 02:14 BlazorServerSignalRApp
-rw-r--r--.  1 root root  563 12月 20 02:14 README.md
drwxr-xr-x.  2 root root   30 12月 20 02:14 dotnetapp

dotnetapp では、稼働環境のシステム情報を取得し、出力するアプリケーションが実装されています。
正常に稼働すれば、CPU情報やメモリの情報などが確認できるはずです。

[root@dotnet-sample-alma87 dotnet-demo]# cd dotnetapp/
[root@dotnet-sample-alma87 dotnetapp]# ls
Program.cs  dotnetapp.csproj

早速、dotnetappディレクトリにて、.NETアプリケーションのRestore作業ならびにRun(起動)をしてみます。
ちなみにこのアプリケーションは、x86用に作成されたものをそのまま使用しています。

Restore 作業
[root@dotnet-sample-alma87 dotnetapp]# dotnet restore
  Determining projects to restore...
  Restored /root/dotnet-demo/dotnetapp/dotnetapp.csproj (in 220 ms).
[root@dotnet-sample-alma87 dotnetapp]# ls
Program.cs  dotnetapp.csproj  obj
Run 作業
[root@dotnet-sample-alma87 dotnetapp]# dotnet run
         42                                                    
         42              ,d                             ,d     
         42              42                             42     
 ,adPPYb,42  ,adPPYba, MM42MMM 8b,dPPYba,   ,adPPYba, MM42MMM  
a8"    `Y42 a8"     "8a  42    42P'   `"8a a8P_____42   42     
8b       42 8b       d8  42    42       42 8PP!!!!!!!   42     
"8a,   ,d42 "8a,   ,a8"  42,   42       42 "8b,   ,aa   42,    
 `"8bbdP"Y8  `"YbbdP"'   "Y428 42       42  `"Ybbd8"'   "Y428  
.NET 7.0.1
AlmaLinux 8.7 (Stone Smilodon)

UserName: root
OSArchitecture: Ppc64le
ProcessorCount: 4
TotalAvailableMemoryBytes: 5905842176 (5.000 GiB)

無事にサンプルコードが動きました!

まとめ

今回のブログでは、まず.NET 7がLinux on power (IBM Power)環境で問題なく稼働することを確認しました。サンプルコードも特にCPUアーキテクチャについて意識することなく、ソースコードの変更は"ゼロ"でそのまま動かすことが出来ました。
また、AlmaLinuxのようにRHEL互換の無償 LinuxOSでも問題なく動作することも分かりました。機会があればRockey LinuxやCentOS Stream環境でも評価してみたいなとも思います。

個人的には、まだまだ.NETアプリケーションの実装部分については理解が足りていないので、次の投稿予定の"2. 「x86環境で作成された.NET アプリケーションはppc64le環境でもそのまま動くのか」" では、アプリケーションの互換性があるのかという点とともに、サンプルコードを自分なりに変更しながら、.NETの理解も進められたらと思います。

「.NET をIBM Powerで動かしてみた話 #2 」はこちらから↓

それでは、今回は以上となります。本記事が何かの参考となれば幸いです。

3
1
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
3
1