Archive for April, 2013

Use the old method to logrotate in centos 6

Friday, April 26th, 2013

The dateext option for logrotate.conf is enabled by default in centos6

[william.ho@mail10a log]$ ls /var/log
anaconda.ifcfg.log anaconda.xlog btmp-20130401 cron-20130414 ftp.log maillog messages ntpstats secure-20130331 spooler-20130331 wtmp
anaconda.log anaconda.yum.log clamav cron-20130421 httpd maillog-20130331 messages-20130331 openwebmail.log secure-20130407 spooler-20130407 xferlog
anaconda.program.log audit cron dmesg iptraf maillog-20130407 messages-20130407 sa secure-20130414 spooler-20130414 yum.log
anaconda.storage.log boot.log cron-20130331 dmesg.old lastlog maillog-20130414 messages-20130414 sa-update.log secure-20130421 spooler-20130421
anaconda.syslog btmp cron-20130407 dracut.log mail maillog-20130421 messages-20130421 secure spooler tallylog

To disabled it, edit /etc/logrotate.conf and comment the line “dateext”

Specify Exprire/Cache control headers for static content in apache httpd

Friday, April 19th, 2013

in /etc/httpd/conf/httpd.conf

Add

#A better header control on images/static content
Include conf/extra/httpd-expire.conf

Then create /etc/httpd/conf/extra/httpd-expire.conf

ExpiresActive on

# Perhaps better to whitelist expires rules? Perhaps.
ExpiresDefault “access plus 1 month”

# cache.appcache needs re-requests
# in FF 3.6 (thx Remy ~Introducing HTML5)
ExpiresByType text/cache-manifest “access plus 0 seconds”

# Your document html
ExpiresByType text/html “access plus 0 seconds”

# Data
ExpiresByType text/xml “access plus 0 seconds”
ExpiresByType application/xml “access plus 0 seconds”
ExpiresByType application/json “access plus 0 seconds”

# RSS feed
ExpiresByType application/rss+xml “access plus 1 hour”

# Favicon (cannot be renamed)
ExpiresByType image/x-icon “access plus 1 week”

# Media: images, video, audio
ExpiresByType image/gif “access plus 1 month”
ExpiresByType image/png “access plus 1 month”
ExpiresByType image/jpg “access plus 1 month”
ExpiresByType image/jpeg “access plus 1 month”
ExpiresByType video/ogg “access plus 1 month”
ExpiresByType audio/ogg “access plus 1 month”
ExpiresByType video/mp4 “access plus 1 month”
ExpiresByType video/webm “access plus 1 month”

# HTC files (css3pie)
ExpiresByType text/x-component “access plus 1 month”

# Webfonts
ExpiresByType font/truetype “access plus 1 month”
ExpiresByType font/opentype “access plus 1 month”
ExpiresByType application/x-font-woff “access plus 1 month”
ExpiresByType image/svg+xml “access plus 1 month”
ExpiresByType application/vnd.ms-fontobject “access plus 1 month”

# CSS and JavaScript
ExpiresByType text/css “access plus 1 year”
ExpiresByType application/javascript “access plus 1 year”
ExpiresByType text/javascript “access plus 1 year”
Header append Cache-Control “public”

Installing keepalived from source (For centos 5, rpmbuilder only provide centos 6 rpms)

Monday, April 8th, 2013

1: Get the source and extract

wget?http://www.keepalived.org/software/keepalived-1.2.7.tar.gz

tar xvfzp keepalived-1.2.7.tar.gz

2: Compile and install

cd keepalived-1.2.7
./configure
make
make install

3: init script

cp /usr/local/etc/rc.d/init.d/keepalived /etc/init.d/keepalived

vi /etc/init.d/keepalived

After line 19, add

PATH=$PATH:/usr/local/sbin

4: create directories and config file

mkdir -p /etc/keepalived
touch /etc/sysconfig/keepalived

vi /etc/keepalived/keepalived.conf

On master:

vrrp_script chk_ping {
script “ping -c 1 192.168.100.1”
interval 2 # check every 2 seconds
weight 2 # add 2 points of prio if OK
}

vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 100
priority 101
virtual_ipaddress {
192.168.100.52/24 dev eth0
}
track_script {
chk_ping
}

}

On slave

vrrp_script chk_ping {
script “ping -c 1 192.168.100.1”
interval 2 # check every 2 seconds
weight 2 # add 2 points of prio if OK
}

vrrp_instance VI_1 {
interface eth0
state MASTER
virtual_router_id 100
priority 100
virtual_ipaddress {
192.168.100.52/24 dev eth0
}
track_script {
chk_ping
}

}

5: Start service

chkconfig keepalived on

service keepalived start

?