AWSでよくやる初期構築まとめ。
設定周り
SWAP作成
エフェメラルを全部SWAP化
/etc/rc.d/rc.local に以下を記載※rc.local に実行権限を与えておくこと
mkswap /dev/xvdb
swapon -a
SELinuxの停止
# setenforce 0
で一時的に停止
# vi /etc/selinux/config で
SELINUX=enforcing
↓
SELINUX=disable
にしてサーバ再起動
周りのサーバに接続
Fromのサーバでssh鍵作成
ssh-keygen -t rsa -b 4096
(鍵の保存場所とパスフレーズは堅めなPassを入力してEnter)
Toのサーバに入って生成した鍵(id_rsa.pub)をauthorized_keysに追記
$HOME/.ssh/authorized_keys あたりのやつ
作業ユーザ作成
グループの作成
groupadd -g 1001 hoge
ユーザの作成
useradd -u 1001 -g 1001 -m -d /home/hoge -s /bin/bash hoge
Wheelについか
usermod -G wheel hoge
インストール周り
jqインストール
curl -o /usr/bin/jq http://stedolan.github.io/jq/download/linux64/jq
chmod +x /usr/bin/jq
psql インストール
yum install postgresql
RedhatにAWS CLIインストール
easy_install pip
pip install awscli
■タブ補完有効化
echo 'complete -C /usr/bin/aws_completer aws' > /etc/profile.d/aws-cli.sh
Redhat のロケール変更
ロケールの設定確認
localectl status
ロケールの設定変更
localectl set-locale LANG=ja_JP.utf8
Redhat のTimezone変更
タイムゾーン設定確認
timedatectl status
タイムゾーンを日本に変更
timedatectl set-timezone Asia/Tokyo