Archive

Archive for the ‘howto’ Category

Ubuntu 11.10 performance tuning

November 19, 2011 4 comments

I recently upgraded my netbook’s OS to Ubuntu 11.10 and noticed that it’s taking longer than usual to launch programs that I use quite often. For example, it takes 7-8 seconds to launch Google Chrome, about 4 seconds to open terminal. Here’s what I did to make the os run faster without investing with a SSD disk (My root partition is using ext4 fs, skip step 1 through 3 if you are using file systems other than ext3 or ext4):
1. Add the following bold part to the root partition line in /etc/fstab
errors=remount-ro,noatime,data=writeback

2.

tune2fs -o journal_data_writeback /dev/sda5

/dev/sda5 is the root partition.

3. change the following line in /etc/default/grub
GRUB_CMDLINE_LINUX=”rootflags=data=writeback
(bold part is added)

4. Run update-grub
5. Add the following line to /etc/sysctl.conf
vm.swappiness=10

NOTE: all the above changes require root privileges.

6. Reboot

The difference? It now takes about 3-4 seconds to launch Google Chrome from cold start.

Categories: howto, ubuntu

Fixing Tunnelblick (3.1.7) kernel panic problem in Lion

August 3, 2011 Leave a comment

The currently stable version (3.1.7) of Tunnelblick would cause a kernel panic in Mac Lion while a connection is being made. Workaround is to use a beta version (3.2beta28) which is available at http://code.google.com/p/tunnelblick/downloads/detail?name=Tunnelblick_3.2beta28.dmg, released 7/31/2011.

[Edit 8/18/2011] Just updated Lion to 10.7.1 last night and version 3.2beta28 seems to be unstable as well. It has caused kernel panic two times in a row. Need to keep looking for a version that works. Did a re-installation of the same version and it works afterwards.

Change windows xp’s time synchronization frequency how-to

July 28, 2011 Leave a comment

Found the solution here: http://www.pcreview.co.uk/forums/windows-xp-windows-xp-change-time-synchronization-frequency-t325219.html

HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\Services\W32Time\TimeProviders\NtpClient
Default is set to 604800 (7 days, bloodily stupid value chosen by M$?)

Change to a smaller amount, for example, 86400 (1day) or even 3600 (1 hour) if the OS is running some time-sensitive stuff.

A system restart is required for the new setting to be in effect.

Mac OS X Lion terminal color (remote access) problem fix

July 23, 2011 18 comments

After upgrading to Lion I noticed that the Homebrew theme that I’ve been using since Snow Leopard doesn’t display colors correctly(using different colors for directories, different types of files etc.) any more when working on remote hosts via ssh (local dir colors still work though) and switching to other themes doesn’t help. After messing around with the Terminal settings I finally found the cause and a solution. It seems Lion changed the terminal type to xterm-color256 during the upgrade (don’t remember what the setting was in SL though). The solution is simple enough, just change the emulation type for terminal from xterm-color256 to xterm-color (see screenshot below).

[ Update 1/2/2012 ]
Actually found a better solution here:
1. Keep the current xterm-256color in your Mac Terminal
2. Add the following lines to your ~/.profile on your remote host

[ "$TERM" = "xterm" ] && TERM="xterm-256color"
alias ls='ls --color'

3.

. ~/.profile
Categories: dircolor, howto, mac osx

Check apache config syntax without restarting

June 22, 2011 Leave a comment

Command:
apachectl configtest

Found from http://httpd.apache.org/docs/1.3/configuring.html [ first section ]

Categories: apache, howto

Comparing two mysql tables containing huge number of records each

June 15, 2011 Leave a comment

Usually I use the following method to compare two mysql tables with identical structure (or one contains the subset of columns of the other):

select * from db_A.tbl_data
where (col1, col2, col3, ...) not in
(select col1, col2, col3, ... from db_B.tbl_data);

select * from db_B.tbl_data
where (col1, col2, col3, ...) not in
(select col1, col2, col3, ... from db_A.tbl_data)

[ change * to count(*) if only the number of differences is needed ]

This method works pretty well in terms of performance when
1) number of columns to be compared is not too big, usually around 10
2) there are indexes defined in each table, this is very important when number of rows to be compared in each table is huge, I’lve done comparisons between 2M rows agains 2M rows, it can take minutes to finish, even with indexes.

But I ran into performance problem the other day when I tried to compare two identical-structured tables (comparing all 15 columns) with almost 3M rows each, and each table has only 1 index defined. Queries using the first method ran very slowly and I quickly used up patience ( I waited for more than half an hour and even the first query couldn’t got finished). Without other choices, I came up with the following solution:

a) log in to mysql server
b) select * from db_A.tbl_data into outfile '/tmp/outfile_A';
c) select * from db_B.tbl_data into outfile '/tmp/outfile_B';
d) exit mysql console
e) cd /tmp; diff outfile_A outfile_B > diff
f) wc -l diff

if the result from f) is small, I can open up file diff with an editor to see what the differences are, otherwise I can use head diff and/or tail diff to take a glance at the differences. With this method, I got the results in less than 3 minutes, which is a huge improvement compared to the first method.

Categories: howto, mysql, Tip

How to get out from tmux session inside a tmux window

June 8, 2011 4 comments

Here’s how I got stuck:
1) Remote access to a linux serverA
2) Launch tmux, Ctrl-b c to create a new window
3) From the new window, remote access to serverB, then run tmux att under shell to attach an existing tmux session (on serverB)
4) Now if I use the shortcut key Ctrl-b d, I can only detach from the session on serverA, because the tmux session on server B also uses Ctrl-b as the prefix

The fix:
a) Press Ctrl-b n until the window containing the ssh session to server B becomes the current window
b) Press Ctrl-b :
c) Enter tmux command set -g prefix C-a
d) Press Ctrl-b d, tmux session on serverB is now detached, type exit to close the new window created in step 2, this step is optional though as the “nested” tmux session is detached from the ssh shell
e) Press Ctrl-a :
f) Enter tmux command set -g prefix C-b

Step c changes prefix to Ctrl-a so it won’t conflict with the tmux shortcut prefix from serverB. Step f changes the prefix back to Ctrl-b for serverA.

Categories: howto, Tip, tmux
Follow

Get every new post delivered to your Inbox.