Archive for the ‘System’ Category

How to use IPMI on Debian

Posted by อัทศักดิ์ วงศ์กิตตะ on Tuesday, November 2nd, 2010

โหลด IPMI Kernel Modules

modprobe ipmi_watchdog
modprobe ipmi_poweroff
modprobe ipmi_msghandler
modprobe ipmi_devintf
modprobe ipmi_si

ติดตั้ง ipmitool

apt-get install ipmitool

ทำการ config ipmi

ipmitool lan set 1 ipaddr 192.168.1.101
ipmitool lan set 1 netmask 255.255.255.0
ipmitool lan set 1 defgw ipaddr 192.168.1.254
ipmitool lan set 1 password mypassword
ipmitool lan set 1 access on
ipmitool lan set 1 arp respond on
ipmitool mc reset cold

วิธีการใช้งาน

ดู สถาณะ Power

ipmitool -H 192.168.1.101 -U root -P mypassword power status

Reset  เครื่อง

ipmitool -H 192.168.1.101 -U root -P mypassword power reset

หากท่านใช้ iPhone ผมแนะนำ IPNI Touch ครับ สามารถสั่ง Power On/Off/Reset ได้เลย ทำให้ Admin อย่างเราๆมีชีวิตที่แสนสบายขึ้นเยอะเลยครับ

HA Proxy High Performance TCP/HTTP Load Balancer

Posted by อัทศักดิ์ วงศ์กิตตะ on Wednesday, October 20th, 2010

วันนี้ประเดิม Blog แรกด้วย HAProxy   ซึ่งเป็น Software load balance  ที่สามารถทำงานได้ถึง Layer7    หลักๆผมเอามาทำเป็น HTTP Load Balance    เป้าหมายหลักๆที่ต้องการคือ

  • แยกโหลดไปยังเครื่อง Web Node แต่ละเครื่องได้
  • กำหนด weight  ของแต่ละ Server ได้
  • สามารถทำ health check script ได้เอง
  • สามารถ ทำงานได้ในระดับ Layer 7 ได้

หลังจากผมใช้งาน Linux-Ha (ipvsadm) มานาน  ผมพบปัญหาว่า บางครั้งหากเครื่อง Web Node มีปัญหาเครื่อง Load balance จะไม่ปลดโหลดออก ทำให้ผู้ใช้งานไม่สามารถใช้งานได้       ผมเลยลองค้นหาเรื่อง L7 Load Balance   จึงมาพบ  HA Proxy    เลยลอง apt-get install haproxy   ดูพบว่าใน Debian ก็มี package มาให้ เลยลองติดตั้งพบว่า สามารถตอบสนอง ความต้องการของผมได้เป็นอย่างดี  ยังไงลองมาดูกันครับ ว่าติดตั้งและใช้งานเป็นยังไง

ติดตั้ง

apt-get install haproxy
# File /etc/haproxy/haproxy.cfg
global
 daemon
 user            haproxy
 group   haproxy
 maxconn 8192
 log             127.0.0.1       local0
 log             127.0.0.1       local1 notice
 stats           socket  /var/run/haproxy.sock mode 666

defaults
 log             global
 mode    http
 option  httplog
 option  dontlognull
 option  httpclose
 #option forwardfor

 stats           enable
 retries 3
 option  redispatch
 maxconn 65535
 contimeout      5000
 clitimeout      50000
 srvtimeout      50000

listen  igetweb.com 0.0.0.0:80
 balance roundrobin

 acl     url_static              path_beg                /images /image /css
 acl     url_static              path_end                .jpg .jpeg .JPG .gif .png .ico .css .zip .tgz .gz .rar .bz2 .doc .xls .exe .pdf .ppt .txt .tar .mid .midi .wav .bmp .rtf .js .swf .wma .wmv

 use_backend             pool_static                     if url_static
 default_backend         pool_dynamic

backend pool_dynamic
 balance roundrobin
 option  httpchk HEAD /check.txt HTTP/1.0
 server web1 192.168.1.11:80  check inter 2000 fall 3 weight 1
 server web2 192.168.1.12:80  check inter 2000 fall 3 weight 1

backend pool_static
 balance roundrobin
 option  httpchk HEAD /check.txt HTTP/1.0
 server web1 192.168.1.21:80  check inter 2000 fall 3 weight 1
 server web2 192.168.1.22:80  check inter 2000 fall 3 weight 1

ส่วนสำคัญคือ ACL โดยเราได้ทำการประกาศ ACL ที่ชื่อ url_static โดยหากผู้ใช้งานเรียก url ที่ขึ้นต้นด้วย /image /images /css หรือ ไฟล์ที่ลงท้ายด้วย jpg, jpge และทำการประกาศว่า หาก macth acl url_static ให้ไปเรียกใช้ pool_static แค่นี้เราก็มี L7 Load Balance ไว้ใช้งาน โดยไม่ต้องเสียงินหลักแสน ซื้อ Hardware Load balance แล้วครับ