Wednesday, November 30, 2011

Extracting and tar.bz2 on Linux

To extract a tar.bz2 file, use this command:
tar -jxvf filename.tar.bz2
where j means  it's for bzip2, xz, lzip and lzma compress extension.

To extract a tar.gz file, the command is:
tar -zxvf filename.tar.gz
where z means it's for gzip, gunzip and ungzip compression extension
x is extract files from filename.tar.gz
v is to list all the file proccessed
f is to extract filename.tar.gz

if you want to specify the directory to where the extracted file go, use this command:
tar -xvzf file.tar.gz -C directory
where C means  put extracted file to directory

Friday, November 18, 2011

How to know MySQL activities: MysqlBinLog

Mysql has this new (maybe it's old) logging system called binary log (also called logbin). This consists of files containing events that describe  modifications to database contents. This file is saved in binary format by the server and the only way to read this binary file in human form is through mysqlbinlog utility. (By the way, this binary log is used by slave to replicated master's schema, so this is really a power file).

To execute mysqlbinlog in your terminal:
mysqbinlog [options] logfile
mysqlbinlog /var/lib/mysql/localhost-bin.000005 
This command will then display the content of the binary file localhost-bin.000005. The content of this file is:

# at 430
#111110 21:55:34 server id 1  end_log_pos 537 Query thread_id=2 exec_time=0 error_code=0
SET TIMESTAMP=1320933334/*!*/;
update Company set name='hello' where id = 1
This 1st line which is "# at 430" means that the starting position of the event in the binary log file is 430. On the second line, the number's with colon is the timestamp of the event (this is when the event happen). The "server id 1" state that the event happen on server id number 1. "end_log_pos 537" indicates that the next event starts at 537. "thread_id=2" says that the thread that execute the event is id 2. "exec_time=0" means the time spent to execute the event. Lastly, the last line is the event executed by the server. As you can is it is an update.

For your server to log event as a binary file, you must first enable it. To enable, you must edit the my.cnf and append log-bin=path.

The normal formal of binary file logs is host_name-bin.###### and store in /var/bin/mysql directory.

Mysqbinlog I commonly use:

mysqbinlog /var/lib/mysql/localhost-bin.000005 > ~/mysql5.sql
This will put all the content of the logbin to the file mysql5.sql.

mysqbinlog --start-datetime="2011-11-11 11:11:11"  /var/lib/mysql/localhost-bin.000005
This will only display event that is log on and after 2011-11-11 11:11:11.

mysqbinlog --stop-datetime="2011-11-12 11:11:11" /var/lib/mysql/localhost-bin.000005
This will only display event that is log before 2011-11-12 11:11:11.

mysqbinlog --database=liims2 /var/lib/mysql/localhost-bin.000005

This will only display event that is invoke on database liims2.

Hope this will help you on using mysqlbinlog utility.


Saturday, November 12, 2011

Updating from Fedora 15 to Fedora 16

I have update my fedora 15 to 16 successfully today. So know I will share you the step.

First install the new Fedora 16 gpg key.
rpm --import
then upgrade all packages using this commands.
yum update yum
yum clean all
yum --releasever=16 --disableplugin=presto distro-sync

you must have a root permission to do all the command above. so use sudo or log in as a root

Thursday, November 10, 2011

Maven - Installing Dependencies in your Local Computer

This is not something new to me. I just need to document this activity before I forget it again.

There are times when your .jar or api's are not in a central repositories for some reason. This is the time when installing dependencies in your local computer is applicable.

Here are the ways:
1. Install the dependency locally using the install plugin.

maven install:install-file -Dfile=foobar.jar -DartifactId=for-bar -Dversion=1 -Dpackaging=jar
2. Create your own repository and deploy it there. This is a fovrite method for companies with an intranet and need to be able to keep everyone in synch. There is a Maven goal called deploy:deploy-file which is simlar to the install:install-file goal.

On the two ways stated above, I normally used the 1st one if the project is been done by I alone. And if it is a team project, the 2nd ways is what I used.