Good Team Plays Hard
In: Ubuntu or Linux
7 May 2012Most of the time I use du -h to query the disk usage but the result list is just way too long to really analyze which directory use the most disk space. Today I come across this dilemma again, I need to find a ways to remove some of the junk so I can free up some disk space of the server. Below is the command that I executed, you can mess around with the max-depth variable to help you analysis:
du -hx –max-depth=1 / | perl -e ‘%byte_order = ( G => 0, M => 1, K => 2 ); print map { $_->[0] } sort { $byte_order{$a->[1]} <=> $byte_order{$b->[1]} || $b->[2] <=> $a->[2] } map { [ $_, /([MGK])/, /(\d+)/ ] } <>‘
When you try to query a database column that have the Apostrophes symbol, it’s kind of abnormal. Recently try to query some foreigner’s name that have apostrophes in them which start out my try and error SQL adventure.
SELECT * FROM `test` WHERE `Name` LIKE '%'%';
[Err] 1064 – You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near ‘%” at line 2
Then I try another method:
SELECT * FROM `test` WHERE `Name` LIKE '%''%';
And bingo! I got what I was looking for. The problem lies in the fact that SQL Server assumes the predicate is done after the second single quote. SQL Server sees everything after that second single quote as an error in your SQL code. Your intentions were lost or misunderstood.
In: MySQL
4 Aug 2011Recently I want to find a specific column in a database but I forgot which table it resides. I know my information will be inside the information_schema database. So I just launch a mysql console and run the command below:
SELECT TABLE_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE column_name LIKE '<something>'
This command save my day on going through all the tables to search that particular column.
In: Ubuntu or Linux
28 Jul 2011Recently I had faced with the dilemma of wanting to increase the system memory of a 32 bit linux system to more than 4GB. At first I though this will be a mission impossible, but after some googling I had found out something about Physical Address Extensions (PAE). Long story short, you can install PAE to your linux kernel to add memory support of more than 4GB. In order to install PAE, just use yum:
# yum install kernel-PAE
Just reboot the server and make sure you boot with PAE kernel i.e. 2.6.18-8.1.15.el5PAE:
# reboot
In: Ubuntu or Linux
20 Jun 2011In order to install Sun JDK on Ubuntu 11.04 Natty Narwhal, please follow the steps below:
In: Iphone
11 Oct 2010Today limera1n had released the jailbreak solution for the new iphone 4 4.1. Congratulation for those who had installed this release. However I just got one important tips for those peoples that had jailbreak their phone, REMEMBER TO CHANGE YOUR ROOT PASSWORD! So you didn’t end up crying and complaining in the end. Now I will try to provide the steps to achieve this below:
Hope the steps above help you on securing your iphone 4.
In: Ubuntu or Linux
24 Sep 2010Previously I successfully get the jboss to run behind apache using the mod_jk module. Recently I have to deal with similar issue, only this time is configure the tomcat to run behind apache 2.2.
The Ubuntu-supplied Tomcat doesn’t listen for for AJP1.3 requests on port 8009 by default, so edit /var/lib/tomcat6/conf/server.xml, search for “8009″ and uncomment the AJP1.3 connector module:
/var/lib/tomcat6/conf/server.xml
…
…
Restart Tomcat, giving it time to start the listeners, and check that it is listening on port 8009:
$ sudo /etc/init.d/tomcat6 restart * Stopping Tomcat servlet engine tomcat6 [ OK ] * Starting Tomcat servlet engine tomcat6 [ OK ] $ sudo netstat -ln | grep :8009 tcp6 0 0 :::8009 :::* LISTEN
For Lucid, restart Tomcat with $ sudo service tomcat6 restart.
If the listener is listening, Tomcat should be good to go.
To get Apache to talk to Tomcat, the first step is to install the AJP1.3 connector module mod_jk:
$ sudo apt-get install libapache2-mod-jk2
For Lucid, package is libapache2-mod-jk.
With the default Ubuntu packaging, this is all set up and should be loaded without any further intervention. The key to this is that /etc/apache2.conf includes all modules listed in /etc/apache2/mods-enabled. There’s no need to add the LoadModule directive to apache2.conf as you might see quoted in some places.
Then it’s just a matter of configuring Apache to route some requests through to Tomcat.
The core of the Apache configuration looks like this on a default Ubuntu setup:
JkWorkersFile /etc/apache2/workers.properties JkShmFile /var/log/apache2/mod_jk.shm JkLogFile /var/log/apache2/mod_jk.log JkLogLevel error JkLogStampFormat "[%a %b %d %H:%M:%S %Y] " JkMount /MyWebApplication/* tomcat
You have a choice at this point. You can configure this within the default virtual host that Ubuntu’s Apache comes with, or globally.
If you want to configure just for the virtual host, add the above section to the bottom of /etc/apache2/sites-available/default.
If you want to configure the forwarding globally, add the above section to the bottom of /etc/apache2/apache2.conf. In this case, you also need to add an extra line to the sites-available file to get the virtual site to read the mounts. Immediately under DocumentRoot is a reasonable place.
/etc/apache2/sites-available/default
... DocumentRoot /var/www JkMountCopy On ...
The final part of the jigsaw is to set up the worker.properties file now referred to in the Apache config files. So make a new file …
$ sudo touch /etc/apache2/workers.properties
… and edit it. With sudo of course
/etc/apache2/workers.properties
worker.list=tomcat worker.tomcat.type=ajp13 worker.tomcat.host=localhost worker.tomcat.port=8009
Look back at the lines we added to the Apache config files and note that the JkMount directives refer Apache to entries in workers.properties. If you had multiple Tomcat servers, you could achieve some simple application-level load balancing by routing different applications to different servers:
/etc/apache2/workers.properties
worker.list=tomcat_a, tomcat_b worker.tomcat_a.type=ajp13 worker.tomcat_a.host=hosta worker.tomcat_a.port=8009 worker.tomcat_b.type=ajp13 worker.tomcat_b.host=hostb worker.tomcat_b.port=8009
Anyway, I digress. Restart Apache and you should be up and running.
$ sudo /etc/init.d/apache2 restart
This is a place I create just for fun and to write down some experience and notes for myself. So feel free to enjoy and drop any comments you have. I had been employed as Programmer, System Analysts, System Administrator, DBA and Project Manager. I will share some of my case study here as well. Enjoy!