CLI to display all DNS records

May 12th, 2013

dig -t AXFR domain_name @authorative_name_server

Use the old method to logrotate in centos 6

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

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)

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

?

Mysql binary logs taking up too much space

March 12th, 2013

A little housekeeping is required to reclaim the space

Navigate to /var/lib/mysql and see how far the logs goes to

Then run

mysql -u root -p ‘MyPassword’ -e “PURGE BINARY LOGS TO ‘mysql-bin.0000x’;” to purge the logs

Turn on Screen Sharing via SSH Terminal Command Line

February 25th, 2013

To Turn on Screen Sharing

/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -activate -configure -access -on -clientopts -setvnclegacy -vnclegacy yes -clientopts -setvncpw -vncpw mypasswd -restart -agent -privs -all

To Turn off Screen Sharing
/System/Library/CoreServices/RemoteManagement/ARDAgent.app/Contents/Resources/kickstart -deactivate -configure -access -off

Combining REMOTE_ADDR and X-Forwarded-For in apache access_log

January 12th, 2013

A great and simple solution to combine the reverse proxy log into access_log

SetEnvIf REMOTE_ADDR “(.+)” CLIENTIP=$1
SetEnvIf X-Forwarded-For “^([0-9.]+)” CLIENTIP=$1
LogFormat “%{CLIENTIP}e %D %u %t \”%r\” %>s %O \”%{Referer}i\” \”%{User-Agent}i\”” trueip_combined

For details: http://blog.grahampoulter.com/2011/10/how-to-log-client-ip-from-apache-behind.html

Mac Mini 2013 model Power Consumption Impact Analysis

January 4th, 2013

Date of Report: 2013/1/3

Power Consumption: ~0.5 Amp

Mac Mini Specification:

Model: Late 2012
– 2.3GHz Quad-Core Intel Core i7
– 16G RAM
– 256G SSD

 

Mac Mini Power Consumption Before Adding to datacenter: 5.85 Amp

Mac Mini Power Consumption After Adding to datacenter: 5.9 Amp

 

ghettoVCB.sh modification required for ESX 5.1

November 29th, 2012

vm backup script will fail with “You’re not running ESX(i) 3.5, 4.x, 5.x!”

Fix: change ghettoVCB.sh

231c231
< if [[ “${ESX_VERSION}” == “5.0.0” ]]; then

> if [[ “${ESX_VERSION}” == “5.0.0” ]] || [[ “${ESX_VERSION}” == “5.1.0” ]]; then

Google Apps Sign up

November 12th, 2012

http://www.google.com/enterprise/apps/business/pricing.html

Remarks:
Start from 12/6/2012, the Google Apps Free version is no longer available.