Yearly Archives: 2012

Seri Belajar Open Source Cara Copas (BOSCA) : Install MySQL Server (tanpa root)

Panduan ini akan memungkinkan Anda untuk memasang MySQL Server tanpa memerlukan user root. Ini berarti bahwa Anda jadi bisa untuk memasang bahkan banyak MySQL Cluster di satu komputer. Ini akan sangat berguna misalnya untuk melakukan riset / ujicoba.

Memasang banyak MySQL Server di satu komputer juga berguna untuk meningkatkan concurrent throughput – pada jumlah koneksi / user yang banyak, kadang MySQL Server nya sendiri yang menjadi bottleneck.
Memasang banyak MySQL Server di komputer tersebut, dengan masing-masing listening di Port yang berbeda, bisa menjadi salah satu alternatif solusinya.

Seri BOSCA = Belajar Open Source Cara copAs (copy-paste) :: artikel ini saya tuliskan sedemikian rupa, sehingga Anda tinggal copas / copy-paste saja ke Terminal / Console.
Sehingga hasilnya langsung bisa dinikmati.

Saya percaya bahwa learning by doing adalah cara belajar yang terbaik. Pengetahuan & pemahaman akan otomatis didapatkan dengan langsung praktek / melakukan.
Seri artikel BOSCA bertujuan untuk membantu Anda agar dapat segera mulai melakukan praktek, dengan usaha yang seminimal mungkin.

Selamat menikmati :

### perlu install library AIO (Asynchronous I/O) di beberapa distro
sudo apt-get install libaio1

mkdir $HOME/mysql-cluster
mkdir $HOME/mysql-cluster/server1
cd  $HOME/mysql-cluster/server1

### Download dari http://www.mysql.com/downloads/mysql/
### Pilih "Linux - Generic 2.6 (x86, 64-bit), Compressed TAR Archive"
wget -c --timeout=10 --tries=0 http://ftp.ntu.edu.tw/pub2/MySQL/Downloads/MySQL-5.5/mysql-5.5.22-linux2.6-x86_64.tar.gz

tar xzvf mysql-5.5.22-linux2.6-x86_64.tar.gz
ln -s mysql-5.5.22-linux2.6-x86_64 mysql

### buat beberapa direktori untuk file PID, socket, dan log
mkdir $HOME/mysql-cluster/server1/mysql/etc
mkdir $HOME/mysql-cluster/server1/mysql/var
mkdir $HOME/mysql-cluster/server1/mysql/var/log
mkdir $HOME/mysql-cluster/server1/mysql/var/run
chown -R $USER:$USER $HOME/mysql-cluster/server1/mysql/var
chown -R $USER:$USER $HOME/mysql-cluster/server1/mysql/etc

################# menyiapkan file konfigurasi
cp $HOME/mysql-cluster/server1/mysql/support-files/config.medium.ini $HOME/mysql-cluster/server1/mysql/etc/my.cnf

################ inisialisasi database
cd $HOME/mysql-cluster/server1/mysql
$HOME/mysql-cluster/server1/mysql/scripts/mysql_install_db --user=$USER --defaults-file=$HOME/mysql-cluster/server1/mysql/etc/my.cnf --basedir=$HOME/mysql-cluster/server1/mysql/  --datadir=$HOME/mysql-cluster/server1/mysql/data/

###### start database
$HOME/mysql-cluster/server1/mysql/bin/mysqld_safe --defaults-file=$HOME/mysql-cluster/server1/mysql/etc/my.cnf  --user=$USER  --basedir=$HOME/mysql-cluster/server1/mysql/  --datadir=$HOME/mysql-cluster/server1/mysql/data/  --socket=$HOME/mysql-cluster/server1/mysql/var/run/mysql.sock --pid-file=$HOME/mysql-cluster/server1/mysql/var/run/mysql.pid --port=9001 &

##### akses database
$HOME/mysql-cluster/server1/mysql/bin/mysql -u root -h 127.0.0.1 -P 9001 

##### shutdown database
$HOME/mysql-cluster/server1/mysql/bin/mysqladmin -u root -h 127.0.0.1 -P 9001 shutdown

### buat script startup
echo '#!/bin/bash' >> $HOME/mysql-cluster/server1/startup-server1.sh
echo "$HOME/mysql-cluster/server1/mysql/bin/mysqld_safe --defaults-file=$HOME/mysql-cluster/server1/mysql/etc/my.cnf  --user=$USER  --basedir=$HOME/mysql-cluster/server1/mysql/  --datadir=$HOME/mysql-cluster/server1/mysql/data/  --socket=$HOME/mysql-cluster/server1/mysql/var/run/mysql.sock --pid-file=$HOME/mysql-cluster/server1/mysql/var/run/mysql.pid --port=9001 &" >> $HOME/mysql-cluster/server1/startup-server1.sh
chmod 755 $HOME/mysql-cluster/server1/startup-server1.sh


### buat script shutdown
echo '#!/bin/bash' >> $HOME/mysql-cluster/server1/shutdown-server1.sh
echo "$HOME/mysql-cluster/server1/mysql/bin/mysqladmin -u root -h 127.0.0.1 -P 9001 shutdown"  >> $HOME/mysql-cluster/server1/shutdown-server1.sh
chmod 755  $HOME/mysql-cluster/server1/shutdown-server1.sh


### untuk startup / shutdown MySQL Cluster, cukup ketik :
$HOME/mysql-cluster/server1/startup-server1.sh
$HOME/mysql-cluster/server1/shutdown-server1.sh


### Enjoy !

Father’s Prayer For His Children

Children are Creature of Light.
Born pure & innocent.
Bringer of joy.

As they grow however, darkness start to weigh upon them.
They began to know pain, hate, and lies.

I realize that just our love for them is not enough to protect them.
Lord Almighty, please grant us patience & knowledge, to teach & guide them.

Please give them strength to soar above the darkness
To not be engulfed by it.

Amen.

Archive-Backup Your Website

This is the #2 article in the backup topics, check out the first one : MySQL Archived Backup

Nowadays, nearly everyone / every company have a website of sorts. What most of us forgot is to back them up, in case of problems.
And as Murphy’s Law stated :

If it can go wrong, it will go wrong – in the worst possible time

Backup of your data can save you from such occasion.

An archived-backup can help you further – should you need to retrieve certain version of your data, then you can. Because it saves multiple copies of your data, each from certain point of time.

A way to do this is by using tools like the excellent rdiff-backup. In short – it’s like Apple’s Time Machine, but can be easily scripted & automated.

For other cases, you may need to create your own script for it.

Below is a script we use to backup our customer’s website.
It will backup both their MySQL database and the actual website itself.

Note that the backup script will archive for 2 weeks.
If you need diffent archive period, please feel free to modify the script, following the example in this article.

Here’s the script : backup-website.sh



#!/bin/bash

### Please change the variables below to suit you
sourcedir="/home/myuser/web"
targetdir="/home/myuser/mybackup"
targetfile="myname"
datestr="`date +%A`"
# 2 months archive
#datestr="`date +%d`"

tempdir="/tmp/$targetfile-$datestr"

dbuser="root"
dbpass="mypass"
database="mydb"

#################################
bmkdir="/bin/mkdir"
btar="/bin/tar"
bbzip2="/bin/bzip2"
bcp="/bin/cp"
bmysqldump="/usr/bin/mysqldump"

################################## start backup now

### create temporary space
$bmkdir $tempdir

### backup database
$bmysqldump -u $dbuser --password=$dbpass $database > $tempdir/$targetfile-$datestr.mysql
$bbzip2 $tempdir/$targetfile-$datestr.mysql

### backup website
$btar cvzf $tempdir/$targetfile-web-$datestr.tar.gz $sourcedir

### 2 weeks archive
$bcp $targetdir/$targetfile-$datestr.tar $targetdir/$targetfile-last-$datestr.tar

### backup website + mysql database
$btar cvf $targetdir/$targetfile-$datestr.tar $tempdir/*


Enjoy 🙂

MySQL Archived Backup

I regard backup as a very important matter. Because one of the certainties in life is this :

Computer WILL Fail

However, with so many computers in our care, we need a way to make it automatic. Otherwise, it will simply take too much time.

Thankfully, this is very easy to do in UNIX / Linux computers.

We have several kind of backup scripts. All of them are quite simple, but essential. Nobody should be without them.

Below you can find a backup script we use to backup MySQL database for our clients. Basically, this is how we use it :

  1. Modify the script to archive for the time range that we’d like.
    The script can archive the backup from 1 week to unlimited. Just remark out the time range that you don’t need (by putting the “#” character in the first column of the particular row).
  2. Make sure we can run mysqldump automatically / with no user intervention.
    This can be done easily by creating a file name ~/.my.cnf
  3. Setup the backup to run automatically via cron
  4. Routinely backup the backup to other servers.
    Yes, there is no such thing as “too much backup”.

Without further ado, here is the script : backup-archive-mysql.sh


#!/bin/bash

### Please change the variables below to suit you
targetdir="/home/myuser/mybackup"
targetfile="db-mydb"
targetsuffix=".mysql"

userdb="root"
database="mydb"

#################################
bcp="/bin/cp"
bmysqldump="/usr/bin/mysqldump"

################################## start backup now
### Archive : 1 week
$bmysqldump -u $userdb $database > $targetdir/$targetfile-`date +%A`$targetsuffix

### Archive : 2 weeks
$bcp $targetdir/$targetfile-`date +%A`$targetsuffix $targetdir/$targetfile-last-`date +%A`$targetsuffix
$bmysqldump -u $userdb $database > $targetdir/$targetfile-`date +%A`$targetsuffix

### Archive : 1 month
$bmysqldump -u $userdb $database > $targetdir/$targetfile-`date +%d`$targetsuffix

### Archive : 2 months
$bcp $targetdir/$targetfile-`date +%d`$targetsuffix $targetdir/$targetfile-last-`date +%d`$targetsuffix
$bmysqldump -u $userdb $database > $targetdir/$targetfile-`date +%d`$targetsuffix

### Archive : 1 year
$bmysqldump -u $userdb $database > $targetdir/$targetfile-`date +%m%d`$targetsuffix

### Archive : 2 years
$bcp $targetdir/$targetfile-`date +%m%d`$targetsuffix $targetdir/$targetfile-last-`date +%m%d`$targetsuffix
$bmysqldump -u $userdb $database > $targetdir/$targetfile-`date +%m%d`.mysql

### No Archive
### WARNING: always monitor your free disk space, or the following line may consume them all
$bmysqldump -u $userdb $database > $targetdir/$targetfile-`date +%Y%m%d`$targetsuffix

Here is a sample of ~/.my.cnf; if this file exist, then various MySQL tools & software will be able to run with no intervention.
Of course you’ll need to adjust its user & password :


[client]
user=root
password=mypassword

Hope you’ll find this useful.
I’ll post our other scripts here from time to time as well. Stay tuned.

Korban Murphy's Law

Beberapa waktu yang lalu, saya membuatkan infrastruktur IT untuk sebuah client yang serba redundant & resilient. Semua server ada hot-standby nya. Database server ada replikanya. Redundant UPS & AC. Lalu, untuk ISP nya, saya pilih yang multiple backbone. Sehingga, kalau salah satu backbone nya down, traffic masih bisa lancar via 2 backbone lainnya. Cukup? Ternyata, ada yang terlewat oleh saya….

3 backbone ISP tersebut semuanya melalui 1 (satu) Master Router.
Bisa tebak apa yang terjadi kemudian ? :-/

Yup, seperti yang telah dinyatakan pada Murphy's Law :
"Whatever can go wrong will go wrong, and at the worst possible time, in the worst possible way"

Master Router tersebut tewas – pada saat peak hours :<

Terjadilah kehebohan yang luar biasa, karena infrastrukturnya down pada saat sedang sibuk-sibuknya digunakan = semua orang tahu, dan semua orang jadi korbannya. Akhirnya saya sendiri juga ikut begadang sampai hampir pagi untuk mengawasi semua proses recovery jaringannya.

Lessons learned; Ada yang tahu ISP yang infrastrukturnya benar-benar redundant juga? Supaya jangan menjadi SPOF (single point of failure) dari infrastruktur kami ini.

Terimakasih.

Post imported by Google+Blog for WordPress.

Google is actually able to kill BlackBerry by using its Google Talk as BBM-killer. …

Google is actually able to kill BlackBerry by using its Google Talk as BBM-killer.
Google Talk is already available too on BlackBerry & iPhone, and of course on Android & PC.
Much better than BBM (BlackBerry Messenger) which is only available on BlackBerry.

There are only a few missing features left, like sharing photos in Group Chat, etc. These are simple features for Google to create, and looks like nothing – but, definitely is VERY important to users, and somehow still not provided by Google.
The mind boggles…

My family have asked me repeatedly to join in their BBM groups. But I really do NOT feel like buying such underpowered & troublesome device.

Here's hoping that Google will wisen up – and finally rule the mobile consumer market with its Google Talk.

Post imported by Google+Blog for WordPress.