サーバーの /etc/hosts を更新して、ホスト名で追加したサーバーへ疎通がとれるようにする
- 頻繁に実施する際は ansible 化しておいたほうが良い
1. 追加/削除したサーバーへの疎通確認
- 削除する場合は、削除するサーバーへの参照がないかを確認する(grep で conf などを洗う)
for i in $(grep <!-- 更新対象サーバー --> /etc/hosts | awk -F" " '{print $1}') ; do echo -e "
$i" ssh -t $i "grep <!-- 削除するホスト --> <!-- application の conf -->" ; done
- 追加する場合は、疎通できるかを確認
for i in $(grep <!-- 更新対象サーバー --> /etc/hosts | awk -F" " '{print $1}') ; do echo -e "
$i" ssh -t $i "ping <!-- 追加するサーバーのIP -->" ; done
2. /etc/hosts 配布芸
- 踏み台サーバーに入る(手元からやらない!)
- 手元に配布したい conf を tmp_etc_hosts という名前で用意する
- 配布スクリプトを回す
for i in $(grep <!-- 更新対象サーバー --> /etc/hosts | awk -F" " '{print $1}') ; do scp tmp_etc_hosts $i:/tmp/ ; echo -e "
$i"; ssh -t $i "sudo cp /tmp/tmp_etc_hosts /etc/hosts ;" ; done
3. 動作確認
- 各台で名前解決できてるかを確認
for i in $(grep <!-- 更新対象サーバー --> /etc/hosts | awk -F" " '{print $1}') ; do echo -e "
$i" ssh -t $i "ping <!-- 追加した host -->" ; done
Pinned Articles
About
ウェブ界隈でエンジニアとして労働活動に励んでいる @gomi_ningen 個人のブログです
Tags
LLM
promptfoo
GenAI
JavaScript
PowerShell
fluentd
kibana
elasticsearch
nginx
村川梨衣
五十嵐裕美
イベント
logrotate
IoT
Scala
Java
ICMP
iputils
C言語
WUG
mastodon
Swift
AWS
Windows
Clock
PoEAA
アーキテクチャ
iOS
DeviceFarm
プログラミング言語
OS
StepFunctions
Lambda
Serverless
terraform
ポエム
RHEL
ネットワーク
GraphQL
CloudWatch
Linux
Coreutils
nc
network
telnet
LinuxKernel
fpinscala
ELB
IAM
AppSync