LoginSignup
2
0

More than 3 years have passed since last update.

サーバ間の全てのファイル差分を調べる

Last updated at Posted at 2018-09-13

背景

Active・Standbyサーバ間のファイル同期がうまくいっておらず、インフラ初心者が調査依頼を受けた。
稼働サーバであったこともあり高負荷は掛けられないようで、、、

  • SSHで繋いで全ファイルのDiff取るのは負荷が過ごそう。(分割は時間かかりそう)
  • 純粋に全ファイル落としてローカルでDiff取ろうにもネットワークの帯域制限に引っかかってDL終わらない。

どうしたものかと考えたあげくこうなった。

やったこと

1.2サーバでファイルのハッシュ値を出力する。

$ find / -type f -not -path "{除外パス}" | xargs md5sum | sed 1d | awk '{print $2,$1}' > /tmp/active_md5sum.txt
$ find / -type f -not -path "{除外パス}" | xargs md5sum | sed 1d | awk '{print $2,$1}' > /tmp/standby_md5sum.txt

2.Diff比較をして差分が出れば中身に違いがあることがわかる

$ diff tmp/active_md5sum.txt /tmp/standby_md5sum.txt
# example
- /etc/aliases 5cf86e039c230ed8dfc36e1ec8cef8ad
+ /etc/aliases 6d7ead55409c2959da7f984c607d2a45

3.実際に差分のあったファイル持ってきて中身を比較

おわりに

こんなやり方で良かったのか、もっとスマートな方法があるんじゃなかと思いながらも妥協した。
そもそも同期してないってどうなの

こんなやり方あるよ。というものがあったら教えてください。m(_ _)m

2
0
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
2
0