Rabu, 21 Desember 2011

Edit blogspot/blogger template menjadi SEO Friendly

Mengubah Blogspot atau blogger menjadi SEO Friendly - Postingan kali ini membahas tentang Tips SEO (Search engine optimization). Postingan ini adalah kumpulan cara untuk men-SEO-kan template blogger / blogspot kita. Tutorial step by step mengedit template blogger / blogspot agar SEO Friendly ini adalah hanya salah satu cara untuk meningkatkan SERP. Lebih detail, berikut adalah langkah-langkah SEO Guide untuk blogger templates :

1. Page Title
Biasanya format page title dari blogger kan seperti ini : JUDUL BLOG : JUDUL POSTING, nah agar blog kita lebih disukai oleh google sehingga ujung-ujungnya blog kita jadi rame, kita harus merubah format page title standart itu menjadi seperti ini : JUDUL POSTING | JUDUL BLOG. Caranya cari kode berikut :
<title><data:blog.pageTitle/></title>

Ganti dengan kode berikut ini :
<b:if cond='data:blog.pageType == "item"'>
<title><data:blog.pageName/> | <data:blog.title/></title>
<b:else/>
<title><data:blog.pageTitle/></title>
</b:if>

Atau bisa tambahin beberapa kata kunci ( keyword ) :
<b:if cond='data:blog.pageType == "item"'>
<title><data:blog.pageName/> | <data:blog.title/></title>
<b:else/>
<title><data:blog.pageTitle/> | Kata kunci sobat | Kata kunci sobat </title>
</b:if>


2. Meta keyword dan deskripsi
Mesin pencari seperti google sangat menyukai sebuah website / blog yang jelas tema dan isi content-nya. Oleh karena itu harus menambahkan suatu tag yang namanya meta tag. Caranya adalah dengan menambahkan kode berikut ini sebelum kode <b:skin><![CDATA[/*.
<b:if cond='data:blog.url == data:blog.homepageUrl'>
<meta name="description" content="Deskripsi Blog anda" />
<meta name="keywords" content="Kata kunci , kata kunci, kata kunci, kata kunci , kata kunci" />
</b:if>

3. memasang Breadcrumbs.
Breadcrumbs adalah menu navigasi yang ada diatas sebuah posting atau artikel. Cara pasangnya juga sudah banyak dibahas di blog-blog guru blogging. Silahkan sobat cari di google dengan kata kunci “ cara membuat menu breadcrumbs”.


4. memasang Related Post.
Related post sangat bagus untuk SEO maupun buat pengunjung. Caranya sudah banyak dibahas di blog-blog para guru blogging. Silahkan sobat cari di google dengan kata kunci “ cara membuat related post di blogger”.


5. Disable setting archive
Google tidak suka dengan duplicate content. Jadi ketika kita mengaktifkan opsi arsip, misalnya kejadiannya seperti ini :
Sebuah blog di blogger.com. dimuat 3 posting. Maka di halaman utama atau homepage akan ada 3 posting dan sebuah link arsip. Halaman arsip tersebut akan memunculkan 3 posting yang sama dengan yang di munculkan oleh homepage. Bagi search engine seperti google ini adalah masalah serius. Oleh karena itu kita sebaiknya me-non-aktifkan opsi arsip, caranya : setelah login klik tab setting >> Archiving >> pada bagian Archiving frequency ubah menjadi no archive. >> selesai simpan setting.
Atau jika tidak ingin menonaktifkan fungsi arsip, silahkan letakkan kode berikut dibawah kode :
<b:if cond='data:blog.pageType == &quot;archive&quot;'><meta content='noindex' name='robots'/></b:if>

6. Menambahkan kode ‘rel=canonical’
Gunanya kita menambahkan ‘rel=canonical’ adalah untuk menghindari konten ganda, karena seperti para master of SEO bilang bahwa google sangat tidak dapat mentolerir sebuah duplicate content. Cara nya di edit html tambahkan kode berikut setelah kode <head>
<link expr:href='data:blog.url' rel='canonical' />

Save template dan selesai 

Jumat, 03 April 2009

Replikasi Database dengan MySQL

Dengan menggunakan Fitur Replikasi di MySQL dapat membuat duplikasi database master ke slave secara realtime. Database slave ini juga nantinya dapat digunakan sebagai standby server untuk master jika DB master shutdown (in case: terjadi error di master) dengan melakukan perubahan pada aplikasi supaya merujuk ke DB slave.

Dalam membuat replikasi DB Server ini dapat menggunakan operating system Linux maupun Windows.

Langkah-langkahnya adalah sebagai berikut:

1. Master MySQL Database

Lakukan perubahan pada file konfigurasi mysql yang ada di Server Master. Biasanya nama file : mysql.cnf atau my.cnf yang terletak di /etc/mysql (Sesuai dengan Distro yang digunakan).

Lakukan perubahan atau penambahan seperti baris dibawah ini:

server-id = 1

log_bin = /var/log/mysql/mysql-bin.log

binlog-do-db=database_name_1
binlog-do-db=database_name_2
binlog-do-db=database_name_3

Lalu restart mysql service: /etc/init.d/mysql restart

Kemudian login ke console mysql:

#mysql –u root –p

#enter password:

Pada shell mysql

Mysql> GRANT REPLICATION SLAVE ON *.* TO ’slave_user’@'%' IDENTIFIED BY 'slave2';

Mysql> FLUSH PRIVILEGES;

Mysql> USE nama_db;
Mysql> FLUSH TABLES WITH READ LOCK;

Mysql> SHOW MASTER STATUS;

Hasilnya:

—————+———-+————–+——————+

| File | Position | Binlog_do_db | Binlog_ignore_db |

+—————+———-+————–+——————+

| mysql-bin.000001 | 98 | nama_db | |

+—————+———-+————–+——————+

1 row in set (0.00 sec)

Hasil diatas yang nantinya digunakan untuk konfigurasi DB slave

2. Lakukan snapshot Database master dan di copy ke Slave server. Hal ini dilakukan supaya DB Master dan Slave memiliki struktur dan data yang sama

Snapshot dapat dilakukan dengan menggunakan utility Mysqldump atau dengan menggunakan snapshot data raw files.

mysqldump -u root -p –opt nama_db > nama_db.sql

atau

shell> tar cf /tmp/db.tar ./data
shell> zip -r /tmp/db.zip ./data
shell> rsync --recursive ./data /tmp/dbdata

3. Slave MySQl database

Pada slave buat database dengan nama yang sama nama_db yang datanya bisa diambil dari hasil snapshot yang dilakukan di step 2.

Dengan asumsi DB slave sudah sama dengan Master, lakukan perubahan pada konfigurasi mysql slave /etc/mysql/my.cnf sperti pada baris dibawah ini:

server-id=2

master-host=ip-master

master-user=slave-user

master-password=password-slave

master-connect-retry=60

replicate-do-db=database_name_1
replicate-do-db=database_name_2
replicate-do-db=database_name_3

kemudian restart MySQL:

/etc/init.d/mysql restart

4. penyesuaian data pada slave jika terjadi update pada master pada saat konfigurasi

mysql -u root -p
Enter password:
mysql> SLAVE STOP;

mysql>CHANGE MASTER TO MASTER_HOST=’ip-master′, mysql> MASTER_USER=’slave_user’, MASTER_PASSWORD=’‘, mysql> MASTER_LOG_FILE=’mysql-bin.0000001′, MASTER_LOG_POS=183;

KETERANGAN :

  • MASTER_HOST is the IP address or hostname of the master (in this example it is 192.168.0.100).
  • MASTER_USER is the user we granted replication privileges on the master.
  • MASTER_PASSWORD is the password of MASTER_USER on the master.
  • MASTER_LOG_FILE is the file MySQL gave back when you ran SHOW MASTER STATUS; on the master.
  • MASTER_LOG_POS is the position MySQL gave back when you ran SHOW MASTER STATUS; on the master.

Mysql> START SLAVE;

Mysql> SHOW SLAVE STATUS\G;

*************************** 1. row ***************************

Slave_IO_State: Waiting for master to send event

Master_Host: 10.X.X.X

Master_User: slave_user

Master_Port: 3306

Connect_Retry: 60

Master_Log_File: MASTERMYSQL01-bin.000009

Read_Master_Log_Pos: 4

Relay_Log_File: MASTERMYSQL02-relay-bin.000015

Relay_Log_Pos: 3630
Relay_Master_Log_File: MASTERMYSQL01-bin.000002
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
Replicate_Do_DB: nama_db
Replicate_Ignore_DB:
Replicate_Do_Table:
Replicate_Ignore_Table:
Replicate_Wild_Do_Table:
Replicate_Wild_Ignore_Table:
Last_Errno: 0
Last_Error:
Skip_Counter: 0
Exec_Master_Log_Pos: 4
Relay_Log_Space: 3630
Until_Condition: None
Until_Log_File:
Until_Log_Pos: 0
Master_SSL_Allowed: No
Master_SSL_CA_File:
Master_SSL_CA_Path:
Master_SSL_Cert:
Master_SSL_Cipher:
Master_SSL_Key:
Seconds_Behind_Master: 1519187

Untuk melihat jalan tidaknya proses replikasi Parameter Slave_IO_Running and Slave_SQL_Running: harus YES.

Creating a MySQL Data Snapshot Using Raw Data Files

To get the most consistent results with a raw data snapshot you should shut down the server during the process, as below:

  1. Acquire a read lock and get the master's status.

  2. In a separate session, shut down the MySQL server:

    shell> mysqladmin shutdown
  3. Make a copy of the MySQL data files. Examples are shown below for common ways to do this - you need to choose only one of them:

    shell> tar cf /tmp/db.tar ./data
    shell> zip -r /tmp/db.zip ./data
    shell> rsync --recursive ./data /tmp/dbdata
  4. Start up the MySQL instance on the master.

If you are not using InnoDB tables, you can get a snapshot of the system from a master without shutting down the server as described in the following steps:

  1. Acquire a read lock and get the master's status.

  2. Take a copy of the MySQL data files. Examples are shown below for common solutions - you need to choose only one of these solutions:

    shell> tar cf /tmp/db.tar ./data
    shell> zip -r /tmp/db.zip ./data
    shell> rsync --recursive ./data /tmp/dbdata
  3. In the client where you acquired the read lock, free the lock:

    mysql> UNLOCK TABLES;

Once you have created the archive or copy of the database, you will need to copy the files to each slave before starting the slave replication process.

Minggu, 20 April 2008

Crontab - Quick reference

Crontab - Quick reference

Setting up cronjobs in Unix and Solaris

cron is a unix, solaris utility that allows tasks to be automatically run in the background at regular intervals by the cron daemon. These tasks are often termed as cron jobs in unix , solaris.
Crontab (CRON TABle) is a file which contains the schedule of cron entries to be run and at specified times.

Following points sum up the crontab functionality :

1. Crontab Restrictions
2.
Crontab Commands
3.
Crontab file - syntax
4.
Crontab Example
5.
Crontab Environment
6.
Disable Email
7
. Generate log file for crontab activity
8. Next Steps

1. Crontab Restrictions
____________
You can execute crontab if your name appears in the file /usr/lib/cron/cron.allow. If that file does not exist, you can use
crontab if your name does not appear in the file /usr/lib/cron/cron.deny.
If only cron.deny exists and is empty, all users can use crontab. If neither file exists, only the root user can use crontab. The allow/deny files consist of one user name per line.
2. Crontab Commands
__________
export EDITOR=vi ;to specify a editor to open crontab file.

crontab -e Edit your crontab file, or create one if it doesn't already exist.
crontab -l Display your crontab file.
crontab -r Remove your crontab file.
crontab -v Display the last time you edited your crontab file. (This option is only available on a few systems.)

3. Crontab file
___________
Crontab syntax :-
A crontab file has five fields for specifying day , date and time followed by the command to be run at that interval.

* * * * * command to be executed
- - - - -
| | | | |
| | | | +----- day of week (0 - 6) (Sunday=0)
| | | +------- month (1 - 12)
| | +--------- day of month (1 - 31)
| +----------- hour (0 - 23)
+------------- min (0 - 59)

* in the value field above means all legal values as in braces for that column.
The value column can have a * or a list of elements separated by commas. An element is either a number in the ranges shown above or two numbers in the range separated by a hyphen (meaning an inclusive range).

Note: The specification of days can be made in two fields: month day and weekday. If both are specified in an entry, they are cumulative meaning both of the entries will get executed .

4. Crontab Example
_______

A line in crontab file like below removes the tmp files from /home/someuser/tmp each day at 6:30 PM.

30 18 * * * rm /home/someuser/tmp/*

Changing the parameter values as below will cause this command to run at different time schedule below :

min hour day/month month day/week Execution time
30 0 1 1,6,12 * -- 00:30 Hrs on 1st of Jan, June & Dec.

:

0 20 * 10 1-5 --8.00 PM every weekday (Mon-Fri) only in Oct.

:

0 0 1,10,15 * * -- midnight on 1st ,10th & 15th of month

:

5,10 0 10 * 1 -- At 12.05,12.10 every Monday & on 10th of every month
:

Note : If you inadvertently enter the crontab command with no argument(s), do not attempt to get out with Control-d. This removes all entries in your crontab file. Instead, exit with Control-c.

5. Crontab Environment
___________
cron invokes the command from the user's HOME directory with the shell, (/usr/bin/sh).
cron supplies a default environment for every shell, defining:
HOME=user's-home-directory
LOGNAME=user's-login-id
PATH=/usr/bin:/usr/sbin:.
SHELL=/usr/bin/sh

Users who desire to have their .profile executed must explicitly do so in the crontab entry or in a script called by the entry.

6. Disable Email
____________

By default cron jobs sends a email to the user account executing the cronjob. If this is not needed put the following command At the end of the cron job line .

>/dev/null 2>&1


7. Generate log file
________________

To collect the cron execution execution log in a file :

30 18 * * * rm /home/someuser/tmp/* > /home/someuser/cronlogs/clean_tmp_dir.log

8. Next Steps

This article covered a significant aspect of system administration of setting up cronjobs . Unix administration involves lots of different tasks and some of these tasks are covered in this website but still there are many areas not covered here .

Rabu, 16 April 2008

Backup your MySQL databases automatically with AutoMySQLBackup

If you site relies on MySQL and stores its sensitive data in a MySQL database, you will most definitely want to backup that information so that it can be restored in case of any disaster (manual mistake to delete some data, software errors, hardware errors, server compromise, etc.).

With mysqldump anyone can write a small shell script and running it from cron, it will achieve an automatic backup solution. There are many such scripts already available freely and also many commercial solutions also (I assume as I have not tested any really ;)). The script that I liked the most is AutoMySQLBackup, because it doesn’t have any real requirements (mysqldump of course is needed - in any mysql client package - and gzip or bzip2 to compress the resulting file) and has all the features I was looking for in such a script.

AutoMySQLBackup has all the features I needed: it can backup a single database, multiple databases, or all the databases on the server; each database is saved in a separate file that can be compressed (with gzip or bzip2); it will rotate the backups and not keep them filling your hard drive (as normal in the daily backup you will have only the last 7 days of backups, the weekly if enabled will have one for each week, etc.). It has also some other features (check the project homepage for full details), that I am not using myself (like email logs for example), but other peoples might find interesting.

The installation is very simple: just download the one file bash script and save it somewhere, customize it to fit your setup (only some basic changes are needed: like the MySQL user and password, backup location), make it executable and activate it in cron as needed (daily for example).

Here are the variables that I usually setup:

# Username to access the MySQL server e.g. dbuser
USERNAME=dbuser
# Username to access the MySQL server e.g. password
PASSWORD=password
# Host name (or IP address) of MySQL server e.g localhost
DBHOST=localhost
# List of DBNAMES for Daily/Weekly Backup e.g. "DB1 DB2 DB3"
DBNAMES="all"
# Backup directory location e.g /backups
BACKUPDIR="/var/backup/mysql"
# Mail setup
MAILCONTENT="quiet"

You can also run the script manually:

./automysqlbackup.sh.2.5

but probably you will want to enable it in cron and run daily. You can just dump it in the /etc/cron.daily/ folder and you should be done. :).
Myself I like to place it in /opt and create a symlink to the file (to help with future updates of the script):

ln -s automysqlbackup.sh.2.5 automysqlbackup.sh

and run it from cron by placing in /etc/crontab something like:

#MySQL Daily backup
45 5 * * * root /opt/automysqlbackup.sh >/dev/null 2>&1

If needed, after the script is finished, you can save the backup folder where you placed the databases to a remote location (ftp, nfs, smb, or whatever) or another local medium (like tape for ex.). Saving to remote locations is not supported in the script itself so you will have to either mount the remote space locally (if it is possible… for nfs, smb, for ex.) and save directly onto it, or you will have to use another method to upload the files remotely (maybe you just have to include the backup folder used above in your regular backup script).

Are you using a different scrip to backup your databases? I would like to hear of it… Why did you like it? What features were you looking for? Or you had to write your own script because you have not found your needed features in any existing script available freely? Let me know…