วันอาทิตย์ที่ 6 พฤษภาคม พ.ศ. 2555

block virus

#!/bin/sh #--- check ip wan ---# ppp0=`ifconfig | grep -A1 ppp0 | tail -1 | cut -d : -f 2 | cut -f 1 -d " "` ppp1=`ifconfig | grep -A1 ppp1 | tail -1 | cut -d : -f 2 | cut -f 1 -d " "` ppp2=`ifconfig | grep -A1 ppp2 | tail -1 | cut -d : -f 2 | cut -f 1 -d " "` #--- check gw wan ---# ppp0_gw=`ip route | grep ppp0 | head -1 | cut -f 1 -d " "` ppp1_gw=`ip route | grep ppp1 | head -1 | cut -f 1 -d " "` ppp2_gw=`ip route | grep ppp2 | head -1 | cut -f 1 -d " "` #--- add new SNAT ---# iptables -t nat -A POSTROUTING -o ppp0 -j SNAT --to-source $ppp0 iptables -t nat -A POSTROUTING -o ppp1 -j SNAT --to-source $ppp1 iptables -t nat -A POSTROUTING -o ppp2 -j SNAT --to-source $ppp2 #iptables -I INPUT -j ACCEPT iptables -I FORWARD -j ACCEPT iptables -I OUTPUT -j ACCEPT iptables -t nat -A PREROUTING -i eth1 -p tcp -m tcp -d 10.0.1.1/20 --dport 3128 -j DROP iptables -t nat -A PREROUTING -i tun0 -p tcp -m tcp -d 10.0.1.1/20 --dport 3128 -j DROP #--- gmember ---# iptables -t nat -I PREROUTING -i eth1 -p tcp -d youtube.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d hi5.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d facebook.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d gmember.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 203.151.207.0/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d song.gmember.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 174.36.4.0/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 174.36.56.0/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 208.43.218.0/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d rcw.ms --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d forums.overclockzone.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d overclockzone.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 202.170.126.119/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 216.239.61.100/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 203.144.244.116/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 164.115.2.135/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 174.36.56.184/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 203.146.140.137/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 208.43.218.80/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 38.117.107.188/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 174.36.242.26/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 69.65.59.240/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 209.17.69.4/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i eth1 -p tcp -d 61.19.12.17/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d youtube.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d hi5.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d facebook.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d gmember.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d 203.151.207.0/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d song.gmember.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d 174.36.4.0/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d 174.36.56.0/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d 208.43.218.0/24 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d rcw.ms --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d forums.overclockzone.com --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d overclockzone.com --dport 80 -j ACCEPT #--- HTTP Proxy service ---# if [ -f /var/run/squid.pid ]; then iptables -t nat -D PREROUTING -s 0/0 -i eth1 -p tcp --dport 80 -j REDIRECT --to-ports 3128 iptables -t nat -D PREROUTING -s 0/0 -i tun0 -p tcp --dport 80 -j REDIRECT --to-ports 3128 iptables -t nat -D PREROUTING -i eth1 -p tcp -d 10.0.1.1 --dport 80 -j ACCEPT iptables -t nat -D PREROUTING -i tun0 -p tcp -d 10.0.1.1 --dport 80 -j ACCEPT iptables -t nat -A PREROUTING -s 0/0 -i eth1 -p tcp --dport 80 -j REDIRECT --to-ports 3128 iptables -t nat -A PREROUTING -s 0/0 -i tun0 -p tcp --dport 80 -j REDIRECT --to-ports 3128 iptables -t nat -I PREROUTING -i eth1 -p tcp -d 10.0.1.1 --dport 80 -j ACCEPT iptables -t nat -I PREROUTING -i tun0 -p tcp -d 10.0.1.1 --dport 80 -j ACCEPT fi iptables -t mangle -A PREROUTING -i tun0 -m state --state NEW -j MULTIWAN_MARK iptables -t mangle -A PREROUTING -i tun0 -m state --state RELATED,ESTABLISHED -j MULTIWAN_RESTORE iptables -t mangle -A PREROUTING -m state --state NEW -j MULTIWAN_MARK iptables -t mangle -A PREROUTING -m state --state RELATED,ESTABLISHED -j MULTIWAN_RESTORE iptables -t mangle -I PREROUTING -j ACCEPT # Algo string iptables -A FORWARD -m string --algo bm --string "BitTorrent" -j DROP iptables -A FORWARD -m string --algo bm --string "BitTorrent protocol" -j DROP iptables -A FORWARD -m string --algo bm --string "peer_id=" -j DROP iptables -A FORWARD -m string --algo bm --string ".torrent" -j DROP iptables -A FORWARD -m string --algo bm --string "announce.php?passkey=" -j DROP iptables -A FORWARD -m string --algo bm --string "torrent"" -j DROP iptables -A FORWARD -m string --algo bm --string "announce"" -j DROP iptables -A FORWARD -m string --algo bm --string "info_hash" -j DROP #codered virus iptables -A FORWARD -m string --algo bm --string "/default.ida?" -j DROP #nimda virus iptables -A FORWARD -m string --algo bm --string ".exe?/c+dir" -j DROP iptables -A FORWARD -m string --algo bm --string ".exe?/c_tftp" -j DROP # Block Bit 100% iptables -t filter -I FORWARD -i eth+ -m ipp2p --kazaa --gnu --edk --dc --bit --apple --soul --winmx --ares -j DROP iptables -t filter -I FORWARD -i tun0 -m ipp2p --kazaa --gnu --edk --dc --bit --apple --soul --winmx --ares -j DROP iptables -t filter -I FORWARD -i ppp+ -m ipp2p --kazaa --gnu --edk --dc --bit --apple --soul --winmx --ares -j DROP iptables -t filter -I FORWARD -m ipp2p --kazaa --gnu --edk --dc --bit --apple --soul --winmx --ares -j DROP # bittorrent key iptables -A FORWARD -m string --string "peer_id" --algo kmp --to 65535 -j DROP iptables -A FORWARD -m string --string "BitTorrent" --algo kmp --to 65535 -j DROP iptables -A FORWARD -m string --string "BitTorrent protocol" --algo kmp --to 65535 -j DROP iptables -A FORWARD -m string --string "bittorrent-announce" --algo kmp --to 65535 -j DROP iptables -A FORWARD -m string --string "announce.php?passkey=" --algo kmp --to 65535 -j DROP # ----- Block Bit iptables -A FORWARD -m ipp2p --ipp2p -j DROP iptables -I INPUT -s 0.0.0.0/0 -m string --string "info_hash" --algo bm -j DROP iptables -I INPUT -s 0.0.0.0/0 -m string --string "torrent" --algo bm -j DROP iptables -I INPUT -s 0.0.0.0/0 -m string --string "announce" --algo bm -j DROP # DHT keyword iptables -A FORWARD -m string --string "info_hash" --algo kmp --to 65535 -j DROP iptables -A FORWARD -m string --string "get_peers" --algo kmp --to 65535 -j DROP iptables -A FORWARD -m string --string "announce" --algo kmp --to 65535 -j DROP iptables -A FORWARD -m string --string "announce_peers" --algo kmp --to 65535 -j DROP #--- Block Bit layer7 ---# iptables -I FORWARD -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu iptables -I OUTPUT -p tcp --tcp-flags SYN,RST SYN -j TCPMSS --clamp-mss-to-pmtu iptables -I FORWARD -m ipp2p --bit -j DROP iptables -I INPUT -m ipp2p --bit -j DROP iptables -I OUTPUT -m ipp2p --bit -j DROP # Drop package wrom Virus Input iptables -I INPUT -p tcp --dport 135 -j DROP iptables -I INPUT -p udp --dport 135 -j DROP iptables -I INPUT -p tcp --dport 4444 -j DROP iptables -I INPUT -p udp --dport 4444 -j DROP iptables -I INPUT -p tcp --dport 5554 -j DROP iptables -I INPUT -p udp --dport 5554 -j DROP iptables -I INPUT -p tcp --dport 9996 -j DROP iptables -I INPUT -p udp --dport 9996 -j DROP iptables -I INPUT -p tcp --dport 137 -j DROP iptables -I INPUT -p udp --dport 137 -j DROP iptables -I INPUT -p tcp --dport 138 -j DROP iptables -I INPUT -p udp --dport 138 -j DROP iptables -I INPUT -p tcp --dport 139 -j DROP iptables -I INPUT -p udp --dport 139 -j DROP # Drop package wrom Virus Output iptables -I OUTPUT -p tcp --dport 135 -j DROP iptables -I OUTPUT -p udp --dport 135 -j DROP iptables -I OUTPUT -p tcp --dport 4444 -j DROP iptables -I OUTPUT -p udp --dport 4444 -j DROP iptables -I OUTPUT -p tcp --dport 5554 -j DROP iptables -I OUTPUT -p udp --dport 5554 -j DROP iptables -I OUTPUT -p tcp --dport 9996 -j DROP iptables -I OUTPUT -p udp --dport 9996 -j DROP iptables -I OUTPUT -p tcp --dport 137 -j DROP iptables -I OUTPUT -p udp --dport 137 -j DROP iptables -I OUTPUT -p tcp --dport 138 -j DROP iptables -I OUTPUT -p udp --dport 138 -j DROP iptables -I OUTPUT -p tcp --dport 139 -j DROP

มาปรับจูน DNS Server

มาปรับจูน DNS Server กันเถอะ(Clear os) Posted on 2011/09/05 DNS เป็นระบบจัดการในการแปลงจากชื่อไปเป็นหมายเลข IP Address (name-to-IP Address mapping) หรือในทางกลับกันมันก็สามารถแปลงจาก IP Address ไปเป็นชื่อที่มีการตั้งไว้ DNS ถือเป็นฐานข้อมูลแบบ กระจายชนิดหนึ่งที่มีการถูกเรียกใช้งานมากที่สุดและมีการเปลี่ยนแปลงมากที่สุดบนโลกใบนี้ ในระบบ DNS จะมี การเก็บชื่อและ IP Address ของเครื่องที่เกี่ยวข้องอย่างเป็นระบบลักษณะการทำงานจะเป็นแบบ Client/Server โดยที่ตัว Server จะเป็นตัวเก็บข้อมูลต่าง ๆ ที่เรียกว่าเป็น DNS Server (ที่มา : http://www.asiamediasoft.net/content/newboard/HowDNS) Dnsmasq เป็น DNS Server ชนิด forwarder+Caching แบบง่ายๆ ตัวเล็ก ประสิทธิภาพสูง (ถึงไม่เท่า Bind ก็เถอะ) และยังสามารถแจก DHCP ได้อีกด้วย ทุกอย่างที่ว่านี้มีอยู่ใน Clark Connect อยู่แล้วครับ ถ้าตอนติดตั้งไม่ลืมเลือกหัว DHCP and Caching DNS Servers มาด้วย จะเกิดอะไรขึ้นถ้า DNS Server หลักล้ม หรือไม่อัพเดทฐานข้อมูล หรืออัพเดทช้า หรือบางเว็บไซต์ที่นิยมๆถูกบล็อกจาก DNS บาง Server ลองนึกสภาพที่ไม่มี DNS Server อยู่ในร้านดูสิครับ จะเกิดอะไรขึ้น!!! เริ่มแรกกันเลย Copy สคิปที่อยู่ด้านล่างไปแทนที่อันเก่าที่ /etc/dnsmasq.conf # The “interface” parameter is set by the network policy (LAN/DMZ interfaces) bogus-priv # maybe make larger cache-size=512 # dhcp-authoritative dhcp-lease-max=1000 # block silly requests domain-needed filterwin2k # domain=system.lan expand-hosts # no-negcache strict-order user=nobody # Can make specific servers here and not use resolv.conf server=203.146.237.237 # csloxinfo 39 server=203.121.130.40 # Pacific 39.9 server=203.144.255.72 # asianet 40.9 server=202.69.137.137 # Triple T Global Net 41 server=202.44.144.33 # KSC 41.5 server=203.146.102.231 # truefaster 42.5 server=203.144.255.71 # asianet 42.8 server=202.129.27.134 # cattelecom 43.6 server=202.69.137.138 # Triple T Global Net 45 server=203.146.237.222 # csloxinfo 48.5 server=202.57.160.129 # Issp 48.9 server=202.6.100.1 # ABAC 50 server=203.121.130.39 # Pacific 51.5 server=203.155.33.1 # KSC 51.9 server=202.44.68.3 # Sripatum 52.7 server=203.144.207.49 # asianet (True) 54.5 server=203.144.207.29 # asianet (True) 58.1 server=202.57.128.71 # SGA 62 server=203.147.0.3 # Jasmine Internet 62.4 server=61.19.245.246 # cattelecom * server=61.19.254.134 # cattelecom * server=202.47.249.4 # cattelecom * server=203.148.255.70 # A-Net * server=203.148.255.78 # A-Net * server=203.149.0.2 # Samart * server=203.149.0.3 # Samart * server=203.146.222.3 # buddybb * server=203.158.144.1 # Rmutp * server=203.146.64.33 # Tnet * server=202.182.0.1 # FarEast * server=202.182.0.2 # FarEast * server=192.150.249.11 # Thammasat * server=208.67.222.222 # OpenDNS 277.8 server=208.67.220.220 # OpenDNS 285.1 # include another configuration conf-file=/etc/dnsmasq/dhcp.conf แก้ไข /etc/resolv.conf ตามสคิปด้านล่าง โค๊ด: nameserver 127.0.0.1 nameserver 192.168.1.1 สั่ง service dnsmasq restart ถ้าใครมีอะไีรเพิ่มเติมหรือชี้แนะ ก็เชิญได้เต็มที่เลยครับ เพราะผมก็ศึกษามาแบบงูๆปลาๆเหมือนกัน ส่วน list รายชื่อ dns server ที่ผมใส่มานั้น ผมได้ใช้เวลาหามาเกือบ 1 วันเต็ม จัดเรียงตามเร็ว (ping x+y+z/n) และคัดอันที่ใช้ไม่ได้หรือมีปัญหาิทิ้งแล้ว และทุกรายชื่อใช้ข้ามค่ายกันได้ครับ ใครมีรายชื่อเพิ่มเติมนอกจากนี้ก็โพทบอกได้เลยครับ (ควรเอา DNS ที่ตรง ISP ไปไว้แรกๆ) หรือถ้าใครอยากศึกษาคำสั่งเพิ่มเติม ก็ไปศึกษาได้ที่นี้เลยครับ http://www.thekelleys.org.uk/dnsmasq/docs/dnsmasq-man.html

วันพุธที่ 29 กุมภาพันธ์ พ.ศ. 2555

ข้อดีของการเช่าในระบบ Cloud Computing

เชื่อมต่อสาขาได้ทันที : เหมาะสำหรับธุรกิจที่มีสาขา และต้องการดูข้อมูลรวมทุกสาขา
Server แรง : SML ลงทุนเครื่อง Server ขนาดใหญ่ และหลายเครื่อง เพื่อให้งานของผู้ใช้ ทำงานรวดเร็ว ไม่สดุด แม้มีจำนวนผู้ใช้มาก
ใช้ได้ตลอดเวลา : ใช้งานได้ตลอด 24 ชม. แม้หน้าร้านปิดไปแล้ว ก็สามารถตรวจสอบข้อมูลที่บ้านได้
ลดการลงทุน : ท่านไม่ต้องซื้อ Server หลายหมื่นบาท และไม่ต้องจ้างพนักงานดูแลระบบ
ประหยัดค่าใช้จ่าย : ไม่ต้องเช่า Internet ความเร็วสูง หรือทำ Fixed IP สำหรับ Server ของท่าน เพราะ Cloud สามารถรองรับการใช้งานพร้อมกันได้ปริมาณมาก และที่สาขาสามารถใช้ Net อะไรก็ได้ เพื่อเข้าใช้ระบบ เช่น 3BB Hotsport ก็แค่เดือนละ 100 แค่นี้ก็เชื่อมสาขาได้ทุกที่
ปลอดภัย : เข้ารหัสถึงสองชั้น เพื่อป้องกันข้อมูลรั่วไหล
รวดเร็ว : ท่านสามารถขึ้นระบบได้ทันที และเชื่อมต่อสาขาได้ทันที
มั่นคง : มีระบบการสำรองข้อมูลให้ทุกเวลา โดยท่านสามารถ Backup ข้อมูลไปเก็บไว้ได้เอง

วันอาทิตย์ที่ 26 กุมภาพันธ์ พ.ศ. 2555

Percona XtraDB Cluster

Percona XtraDB Cluster

http://www.percona.com/doc/percona-xtradb-cluster/index.html#

Percona Data Recovery Tool for InnoDB

https://launchpad.net/percona-data-recovery-tool-for-innodb

innotop The best top clone for MySQL, with special attention paid to InnoDB

http://code.google.com/p/innotop/

innotop
The best top clone for MySQL, with special attention paid to InnoDB

[[Multi-Master Replication Manager for MySQL]]

[[Multi-Master Replication Manager for MySQL]]

http://mysql-mmm.org/

วันเสาร์ที่ 18 กุมภาพันธ์ พ.ศ. 2555

วันพุธที่ 30 พฤศจิกายน พ.ศ. 2554

Oracle 11g R2 64bits + Linux MINT 64bits

ค่อย ๆ ทำตามไปทีละบรรทัดนะ
$ cd
$ sudo aptitude install unzip build-essential x11-utils rpm ksh lsb-rpm libaio1
$ wget http://mirrors.kernel.org/ubuntu/pool/universe/g/gcc-3.3/libstdc++5_3.3....
$ dpkg-deb -x libstdc++5_3.3.6-17ubuntu1_amd64.deb ia64-libs
$ sudo cp ia64-libs/usr/lib/libstdc++.so.5.0.7 /usr/lib64/
$ cd /usr/lib64/
$ sudo ln -s libstdc++.so.5.0.7 libstdc++.so.5
$ cd
$ wget http://security.ubuntu.com/ubuntu/pool/universe/i/ia32-libs/ia32-libs_2....
$ dpkg-deb -x ia32-libs_2.7ubuntu6.1_amd64.deb ia32-libs
$ ls -l /usr |grep lib32
(ถ้าไม่ขึ้นอะไรมาให้ $sudo mkdir /usr/lib32)
$ sudo cp ia32-libs/usr/lib32/libstdc++.so.5.0.7 /usr/lib32/
$ cd /usr/lib32
$ sudo ln -s libstdc++.so.5.0.7 libstdc++.so.5
$ sudo su -
# addgroup oinstall
# addgroup dba
# useradd -g oinstall -G dba -p password -d /home/oracle -s /bin/bash oracle
# mkdir /home/oracle
# chown -R oracle:dba /home/oracle
# ln -s /usr/bin/awk /bin/awk
# ln -s /usr/bin/basename /bin/basename
# mkdir /etc/rc.d
# for i in 0 1 2 3 4 5 6 S ; do ln -s /etc/rc$i.d /etc/rc.d/rc$i.d ; done (ทำ debian ให้คล้าย redhat)
# mkdir -p /u01/app/oracle
# chown -R oracle:dba /u01
# passwd oracle
# echo "#">> /etc/sysctl.conf
# echo "# Oracle 11gR2 entries">> /etc/sysctl.conf
# echo "fs.aio-max-nr=1048576" >> /etc/sysctl.conf
# echo "fs.file-max=6815744" >> /etc/sysctl.conf
# echo "kernel.shmall=2097152" >> /etc/sysctl.conf
# echo "kernel.shmmni=4096" >> /etc/sysctl.conf
# echo "kernel.sem=250 32000 100 128" >> /etc/sysctl.conf
# echo "net.ipv4.ip_local_port_range=9000 65500" >> /etc/sysctl.conf
# echo "net.core.rmem_default=262144" >> /etc/sysctl.conf
# echo "net.core.rmem_max=4194304" >> /etc/sysctl.conf
# echo "net.core.wmem_default=262144" >> /etc/sysctl.conf
# echo "net.core.wmem_max=1048586" >> /etc/sysctl.conf
# echo "kernel.shmmax=2147483648" >> /etc/sysctl.conf
# echo "#Oracle 11gR2 shell limits:">>/etc/security/limits.conf
# echo "oracle soft nproc 2048">>/etc/security/limits.conf
# echo "oracle hard nproc 16384">>/etc/security/limits.conf
# echo "oracle soft nofile 1024">>/etc/security/limits.conf
# echo "oracle hard nofile 65536">>/etc/security/limits.conf
# sysctl -p
หลังจากนั้นให้ logout แล้ว login ด้วย user oracle
$ cp linux.x64_11gR2_database_* /tmp
$ cd /tmp
$ unzip linux.x64_11gR2_database_1of2.zip
$ unzip linux.x64_11gR2_database_2of2.zip
$ cd database
$ ./runInstaller
ตอนมันแสดงว่า Fail.... ให้ติ๊ก Ignore all (ถ้าติดตั้งใน redhat จะไม่เจอ)
ก่อนจะติดตั้งเสร็จ มันจะถามให้ run script ก็เปิด terminal ขึ้นมาอีกอันนึง
$ su - (user ที่ใช้งานปรกติ)
$ sudo su -
# /u01/app/oraInventory/orainstRoot.sh
# /u01/app/oracle/product/11.2.0/dbhome_1/root.sh
# nano /etc/oratab
orcl:/u01/app/oracle/product/11.2.0/dbhome_1:N <------ เปลี่ยน "N" เป็น "Y"
ทดสอบ
https://localhost:1158/em
เกือบละ... อีกนิด
ทำให้ oracle start อัตโนมัติเมื่อเปิดเครื่อง
# nano /etc/profile
------------- เพิ่มท้ายไฟล์ ------------------
export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1
export PATH=$PATH:/u01/app/oracle/product/11.2.0/dbhome_1/bin
export ORACLE_SID=orcl <---ถ้าตั้งไว้ชื่ออื่นก็เปลี่ยนด้วย
--------------------------------------------------
# nano /etc/init.d/oracledb
----------------- ก๊อปวางไปตามนี้ ------------------------------------
#!/bin/bash
#
# /etc/init.d/oracledb
#
# Run-level Startup script for the Oracle Listener and Instances
# It relies on the information on /etc/oratab
export ORACLE_BASE=/u01/app/oracle
export ORACLE_HOME=/u01/app/oracle/product/11.1.0/dbhome_1
export ORACLE_OWNR=oracle
export PATH=$PATH:$ORACLE_HOME/bin
export ORACLE_SID=orcl
if [ ! -f $ORACLE_HOME/bin/dbstart -o ! -d $ORACLE_HOME ]
then
echo "Oracle startup: cannot start"
exit 1
fi
case "$1" in
start)
# Oracle listener and instance startup
echo -n "Starting Oracle: "
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl start"
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbstart $ORACLE_HOME"
touch /var/lock/oracle
echo "OK"
;;
stop)
# Oracle listener and instance shutdown
echo -n "Shutdown Oracle: "
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/lsnrctl stop"
su $ORACLE_OWNR -c "$ORACLE_HOME/bin/dbshut $ORACLE_HOME"
rm -f /var/lock/oracle
echo "OK"
;;
reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: `basename $0` start|stop|restart|reload"
exit 1
esac
exit 0
--------------------------------------------------------------
# chmod a+x /etc/init.d/oracledb
# update-rc.d oracledb defaults 99
จบ
ปล. สามารถ start dbconsole (เข้า https://localhost:1158/em ได้) แบบ manual ได้โดย
$ su - oracle
$ emctl start dbconsole
ปิดโดย
$ emctl stop dbconsole
ที่มา
http://forums.oracle.com/forums/thread.jspa?threadID=1115155
http://www.pythian.com/news/13291/installing-oracle-11gr2-enterprise-edi...
http://www.pythian.com/news/968/installing-oracle-11g-on-ubuntu-804-lts-...
http://www.stefanocislaghi.eu/2009/12/28/unable-to-run-dbconsole-oc4j-co...

Linux HugeTLBfs: Improve MySQL Database Application Performance

http://www.cyberciti.biz/tips/linux-hugetlbfs-and-mysql-performance.html


Linux HugeTLBfs: Improve MySQL Database Application Performance

by VIVEK GITE on MAY 20, 2009 · 10 COMMENTS

Applications that perform a lot of memory accesses (several GBs) may obtain performance improvements by using large pages due to reduced Translation Lookaside Buffer (TLB) misses. HugeTLBfs is memory management feature offered in Linux kernel, which is valuable for applications that use a large virtual address space. It is especially useful for database applications such as MySQL, Oracle and others. Other server software that uses the prefork or similar (e.g. Apache web server) model will also benefit.


The CPU's Translation Lookaside Buffer (TLB) is a small cache used for storing virtual-to-physical mapping information. By using the TLB, a translation can be performed without referencing the in-memory page table entry that maps the virtual address. However, to keep translations as fast as possible, the TLB is usually small. It is not uncommon for large memory applications to exceed the mapping capacity of the TLB. Users can use the huge page support in Linux kernel by either using the mmap system call or standard SYSv shared memory system calls (shmget, shmat).

Only selected hardware and operating system support memory pages greater than the default 4KB. The following configuration tested on RHEL 5.3 64 bit using a stock kernel with tons of RAM and multiple CPUs.

How do I verify that my kernel supports hugepage?

Type the following command:
$ grep -i huge /proc/meminfo
Sample output:

HugePages_Total:     0 HugePages_Free:      0 HugePages_Rsvd:      0 Hugepagesize:     2048 kB

The kernel built with hugepage support should show the number of configured hugepages in the system. Otherwise, you need to be built Linux kernel with the CONFIG_HUGETLBFS option.

How do I configure HugeTLBfs?

The HugeTLBfs feature permits an application to use a much larger page size than normal, so that a single TLB entry can map a larger address space. A HugeTLB entry can vary in size. For example, i386 architecture supports 4K and 4M (2M in PAE mode) page sizes, ia64 architecture supports multiple page sizes 4K, 8K, 64K, 256K, 1M, 4M, 16M, 256M and ppc64 supports 4K and 16M. To allocate hugepage, you can define the number of hugepages by configuring value at /proc/sys/vm/nr_hugepages, enter:
# sysctl -w vm.nr_hugepages=40
Above command will try to configure 40 hugepages in the system. Now, run the following again:
# grep -i huge /proc/meminfo
Sample output:

HugePages_Total:    40 HugePages_Free:     40 HugePages_Rsvd:      0 Hugepagesize:     2048 kB

Where,

  • HugePages_Total: 40 - The size of the pool of hugepages. On busy server with 16/32GB RAM, you can set this to 512 or higher value.
  • HugePages_Free: 40 - The number of hugepages in the pool that are not yet allocated.
  • HugePages_Rsvd: 0 - The number of hugepages for which a commitment to allocate from the pool has been made, but no allocation has yet been made.
  • Hugepagesize: 2048 kB -

Configure MySQL to use HugeTLBfs

In MySQL, large pages can be used by InnoDB, to allocate memory for its buffer pool and additional memory pool. Find mysql user id:
# id mysql
Sample output:

uid=27(mysql) gid=27(mysql) groups=27(mysql)
Open /etc/sysctl.conf:
# vi /etc/sysctl.conf
Add the following configuration:

# Set the number of pages to be used. # Each page is normally 2MB, so a value of 40 = 80MB. # Set it 512 or higher if you have lots of memory vm.nr_hugepages=40 # Set the group number (mysql group number is 27) that is allowed to access this memory. The mysql user must be a member of this group. vm.hugetlb_shm_group=27 # Increase the amount of shmem allowed per segment # This depends upon your memory, remember your kernel.shmmax = 68719476736 # Increase total amount of shared memory. kernel.shmall = 4294967296

Save and close the file. Reload settings:
# systclt -p
Open /etc/my.cnf:
# vi /etc/my.cnf
Add large-pages options

[mysqld] large-pages datadir=/var/lib/mysql socket=/var/lib/mysql/mysql.sock user=mysql # rest of config...

Save and close the file. Open /etc/security/limits.conf, enter:
# vi /etc/security/limits.conf
Append the following line to set max locked-in-memory address space to unlimited:

@mysql      soft    memlock         unlimited @mysql      hard    memlock         unlimited

Save and close the file. Finally, restart the mysql server:
# /etc/init.d/mysqld restart

A note about mount command option

If your application uses huge pages through the mmap() system call, you have to mount a file system of type hugetlbfs like this:
# mount -t hugetlbfs none /myapp
Another example, with more control over uid, gid and other options:

# mount -t hugetlbfs -o uid={value},gid={value},mode={value},size={value},nr_inodes={value} none /myapp

Further readings:

  1. Please refer to kernel documentation in Documentation /vm/hugetlbpage.txt for more information. MySQL large memory support help page.
  2. man page - mount

วันพุธที่ 16 พฤศจิกายน พ.ศ. 2554

hosxp_getdataset_reportserver

var cds:tclientdataset;
begin
cds:=tclientdataset.create;
cds.data:=hosxp_getdataset_reportserver('select xxx from xxx');
cds.AssignDataToMainReport;
cds.free;

end;

วันอาทิตย์ที่ 25 กันยายน พ.ศ. 2554

install Percona 5.5 on Centos6

'm unable to install Percona 5.5 on Centos6 without using --nogpgcheck:

rpm -Uhv http://www.percona.com/downloads/percona-release/percona-rel ease-0.0-1.x86_64.rpm
yum install Percona-Server-client-55 Percona-Server-server-55
...lots of output...
Package Percona-Server-client-55-5.5.14-rel20.5.149.rhel6.x86_64.rpm is not signed

I have a /etc/yum.repos.d/Percona.repo file that looks correct and also have a /etc/pki/rpm-gpg-RPM-GPG-KEY-percona file.

If I force it in with --nogpgcheck it conflicts with mysql-libs which a bunch of core packages depend on so the installation ends up looking like this (on a clean machine with a fresh Centos 6 install):

yum remove mysql-libs
yum install --nogpgcheck Percona-Server-client-55 Percona-Server-server-55
yum install --nogpgcheck mysql-libs cronie cronie-anacron crontabs postfix sysstat webalizer

Is running Percona 5.5 on Centos 6 recommended at this time?