AlamLinux9 初期設定

スポンサーリンク

インストール直後に行う初期設定をまとめていきます。

■SELinuxの設定

AlmaLinux9からはSELinuxの設定方法が少々変更になりました。

従前は/etc/sysconfig/selinuxファイルの編集でいけてました。

vi /etc/sysconfig/selinux

# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
#     enforcing - SELinux security policy is enforced.
#     permissive - SELinux prints warnings instead of enforcing.
#     disabled - No SELinux policy is loaded.
# See also:
# https://docs.fedoraproject.org/en-US/quick-docs/getting-started-with-selinux/#getting-started-with-selinux-selinux-states-and-modes
#
# NOTE: In earlier Fedora kernel builds, SELINUX=disabled would also
# fully disable SELinux during boot. If you need a system with SELinux
# fully disabled instead of SELinux running with no policy loaded, you
# need to pass selinux=0 to the kernel command line. You can use grubby
# to persistently set the bootloader to boot with selinux=0:
#
#    grubby --update-kernel ALL --args selinux=0
#
# To revert back to SELinux enabled:
#
#    grubby --update-kernel ALL --remove-args selinux
#
SELINUX=enforcing
# SELINUXTYPE= can take one of these three values:
#     targeted - Targeted processes are protected,
#     minimum - Modification of targeted policy. Only selected processes are protected.
#     mls - Multi Level Security protection.
SELINUXTYPE=targeted

太字のところで示したよう、disableにするには上のコマンドを実行してくださいとあるので、その通りにします。

# grubby --update-kernel ALL --args selinux=0
# reboot

再起動後、以下のコマンドで無効になっていることを確認します。

# getenforce
Disabled

本機能はセキュリティ上、有効にしておくことが奨励されているものの、有効のままだと色んなアプリの使用に支障がでるため、現実的には無効にしているところのほうが多いのではないかと思われます。


■リポジトリの追加

AlmaLinux9でリポジトリを追加します。

# dnf search epel
Last metadata expiration check: 4:09:36 ago on Fri Apr 21 10:27:54 2023.
================================================== Name Matched: epel ==================================================
epel-release.noarch : Extra Packages for Enterprise Linux repository configuration

# dnf install epel-release

以下の2つのファイルがインストールされます。

# cat /etc/yum.repos.d/epel.repo
[epel]
name=Extra Packages for Enterprise Linux $releasever - $basearch
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=https://download.example/pub/epel/$releasever/Everything/$basearch/
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=1
gpgcheck=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever

[epel-debuginfo]
name=Extra Packages for Enterprise Linux $releasever - $basearch - Debug
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=https://download.example/pub/epel/$releasever/Everything/$basearch/debug/
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-debug-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
gpgcheck=1

[epel-source]
name=Extra Packages for Enterprise Linux $releasever - $basearch - Source
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=https://download.example/pub/epel/$releasever/Everything/source/tree/
metalink=https://mirrors.fedoraproject.org/metalink?repo=epel-source-$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
gpgcheck=1
# cat /etc/yum.repos.d/epel-testing.repo
[epel-testing]
name=Extra Packages for Enterprise Linux $releasever - Testing - $basearch
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=https://download.example/pub/epel/testing/$releasever/Everything/$basearch/
metalink=https://mirrors.fedoraproject.org/metalink?repo=testing-epel$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgcheck=1
countme=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever

[epel-testing-debuginfo]
name=Extra Packages for Enterprise Linux $releasever - Testing - $basearch - Debug
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=https://download.example/pub/epel/testing/$releasever/Everything/$basearch/debug/
metalink=https://mirrors.fedoraproject.org/metalink?repo=testing-debug-epel$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
gpgcheck=1

[epel-testing-source]
name=Extra Packages for Enterprise Linux $releasever - Testing - $basearch - Source
# It is much more secure to use the metalink, but if you wish to use a local mirror
# place its address here.
#baseurl=https://download.example/pub/epel/testing/$releasever/Everything/source/tree/
metalink=https://mirrors.fedoraproject.org/metalink?repo=testing-source-epel$releasever&arch=$basearch&infra=$infra&content=$contentdir
enabled=0
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-EPEL-$releasever
gpgcheck=1


■起動サービスについて

AlmaLinux9はインストール直後には様々なサービスが有効になっていますので不要なものは停止するよう設定します。あくまで私の環境化なので一例ということで記載しております。

systemctl disable atd
systemctl disable auditd
systemctl disable bluetooth
systemctl disable irqbalance
systemctl disable kdump
systemctl disable lvm2-monitor
systemctl disable mcelog
systemctl disable mdmonitor
systemctl disable microcode
systemctl disable nis-domainname
systemctl disable nvmefc-boot-connections
systemctl disable smartd
systemctl disable sssd
systemctl disable tuned

次回以降、起動しなくなるので一旦再起動します。

reboot


■時刻同期について

AlmaLinux9では時刻同期にChronyサービスがデフォルトでインストールされています。基本的にここではNTPサーバとしてではなく、NTPクライアントとして設定することを前提としています。

chronyの設定ファイルは/etc/chrony.confです。

# cat /etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (https://www.pool.ntp.org/join.html).
pool 2.almalinux.pool.ntp.org iburst

# Use NTP servers from DHCP.
sourcedir /run/chrony-dhcp

# Record the rate at which the system clock gains/losses time.
driftfile /var/lib/chrony/drift

# Allow the system clock to be stepped in the first three updates
# if its offset is larger than 1 second.
makestep 1.0 3

# Enable kernel synchronization of the real-time clock (RTC).
rtcsync

# Enable hardware timestamping on all interfaces that support it.
#hwtimestamp *

# Increase the minimum number of selectable sources required to adjust
# the system clock.
#minsources 2

# Allow NTP client access from local network.
#allow 192.168.0.0/16

# Serve time even if not synchronized to a time source.
#local stratum 10

# Require authentication (nts or key option) for all NTP sources.
#authselectmode require

# Specify file containing keys for NTP authentication.
keyfile /etc/chrony.keys

# Save NTS keys and cookies.
ntsdumpdir /var/lib/chrony

# Insert/delete leap seconds by slewing instead of stepping.
#leapsecmode slew

# Get TAI-UTC offset and leap seconds from the system tz database.
leapsectz right/UTC

# Specify directory for log files.
logdir /var/log/chrony

# Select which information is logged.
#log measurements statistics tracking

指定したい好みのNTPサーバがあればそれを指定すれば良いのですが、基本的に何も設定は触らなくて大丈夫です。このままでも時刻同期できます。次のコマンドで同期の状態を確認できます。

# chronyc tracking

Reference ID    : 5EC69F0B (nts1.time.nl)
Stratum         : 2
Ref time (UTC)  : Fri Apr 21 07:18:53 2023
System time     : 0.001896059 seconds fast of NTP time
Last offset     : +0.000915421 seconds
RMS offset      : 0.003955518 seconds
Frequency       : 21.477 ppm slow
Residual freq   : +0.365 ppm
Skew            : 3.018 ppm
Root delay      : 0.202217773 seconds
Root dispersion : 0.002127213 seconds
Update interval : 195.7 seconds
Leap status     : Normal

実際に時刻同期を行っているサーバは以下のコマンドで確認できます。同期を行っているサーバとのところで*がついています。

# chronyc sources

MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^+ ntp2.belbone.be               2   7   377   129   +440us[+1354us] +/-  137ms
^* nts1.time.nl                  1   6   377   129    +15ms[  +16ms] +/-  105ms
^+ vmi586073.contaboserver.>     2   7   377    63  -8298us[-8298us] +/-  133ms
^+ mx.ae9.eu                     2   6   377     0  -6169us[-6169us] +/-  190ms


■logrotateの設定について

AlamLinuxをMinimalでインストールしたからなのか、理由がよくわからないのですが、logrotate自体はインストールされているものの/var/log配下のcronやmessageなどのファイルが肥大化しつづけていました。

調べると/etc/logrotate.d配下にあるはずのsyslogファイルが存在しておらず、ローテイト対象とはなっておりませんでした。そのため/etc/logrorate.dに以下の内容でsyslogファイルを作成します。

# vi /etc/logrotate.d/syslog

/var/log/cron
/var/log/maillog
/var/log/messages
/var/log/secure
/var/log/spooler
{
    missingok
    sharedscripts
    postrotate
        /usr/bin/systemctl -s HUP kill rsyslog.service >/dev/null 2>&1 || true
    endscript
}

デフォルトは週ローテイトで4世代まで保存されます。

スポンサーリンク

シェアする

  • このエントリーをはてなブックマークに追加

フォローする