はじめに、
前回でslurmマスターをソースからインストールする方法を行いました。
slurmのワーカーノードもソースからインストールするというのも一つの手ですが、一般的にslurmのワーカーノードは数台から数千台になることがありますので非現実的です。
そこで今回はslurmのワーカーノード用にソースをrpmbuildでパッケージ化することを行います。
前提条件などは前回の記事に記載しています。openhpc x slurm x beeGFS環境の構築と検証:slurmマスターのインストール
尚リポジトリからインストールしていた部分はどうするかについては、ansibleを使って配布する記事を後日書きますので、しばしお待ちください。
パッケージを作成するために必要な事。
通常何気なく、apt
dnf
yum
コマンドでパッケージをインストールされていると思います。ここではそのパッケージをどうやって作成しているのか、そのための事前準備について記載していきます。っと言っても準備するのは3つ、フォルダ、ソースファイル、specファイルの3つだけです。
パッケージを作成する際に必要なディレクトリ
cd rpmbuild
[root@master01 rpmbuild]# ls -al
drwxr-xr-x 8 root root 89 Sep 1 20:38 .
dr-xr-x---. 10 root root 4096 Sep 1 22:13 ..
drwxr-xr-x 9 root root 166 Sep 3 22:55 BUILD
drwxr-xr-x 2 root root 6 Sep 3 22:57 BUILDROOT
drwxr-xr-x 3 root root 20 Sep 1 21:52 RPMS #パッケージ化出来たファイルが保存されます
drwxr-xr-x 2 root root 180 Sep 2 00:09 SOURCES #パッケージ化するためのファイルはここに入れときます。
drwxr-xr-x 2 root root 118 Sep 3 22:55 SPECS # どのようにコンパイルするのかは[ツール名].specふぁいるで定義します
drwxr-xr-x 2 root root 4096 Sep 3 22:57 SRPMS
パッケージを作成するために必要なソースファイル
既にダウンロードしているソースファイルをtar.gzに戻すのも手ですが、
今回は各サイトに既に用意されているソースファイルのtar.gzをダウンロードして配置します。
[root@master01 SOURCES]# wget https://github.com/libevent/libevent/releases/download/release-2.1.12-stable/libevent-2.1.12-stable.tar.gz
[root@master01 SOURCES]# wget https://download.open-mpi.org/release/hwloc/v2.10/hwloc-2.10.0.tar.gz
[root@master01 SOURCES]# wget https://github.com/openpmix/openpmix/releases/download/v4.2.9/pmix-4.2.9.tar.gz
[root@master01 SOURCES]# wget https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-5.0.5.tar.gz
[root@master01 SOURCES]# wget https://github.com/openucx/ucx/releases/download/v1.17.0/ucx-1.17.0.tar.gz
[root@master01 SOURCES]# wget https://github.com/dun/munge/archive/refs/tags/munge-0.5.15.tar.gz
[root@master01 SOURCES]# wget https://download.schedmd.com/slurm/slurm-23.11.10.tar.bz2
[root@master01 SOURCES]# ls -al
total 62284
drwxr-xr-x 2 root root 180 Sep 2 00:09 .
drwxr-xr-x 8 root root 89 Sep 1 20:38 ..
-rw-r--r-- 1 root root 6065893 Sep 1 21:51 hwloc-2.10.0.tar.gz
-rw-r--r-- 1 root root 1100847 Dec 7 2021 libevent-2.1.12-stable.tar.gz
-rw-r--r-- 1 root root 283185 Sep 1 22:56 munge-0.5.15.tar.gz
-rw-r--r-- 1 root root 42840834 Jul 23 08:58 openmpi-5.0.5.tar.gz
-rw-r--r-- 1 root root 6068111 Feb 5 2024 pmix-4.2.9.tar.gz
-rw-r--r-- 1 root root 7407211 Aug 28 05:23 slurm-23.11.10.tar.bz2
パッケージを作成するために必要なspecファイル
specは簡単に言えば、前回コンパイルしたときの手順やコンパイルするときに必要な依存関係にあるツールやライブラリを記述するファイルです。このファイルを元にパッケージを作ってくれます。
ただいきなり一からファイルを作るのは面倒です。
こういうときはchatgptさんにサクッと作って貰うことをお勧めします。
一発で正確なspecファイルを作ってくれるときもありますが、大概ちょこっとエラーが出ますので
適宜エラーメッセージをchatgptにそのままコピペしたら作ってくれます。
本当に便利な世の中になりました。
chatgptへの指示も共有します。(面倒だったのですごく簡単な指示しか書いてません。本来は箇条書きにしたりした方が間違いが少ないです)
https://chatgpt.com/share/8b00739d-a997-467f-bb39-bfcbf1367349
[root@master01 SPECS]# ls -al
total 28
drwxr-xr-x 2 root root 134 Sep 3 23:37 .
drwxr-xr-x 8 root root 89 Sep 1 20:38 ..
-rw-r--r-- 1 root root 666 Sep 1 21:51 hwloc.spec
-rw-r--r-- 1 root root 1077 Sep 1 22:06 libevent.spec
-rw-r--r-- 1 root root 1539 Sep 2 00:00 munge.spec
-rw-r--r-- 1 root root 916 Sep 1 22:43 openmpi.spec
-rw-r--r-- 1 root root 749 Sep 1 22:30 pmix.spec
-rw-r--r-- 1 root root 1284 Sep 3 22:55 slurm.spec
-rw-r--r-- 1 root root 795 Sep 3 23:37 ucx.spec
Name: hwloc
Version: 2.10.0
Release: 1%{?dist}
Summary: Portable Hardware Locality
License: BSD
URL: https://www.open-mpi.org/software/hwloc/
Source0: %{name}-%{version}.tar.gz
BuildRequires: gcc, make
%description
hwloc provides command line tools and a C API to obtain the hierarchical map of key computing resources.
%prep
%setup -q
%build
./configure --prefix=%{_prefix}/hwloc/2.10.0
make %{?_smp_mflags}
%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
%files
%{_prefix}/hwloc/2.10.0
%changelog
* Mon Sep 01 2024 Your Name <your.email@example.com> - 2.10.0-1
- Initial RPM release
Name: libevent
Version: 2.1.12
Release: 1%{?dist}
Summary: The libevent API provides a mechanism to execute a callback function when a specific event occurs on a file descriptor
License: BSD
Group: Development/Libraries
URL: https://libevent.org/
Source0: %{name}-%{version}-stable.tar.gz
BuildRequires: gcc, make, autoconf, automake, libtool, python3
%description
The libevent API provides a mechanism to execute a callback function when a specific event occurs on a file descriptor.
%prep
%setup -q -n %{name}-%{version}-stable
%build
./configure --prefix=%{_prefix}/libevent/%{version}
make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
# Fix ambiguous python shebang
sed -i '1s|^#!/usr/bin/env python|#!/usr/bin/env python3|' $RPM_BUILD_ROOT%{_prefix}/libevent/%{version}/bin/event_rpcgen.py
# Fix permissions for .la files
chmod -x $RPM_BUILD_ROOT%{_prefix}/libevent/%{version}/lib/*.la
%files
%{_prefix}/libevent/%{version}
%changelog
* Sun Aug 25 2024 Your Name <your.email@example.com> - 2.1.12-1
- Initial RPM release
Name: munge
Version: 0.5.15
Release: 1%{?dist}
Summary: MUNGE (MUNGE Uid 'N' Gid Emporium) is an authentication service
License: GPLv3
URL: https://github.com/dun/munge
Source0: %{name}-%{version}.tar.gz
BuildRequires: gcc, make, systemd
%description
MUNGE (MUNGE Uid 'N' Gid Emporium) is an authentication service for creating and validating credentials.
%prep
%setup -q -n munge-munge-%{version}
%build
./bootstrap
%configure --prefix=/opt/munge/%{version} \
--sysconfdir=/opt/munge/%{version}/etc \
--localstatedir=/var \
--with-runstatedir=/run \
--bindir=/opt/munge/%{version}/bin \
--sbindir=/opt/munge/%{version}/sbin \
--libdir=/opt/munge/%{version}/lib \
--mandir=/opt/munge/%{version}/share/man
make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
ln -s /opt/munge/%{version} $RPM_BUILD_ROOT/opt/munge/release
# systemd service file
mkdir -p $RPM_BUILD_ROOT/etc/systemd/system
install -m 644 src/etc/munge.systemd.service $RPM_BUILD_ROOT/etc/systemd/system/munge.service
%files
%license COPYING
%doc README.md
/opt/munge/%{version}
/opt/munge/release
/etc/systemd/system/munge.service
/usr/include/munge.h
%post
systemctl daemon-reload
%preun
if [ $1 -eq 0 ]; then
systemctl stop munge.service
systemctl disable munge.service
fi
%postun
if [ $1 -eq 0 ]; then
systemctl daemon-reload
fi
%changelog
* Mon Sep 1 2024 Your Name <your.email@example.com> - 0.5.15-1
- Initial RPM release
Name: openmpi
Version: 5.0.5
Release: 1%{?dist}
Summary: OpenMPI v5.0.5
License: BSD
URL: https://www.open-mpi.org/
Source0: https://download.open-mpi.org/release/open-mpi/v5.0/openmpi-5.0.5.tar.gz
BuildRequires: gcc, gcc-c++, make
%description
Open MPI is a project combining technologies and resources from several other projects
(FT-MPI, LA-MPI, LAM/MPI, and PACX-MPI) in order to build the best MPI library available.
%prep
%setup -q
%build
./configure --prefix=%{_prefix}/openmpi-%{version} --with-libevent=/opt/libevent/release --with-hwloc=/opt/hwloc/release --with-pmix=/opt/pmix/release --with-slurm
make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
%files
%{_prefix}/openmpi-%{version}
%changelog
* Mon Aug 19 2024 Your Name <your.email@example.com> - 5.0.5-1
- Initial RPM release of OpenMPI 5.0.5
Name: pmix
Version: 4.2.9
Release: 1%{?dist}
Summary: PMIx library
License: BSD
URL: https://github.com/openpmix/openpmix
Source0: %{name}-%{version}.tar.gz
BuildRequires: gcc, gcc-c++
%global debug_package %{nil}
%description
PMIx is a standard for process management services used in high performance computing (HPC) environments.
%prep
%setup -q
%build
./configure --prefix=%{_prefix}/pmix/%{version} --with-libevent=/opt/libevent/release --with-hwloc=/opt/hwloc/release
make %{?_smp_mflags}
%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
%files
%{_prefix}/pmix/%{version}
%changelog
* Mon Sep 01 2024 Your Name <you@example.com> - 4.2.9-1
- Initial RPM release
Name: slurm
Version: 23.11.10
Release: 1%{?dist}
Summary: Slurm Workload Manager
License: GPLv2
URL: https://slurm.schedmd.com/
Source0: https://download.schedmd.com/slurm/slurm-%{version}.tar.bz2
BuildRequires: gcc
BuildRequires: make
Requires: pmix
Requires: ucx
Requires: munge
%description
Slurm is a highly scalable cluster management and job scheduling system for large and small Linux clusters.
%prep
%setup -q
%build
./configure \
--prefix=/opt/slurm/%{version} \
--sysconfdir=/opt/slurm/%{version}/etc \
--with-pmix=/opt/pmix/release \
--with-ucx=/opt/ucx/release \
--with-munge=/opt/munge/release
make %{?_smp_mflags}
%install
rm -rf $RPM_BUILD_ROOT
make install DESTDIR=$RPM_BUILD_ROOT
if [ -L /opt/slurm/release ]; then
rm -f /opt/slurm/release
fi
# Create symlinks
ln -s /opt/slurm/%{version} /opt/slurm/release
# Copy systemd service files
install -Dm644 etc/slurmdbd.service %{buildroot}/etc/systemd/system/slurmdbd.service
# Create configuration directory
mkdir -p %{buildroot}/opt/slurm/release/etc
%files
/opt/slurm/%{version}
/etc/systemd/system/slurmdbd.service
%changelog
* Tue Sep 03 2024 Your Name <you@example.com> - 23.11.10-1
- Initial package
Name: ucx
Version: 1.17.0
Release: 1%{?dist}
Summary: UCX - Unified Communication X framework
License: BSD-3-Clause
URL: https://github.com/openucx/ucx
Source0: https://github.com/openucx/ucx/releases/download/v%{version}/ucx-%{version}.tar.gz
BuildRequires: gcc, gcc-c++, make, pkgconfig, autoconf, automake, libtool
%description
UCX is a communication framework for HPC systems, providing low-latency and high-bandwidth communication.
%prep
%setup -q
%build
./configure --prefix=%{_prefix}/ucx/%{version}
make %{?_smp_mflags}
%install
rm -rf %{buildroot}
make install DESTDIR=%{buildroot}
%files
%{_prefix}/ucx/%{version}
%changelog
* Tue Sep 03 2024 Your Name <your.email@example.com> - 1.17.0-1
- Initial RPM package for UCX
準備が出来たのでパッケージ作成
以下のコマンド実行したらパッケージが出来上がります。
コンパイルしているので、ログが大量に出ます。(今回は省略)
rpmbuild -ba libevent.spec
rpmbuild -ba hwloc.spec
rpmbuild -ba mpix.spec
rpmbuild -ba openmpi.spec
rpmbuild -ba munge.spec1
rpmbuild -ba ucx.spec
rpmbuild -ba slurm.spec
パッケージはRPM/x86_64(環境による)の下にあります。
[root@master01 x86_64]# ls -al
total 49204
drwxr-xr-x 2 root root 4096 Sep 3 23:39 .
drwxr-xr-x 3 root root 20 Sep 1 21:52 ..
-rw-r--r-- 1 root root 2532640 Sep 1 21:52 hwloc-2.10.0-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 753320 Sep 1 21:52 hwloc-debuginfo-2.10.0-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 363136 Sep 1 21:52 hwloc-debugsource-2.10.0-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 404176 Sep 1 22:06 libevent-2.1.12-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 527176 Sep 1 22:06 libevent-debuginfo-2.1.12-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 291744 Sep 1 22:06 libevent-debugsource-2.1.12-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 148236 Sep 2 00:01 munge-0.5.15-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 253572 Sep 2 00:01 munge-debuginfo-0.5.15-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 135456 Sep 2 00:01 munge-debugsource-0.5.15-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 10660820 Sep 1 22:49 openmpi-5.0.5-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 287228 Sep 1 22:49 openmpi-debuginfo-5.0.5-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 206364 Sep 1 22:49 openmpi-debugsource-5.0.5-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 3854668 Sep 1 22:31 pmix-4.2.9-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 8980608 Sep 3 22:57 slurm-23.11.10-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 10105680 Sep 3 22:57 slurm-debuginfo-23.11.10-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 2810188 Sep 3 22:57 slurm-debugsource-23.11.10-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 2238356 Sep 3 23:39 ucx-1.17.0-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 4759136 Sep 3 23:39 ucx-debuginfo-1.17.0-1.el8.x86_64.rpm
-rw-r--r-- 1 root root 1025104 Sep 3 23:39 ucx-debugsource-1.17.0-1.el8.x86_64.rpm
最後に、やり残した事。
前回ソースで説明してしまったので解説することがなく、サクサクっと終わらせました。
実際にはchatgptさんがBuildRequires
にmunge-devel
などのパッケージを指定してくることがありますが今回はソースから行っているのでその記述は削除してください--with
で指定しているので問題ありません。
この段階でやり残した事はslurm.confの書き換え、serviceファイルの書き換え、今回ビルドしたパッケージ以外にインストールが必要なパッケージが残っています。
書き換えはspecファイルファイルでも記述出来るのですが、あえて残しています。
次回この残りをansibleで解決していきたいと思います。