I tried to installed Nagios on my web server today, hoping it could help me monitoring the server and report any problem it can detect.
After I followed instruction on:
http://nagios.sourceforge.net/docs/3_0/quickstart-fedora.html
/usr/sbin/usermod -G nagcmd apache
to change group of apache, my server went completely down! Apache refused me from accessing any pages on mysite.
I initially thought it was related to SELinux setting, but later I figured, my SELinux is not enabled.
After reviewing secure log, I noticed apache was removed from the following two groups:
apache
psaserv
By adding it back to those groups, my sever is running OK again.
Well, be careful when you change any group setting :(
Friday, January 25, 2008
Friday, January 18, 2008
How to keep program running when ssh session is closed or network is disconnected
I guess most of sys admin or unix server had same experience as I had. Very often, I start a long task, such as disk backup, in a remove ssh terminal. After leaving it running for so many hours, suddenly a quick network disconnection will ruin all the work done before completely! A very quick network instability could drop the ssh session, and all the running work in the session simply got dropped! This is too annoying.
Today, I finally found a great tool to resolve the issue: GNU Screen.
I found a bunch of good tutorials about the great tool. One of my favorite is:
http://www.kuro5hin.org/story/2004/3/9/16838/14935
The tool can be found at:
http://www.gnu.org/software/screen/
Most likely, you probably already have it in your installation, or can simply run:
apt-get install screen
or
yum install screen
to get it.
The idea of screen, I guess, is to create a bunch of local session to terminal services. What your SSH will only connect to the local session, and the real work will be done in the local session. So even you lose connection to screen, your work is still running. When your network is back, you simply attach to the screen session, and you can get everything back. The idea is really similar to VNC or other remote control tools.
For more information about the tool, please check the links I provided above. Hopefully it can resolve lots of headache you already had.
Today, I finally found a great tool to resolve the issue: GNU Screen.
I found a bunch of good tutorials about the great tool. One of my favorite is:
http://www.kuro5hin.org/story/2004/3/9/16838/14935
The tool can be found at:
http://www.gnu.org/software/screen/
Most likely, you probably already have it in your installation, or can simply run:
apt-get install screen
or
yum install screen
to get it.
The idea of screen, I guess, is to create a bunch of local session to terminal services. What your SSH will only connect to the local session, and the real work will be done in the local session. So even you lose connection to screen, your work is still running. When your network is back, you simply attach to the screen session, and you can get everything back. The idea is really similar to VNC or other remote control tools.
For more information about the tool, please check the links I provided above. Hopefully it can resolve lots of headache you already had.
Monday, January 14, 2008
How to config apache to set bandwidth limitation
Here's a nice document about how to set bandwidth limitation on Apache 2 with a module called mod_cband.
http://www.howtoforge.com/mod_cband_apache2_bandwidth_quota_throttling
http://www.howtoforge.com/mod_cband_apache2_bandwidth_quota_throttling
Monday, January 7, 2008
Download older version of Oracle products
Oracle only put the latest supported product on their site for download. If by any chance an older version is required, you can go to the following site to see if you can find the old version you need:
http://edelivery.oracle.com/
I was looking for Oracle client 10.1.0.3.0 when Oracle only had 10.2.0.4.0 for download. After about 1 month of search, I finally found 10.1.xxx from that site.
http://edelivery.oracle.com/
I was looking for Oracle client 10.1.0.3.0 when Oracle only had 10.2.0.4.0 for download. After about 1 month of search, I finally found 10.1.xxx from that site.
Tuesday, January 1, 2008
Fix display problem when running Far Manager in Chinese environment
Far Manager is the greatest file manager I have been using over the longest time and cannot live without.
Besides of all the great features and plugins, I do keep running into an annoying issue on my Windows with region set to Chinese. The problem is in Chinese environment, FAR window will be screwed with panel borders shown as garbage characters like below :

I have tried many ways to resolve the issue.
On Win95 through XP, I was able to create a batch file just to start Far, create a shortcut to the batch and set Code Page to English. Although I will not be able to see any Chinese file names, the display looks good.
But in Vista, somehow the code page dropdown turned to be empty. So I had to search for other solutions. Luckily, I do find something very handy which I will share below. Basically you can create a shortcut, and enter the following command into it:
The idea is simple, it set current code page to 437 by "chcp 437". 437 is English in Windows.
Then start Far.
Please be advised, I'm running Vista 64bit. If you run in 32bit OS, the path is different. But it does not matter.
I also often change layout of shortcut to: 100 x 50:

Click on the shortcut, you will see a nice Far window:

I think the trick also works on other locales in case you run into the same issue.
Just heard Far goes open source! What a great news! Wow!!!
Besides of all the great features and plugins, I do keep running into an annoying issue on my Windows with region set to Chinese. The problem is in Chinese environment, FAR window will be screwed with panel borders shown as garbage characters like below :

I have tried many ways to resolve the issue.
On Win95 through XP, I was able to create a batch file just to start Far, create a shortcut to the batch and set Code Page to English. Although I will not be able to see any Chinese file names, the display looks good.
But in Vista, somehow the code page dropdown turned to be empty. So I had to search for other solutions. Luckily, I do find something very handy which I will share below. Basically you can create a shortcut, and enter the following command into it:
C:\Windows\System32\cmd.exe /c chcp 437&&"C:\Program Files (x86)\Far\far.exe"
The idea is simple, it set current code page to 437 by "chcp 437". 437 is English in Windows.
Then start Far.
Please be advised, I'm running Vista 64bit. If you run in 32bit OS, the path is different. But it does not matter.
I also often change layout of shortcut to: 100 x 50:

Click on the shortcut, you will see a nice Far window:

I think the trick also works on other locales in case you run into the same issue.
Just heard Far goes open source! What a great news! Wow!!!
Monday, December 3, 2007
Start multiple versions of Firefox at the same time in Windows
I have been long time Firefox user. I started using Firefox since it was 0.7 or so.
Now Firefox 2.0 has been used for my most day-to-day work, its profile contains lots of my cookies, passwords, plugins, etc. which I rely on everyday.
But 2.0 is famous as a memory eater. It can easily use up to 500M of RAM, and make my Vista 64bit with 4G of RAM running slow. So I started trying Best 3. It works great, and eats up way less RAM than 2.0 does. However, since all plugins in my 2.0 are not supported in 3.0 beta yet, I do need to switch back and force between the two versions. By Googling for a while, I found a site and learned the trick there. Basically I need to create a short cut for my 2.0 Firefox as:
C:\Windows\System32\cmd.exe /C set MOZ_NO_REMOTE=1 & start "Firefox" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -p default
and another shortcut for my 3.0 Beta as:
C:\Windows\System32\cmd.exe /C set MOZ_NO_REMOTE=1 & start "Firefox" "C:\Program Files (x86)\Mozilla Firefox 3 Beta 1\firefox.exe" -p "Li Ma Test"
Now the two works greatly together.
The trick is to create a new profile named as Li Ma Test. You need to run Firefox with the following command line option:
-ProfileManager
Then you can create a new profile to be used by the shortcut.
The two useful sites I found were:
http://www.hiveminds.co.uk/node/3114
and
http://www.google.com/search?source=ig&hl=en&rlz=1G1_____ENUS242&q=firefox+command+line&btnG=Google+Search
Enjoy!
And hope 3.0 Beta can go to final soon.
Now Firefox 2.0 has been used for my most day-to-day work, its profile contains lots of my cookies, passwords, plugins, etc. which I rely on everyday.
But 2.0 is famous as a memory eater. It can easily use up to 500M of RAM, and make my Vista 64bit with 4G of RAM running slow. So I started trying Best 3. It works great, and eats up way less RAM than 2.0 does. However, since all plugins in my 2.0 are not supported in 3.0 beta yet, I do need to switch back and force between the two versions. By Googling for a while, I found a site and learned the trick there. Basically I need to create a short cut for my 2.0 Firefox as:
C:\Windows\System32\cmd.exe /C set MOZ_NO_REMOTE=1 & start "Firefox" "C:\Program Files (x86)\Mozilla Firefox\firefox.exe" -p default
and another shortcut for my 3.0 Beta as:
C:\Windows\System32\cmd.exe /C set MOZ_NO_REMOTE=1 & start "Firefox" "C:\Program Files (x86)\Mozilla Firefox 3 Beta 1\firefox.exe" -p "Li Ma Test"
Now the two works greatly together.
The trick is to create a new profile named as Li Ma Test. You need to run Firefox with the following command line option:
-ProfileManager
Then you can create a new profile to be used by the shortcut.
The two useful sites I found were:
http://www.hiveminds.co.uk/node/3114
and
http://www.google.com/search?source=ig&hl=en&rlz=1G1_____ENUS242&q=firefox+command+line&btnG=Google+Search
Enjoy!
And hope 3.0 Beta can go to final soon.
Saturday, December 1, 2007
Implement resumable file download by PHP
I had a requirement to implement a file downloading service with Apache + PHP.
The files are all uploaded by another tool. All uploaded files are renamed to UUID, and a UUID.info file is attached to store corresponding information of the original file.
Now at downloaded side, I need to:
1. verify UUID info before download
2. still able to download the file into the original file name instead of a user-in-friendly UUID.
3. Support browser and download manager, such as FlashGet
Without PHP code the 1 and 2 could not be accomplished.
But to support 3, PHP does not have any built-in support. Especially when considering downloading large files from server, PHP normally does not work well.
Luckily, I found a PHP class from:
http://www.phpclasses.org/browse/package/2221.html
Big thanks to the author, I was able to implement all I needed in less than 30 lines of my code :)
Hopefully, my finding can be helpful to you.
Li
The files are all uploaded by another tool. All uploaded files are renamed to UUID, and a UUID.info file is attached to store corresponding information of the original file.
Now at downloaded side, I need to:
1. verify UUID info before download
2. still able to download the file into the original file name instead of a user-in-friendly UUID.
3. Support browser and download manager, such as FlashGet
Without PHP code the 1 and 2 could not be accomplished.
But to support 3, PHP does not have any built-in support. Especially when considering downloading large files from server, PHP normally does not work well.
Luckily, I found a PHP class from:
http://www.phpclasses.org/browse/package/2221.html
Big thanks to the author, I was able to implement all I needed in less than 30 lines of my code :)
Hopefully, my finding can be helpful to you.
Li
Subscribe to:
Posts (Atom)