Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

インフラエンジニアのためのGit入門

6,168 views

Published on

「システム構成管理にetckeeperを使おう。」
2010年11月に作成した資料ですが、大人の事情でお蔵入りしたままにしていた資料です。

Published in: Technology, Business

インフラエンジニアのためのGit入門

  1. 1. 2010 11 13 . . . . . .
  2. 2. . Git etckeeper. mkouhei@debian.or.jp all id: mkouhei 2010 11 13 2012 1 4 . . . . . .
  3. 3. : , @IT , , KVM(mkouhei) KVMGPG KeyID : :R&D, ( )4096R/7E37CE41 @ITDebian JP Project, !CouchDB Debian #5 Debian Ubuntu ( ) Git ( ) . . . . . .
  4. 4. /etc . . . . . .
  5. 5. . . . . . .
  6. 6. tab . . . . . .
  7. 7. rcs . . . . . .
  8. 8. Subversion . . . . . .
  9. 9. Git . . . . . .
  10. 10. Git ? Git git add index git commit git pushworking directory git checkout local repository remote repository git pull 1 index VCS Git VCS1 VCS . . . . . .
  11. 11. etckeeper . . . . . .
  12. 12. /etc VCSapt yumcronGit, mercurial, bazaar, darcs . . . . . .
  13. 13. 2 Git$ sudo apt-get install etckeeper$ ls -ld /etc/.gitdrwx------ 8 root root 4096 2010-11-12 07:48 /etc/.git 2 Debian . . . . . .
  14. 14. etckeeper Git etckeeper init git config etckeeper commit git log git diff git remote add git push git pull . . . . . .
  15. 15. Git etckeeper git init etckeeper init git config etckeeper vcs config git status etckeeper vcs status git diff etckeeper vcs diffindex git add etckeeper vcs add git commit etckeeper commit git remote add etckeeper vcs remote add git push etckeeper vcs push git pull etckeeper vcs pull . . . . . .
  16. 16. ITIL 変更履歴の確認 etckeeper vcs log git log 変更作業 vi hoge.conf vi hoge.conf 変更内容確認 etckeeper vcs diff 変更状況確認 etckeeper vcs status git diffコミットの事前登録 etckeeper vcs add git status コミット etckeeper commit git add コミットログ確認 etckeeper vcs log etckeeper vcs push git commit バックアップ git log git push . . . . . .
  17. 17. . . . . . .
  18. 18. Git user.name, user.email $ git config user.name=’Gonbeh Nanashi’ $ git config user.email=’gonbeh@example.com’ . . . . . .
  19. 19. etckeeper $ ls -ld /etc/.git drwx------ 8 root root 4096 2010-11-12 07:48 /etc/.git . . . . . .
  20. 20. Why? . . . . . .
  21. 21. /etc/shadowiptablestripwire . . . . . .
  22. 22. . . . . . .
  23. 23. $ git log :/Initialcommit 0a6703b7ac1f521faff1a1b1c7d65a0b104301deAuthor: Gonbeh Nanashi <gonbeh@example.com>Date: Mon May 3 02:08:50 2010 +0900 Initial commit~~~~~~~~~~~~~~~~~(stdin): . . . . . .
  24. 24. .1 $ cd /etc; sudo vi /etc/hosts.2 $ sudo etckeeper vcs status $ sudo etckeeper vcs diff.3 $ sudo etckeeper commit ’add new hosts entries.’ . . . . . .
  25. 25. Git indexadd (ry . . . . . .
  26. 26. Git . 1 $ cd /etc; sudo vi /etc/hosts . 2 $ sudo git status $ sudo git diff . index 3 $ sudo git add hosts . 4 $ sudo git commit -sm ’add new hosts entries.’ . . . . . .
  27. 27. etckeeper Git Git VCS commit git commit -a (init) (commit) root 1. git 2. etckeeper vcs subcommand . . . . . .
  28. 28. git . . . . . .
  29. 29. etckeeper /etc apt yum cron . . . . . .
  30. 30. etckeeper . . . . . .
  31. 31. . . . . . .
  32. 32. . . . . . .
  33. 33. /etc etckeeper Srv0 push Client 198.51.100.100 local repos Srv0 Srv1 Srv2 Srv3 198.51.100.1 198.51.100.11 198.51.100.12 198.51.100.13 remote repos local repos local repos local repos local repos(/etc) (gitosis) (/etc) (/etc) (/etc) git pull git push git push git push git push remote repos remote repos remote repos remote repos local repos (Srv0 /etc bkup) (Srv1 /etc bkup) (Srv2 /etc bkup) (Srv3 /etc bkup) . . . . . .
  34. 34. sshd(/etc/ssh/sshd config) root push root PermitRootLogin yes PasswordAuthentication no ChallengeResponseAuthentication no . . . . . .
  35. 35. ssh root . . . . . .
  36. 36. . . . . . .
  37. 37. root (/root/.ssh/authorized keys) IP from=’198.51.100.1?’ no-pty from="198.51.100.1?",no-pty ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEAx5v6Na2jwzE6xG ah8MVY0Odbi/1oMC6OYolFo3e//Ysacn8r7XOAXIiQvryuIUgzclmJag7EhnfB3pzpNxhu1Ai0c1th ciwdmdZyM+tGGwcrfXERrsipBPbQsr2eMiOX7oX0MQJEHF0qt97EZmIhZ60rS+KfyA1EzIWLDL8Avd h/2MoHwJG6YJqAwkqcvU61DHawLlyNN/XmrXEsObg+APJrvJNXGcu7u6iWBpjeKORuuOkX2rGoESWz OZHtJooZQbzdfjyu3pTrriQLnk9gdYV2Xj7ax8W853n9lZa8JBilleoRfBE192E4fDb4/mMjQPcMTp ywb7QQ== root@example.com . . . . . .
  38. 38. /var/lib/etckeeper/etc host 3 $ sudo mkdir -p /var/lib/etckeeper/etc_Srv{0,1,2,3} $ sudo chmod 700 /var/lib/etckeeper/etc_Srv[0-3] $ cd /var/lib/etckeeper/etc_Srv0; sudo git init --bare $ cd ../etc_Srv1; ( )3 path . . . . . .
  39. 39. /etc$ cd /etc$ sudo git remote add backup ssh://Srv0/etc-Srv1 ( )$ sudo git push backup --all . . . . . .
  40. 40. etckeeper = sudo ssh root . . . . . .
  41. 41. etckeeper 4 1 4 gitosis . . . . . .
  42. 42. Git( ) . . . . . .

×