Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Linuxシステム概要

 Linuxシステム概要

社内勉強会ではなしたもの

Shota Ito

April 12, 2019
Tweet

More Decks by Shota Ito

Other Decks in Technology

Transcript

  1. LINUXγεςϜʹ͍ͭͯ ͓໿ଋ ▸ ࠓ೔͸Χʔωϧͦͷ΋ͷ·Ͱߦ͖ண͖·ͤΜ ▸ ࠓ೔࿩͢͜ͱ͸Ή͍ͣͰ͢ ▸ ͍ͯ͏͔ɺࢲ΋Θ͔Βͳ͍͜ͱ͕΄΅શͯͰ͢ ▸ Θ͔Βͳ͍ͷ͕ී௨Ͱ͢

    ▸ ੲͷϓϩάϥϚʔ͸CΛॻ͍ͨܦݧ͔ΒΘ͔Δ͔΋ ▸ ςʔϚ͕େ͖͗͢ΔͷͰ֓ཁఔ౓Ͱ͢ ▸ ڵຯΛ࣋ͬͨਓ͕͍ͨΒݸผʹฉ͍͍ͯͩ͘͞
  2. Χʔωϧ σόΠε σόΠευϥΠό εϨου εέδϡʔϥ ϑΝΠϧ γεςϜ ωοτϫʔΫ ελοΫ Ծ૷ϝϞϦ

    γεςϜίʔϧ ϢʔβϨϕϧ ΧʔωϧϨϕϧ γεςϜϥΠϒϥϦ σʔλϕʔε ΞϓϦέʔγϣϯ
  3. Χʔωϧ σόΠε σόΠευϥΠό εϨου εέδϡʔϥ ϑΝΠϧ γεςϜ ωοτϫʔΫ ελοΫ Ծ૷ϝϞϦ

    γεςϜίʔϧ ϢʔβϨϕϧ ΧʔωϧϨϕϧ γεςϜϥΠϒϥϦ σʔλϕʔε ΞϓϦέʔγϣϯ
  4. LINUXγεςϜʹ͍ͭͯ γεςϜϥΠϒϥϦͬͯʁ ▸ ༗໊Ͳ͜Ζ͸glibc(GNU C Library) ▸ php΍java΋࠷ऴతʹ͸glibcΛinclude͍ͯ͠Δ
 ˞΋ͪΖΜଞʹ΋୔ࢁinclude͍ͯ͠·͢ ▸

    openldap-devel.x86_64, openssl-devel.x86_64, zlib- devel.x86_64…౳ ▸ GNU: GNUͱ͸ΦϖϨʔςΟϯάγεςϜͰ͋Γɺ
 ͔ͭίϯϐϡʔλιϑτ΢ΣΞͷ޿ൣғʹ౉ΔίϨΫγϣϯͰ͋Δɻ (wiki͔ΒҾ༻)
  5. Χʔωϧ σόΠε σόΠευϥΠό εϨου εέδϡʔϥ ϑΝΠϧ γεςϜ ωοτϫʔΫ ελοΫ Ծ૷ϝϞϦ

    γεςϜίʔϧ ϢʔβϨϕϧ ΧʔωϧϨϕϧ γεςϜϥΠϒϥϦ σʔλϕʔε ΞϓϦέʔγϣϯ
  6. LINUXγεςϜʹ͍ͭͯ APACHE HTTPDͷγεςϜίʔϧΛͷ͍ͧͯݟΔ ▸ શίʔϧΛऔಘ
 # strace $(for pid in

    `pgrep httpd`;do echo -n "-p $pid ";done) ▸ getsockname,accept,accept4Λऔಘ
 # strace $(for pid in `pgrep httpd`;do echo -n "-p $pid ";done) -e trace=getsockname,accept,accept4 ▸ grepͰߜΔ࣌
 strace $(for pid in `pgrep httpd`;do echo -n "-p $pid ";done) 2>&1 | grep '192.168.120.129' ▸ iptablesͰःஅ͢Δͱίʔϧঢ়ଶ͸Ͳ͏ͳΔʁ
  7. LINUXγεςϜʹ͍ͭͯ TIPS: ύΠϓͷ࢓૊Έˏ֬ೝͯ͠ΈΔ ▸ ྫɿ$ cat hoge.txt | grep ito

    ▸ ʮcat | grep itoʯΛίʔϧϨϕϧͰ௥͍͔͚ͯΈΔ ▸ strace -p `pgrep cat` ▸ strace -p `pgrep grep` ▸ lsof -p `pgrep cat` ▸ lsof -p `pgrep grep`
  8. LINUXγεςϜʹ͍ͭͯ TIPS: ύΠϓͷ࢓૊Έˏղઆ CAT ϓϩηε GREP ϓϩηε Χʔωϧ͕༻ҙ͍ͯ͠ΔϦϯάόοϑΝ /DEV/PTS/0 ϓϩηε

    pipe:[412981] ᶃϑΝΠϧσΟεΫϦϓλ̌(࣮ମɿ/dev/pts/0)ΛಡΉ
 read(0, “hoge¥n”, 65536) ᶄϑΝΠϧσΟεΫϦϓλ̍(࣮ମɿpipe:[412981])΁ॻ͖ࠐΉ
 write(1, “hoge¥n”, 5) ᶅϑΝΠϧσΟεΫϦϓλ̌(࣮ମɿpipe:[412981])ΛಡΉ
 read(0, “hoge¥n”, 32768) write callʹ͍ͭͯ read callʹ͍ͭͯ ϦϯάόοϑΝʹ͍ͭͯ ϑΝΠϧσΟεΫϦϓλʹ͍ͭͯ
  9. LINUXγεςϜʹ͍ͭͯ ϦϦʔεલੑೳτϥϒϧγϡʔτ(࣮࿩ WEB APP ▸ ͳΜ͔Α͘Θ͔Βͳ͍͚Ͳɺ஗͍ʂௐࠪͯ͠ʂ DB LB Ϩεϙϯε͸ͲΕ͘Β ͍Ͱฦ͍ͯ͠Δʁ

    Τϥʔ͸ʁ ໰୊ͳͦ͞͏ ΞϓϦͷϨεϙϯε&Τϥʔ͸໰ ୊ͳͦ͞͏ʁ Ϩεϙϯε͕Ͱͯͳ͍ !! DB͸ॏ͘ͳ͍ʁ ໰୊ͳͦ͞͏