LoginSignup
1
8

More than 5 years have passed since last update.

CentOS7 インストール後の初期設定を行う

Posted at

はじめに

CentOS7 の minimal インストール直後に以下を実施します。

  • 全パッケージのアップデート
  • 自動アップデートの設定
  • SELinux を無効化
  • 時刻同期(chronyd)の設定

設定手順

全パッケージのアップデート

概要
 ・インストール直後はパッケージが古いので最新版をインストールする

アップデート

yum -y update

自動アップデートの設定

概要
 ・最新のパッケージに保つため自動アップデートを設定する

インストール

yum -y install yum-cron

設定変更
 ・apply_updates を yes に変更

cp -p /etc/yum/yum-cron.conf /etc/yum/yum-cron.conf.org
vi /etc/yum/yum-cron.conf
/etc/yum/yum-cron.conf
# Whether updates should be applied when they are available.  Note
# that download_updates must also be yes for the update to be applied.
apply_updates = yes

起動設定

systemctl start yum-cron
systemctl enable yum-cron

SELinux を無効化

概要
 ・セキュリティ的には有効のほうが良いが、不都合が多いため無効にする

一時的に無効化

setenforce 0

設定変更
 ・SELINUX を disabled に変更

cp -p /etc/selinux/config /etc/selinux/config.org
vi /etc/selinux/config
/etc/selinux/config
# 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.
SELINUX=disabled

サーバ再起動

reboot

動作確認

getenforce
実行結果
Disabled

※「Disabled」が表示されれば無効化されています。

時刻同期(chronyd)の設定

概要
 CentOS7 から chrony が標準になったようです

  • インストール
yum -y install chrony

設定変更
 ・既存の server 項目をコメントアウト
 ・ntp.nict.jp を使うように追加

cp -p /etc/chrony.conf /etc/chrony.conf.org
vi /etc/chrony.conf
/etc/chrony.conf
# Use public servers from the pool.ntp.org project.
# Please consider joining the pool (http://www.pool.ntp.org/join.html).
#server 0.centos.pool.ntp.org iburst
#server 1.centos.pool.ntp.org iburst
#server 2.centos.pool.ntp.org iburst
#server 3.centos.pool.ntp.org iburst
server ntp.nict.jp iburst

起動設定

systemctl start chronyd
systemctl enable chronyd

動作確認

chronyc sources
実行結果
210 Number of sources = 1
MS Name/IP address         Stratum Poll Reach LastRx Last sample
===============================================================================
^* ntp-b3.nict.go.jp             1  10   377   644  +7955ns[  -13us] +/- 1000us

サーバ名の横に「*」か「+」が表示されれば、時刻同期が行われています。

次回予定

セキュリティ対策を予定

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