CentOS7での初期環境設定
前提
初期設定は、すべてrootユーザを使用して実行する。
ホスト名の変更
ホスト名変更は、今まで/etc/sysconfig/network等に定義していたが、hostnamectlへ移行した。
# hostanmectl set-hostname ${hostname}
example.command
# hostnamectl set-hostname new_host
タイムゾーンの変更
タイムゾーンは、/usr/share/zoneinfo配下にある、各々のゾーンファイルを/etc/localtimeへ置き換える形で変更していたが、timedatectlへ移行した。
# timedatectl list-timezones # タイムゾーンの一覧表示
# timedatectl set-timezones ${timezone}
example.command
# timedatectl set-timezones Asia/Tokyo
localeの変更
localeは、/etc/sysconfig/i18nや/etc/sysconfig/keyboardへ定義していたが、localectlへ移行した。
# localectl list-locales # localeの一覧表示
# localectl set-locale LANG=${locale}
example.command
# localectl set-locale LANG=ja_JP.utf8
iptablesの設定変更
iptablesは、/etc/iptablesなどに直接定義を記述する、または、iptablesコマンドを使用していたが、firewall-cmdへ移行した。
# firewall-cmd --state # 起動確認
# firewall-cmd --reload # 定義反映
# firewall-cmd --add-port=${port_num}/${protocol} # 対象ポートの許可
httpプロトコルの許可を代表として記載
exmaple.command
# firewall-cmd --add-service=http --permanent # httpプロトコル(デフォルト)の解放
# firewall-cmd --add-port=3000/tcp --permanent # port=3000の解放
※ firewall-cmdは、機能が多彩なため、別途書籍等で学習するのが良い。