November 18, 2004
Network Problem
ServInt experienced 6 hours down time due to fiber cut yesterday, it's quite frustrating. Besides losing orders, I'm more concerned about the possible search engine ranking. Google was doing a deep crawl on one of my websites before the server was down - which I have been waiting for days, I have no idea how Google deals with this, will it arrange the deep crawl next day or till weeks later?
But anyway, the problem was solved quickly, I think 6 hours for a fiber cut problem is not long. According to ServInt's post-outage email, the CEO has got Deutsche Telecom as another fiber provider, this will solve the single link problem.
Here is a picture of the fiber cut spot, I feel much better when I saw it :-).

Category : General
Posted by FreeBSD Newbie at 05:33 PM | Comments (0)
Monitor Your Server
You might want to monitor your server since you have to take care of it yourself, here are two websites which offer free service, they will send you email in case your server is inaccessible:
siteuptime.com
Update(Mar. 3rd, 2005): After using both service for three months, I removed one because of reliability. siteuptime.com is very reliable, never failed to report when the server is inaccessible, nor gave error report when server is fine.
Category : Tips
Posted by FreeBSD Newbie at 05:01 PM | Comments (0)
November 06, 2004
Screen Command
My Windows XP suddenly crashed when I was running a long-time Linux script, then I tried to find a way to regain the lost output, but it seems not possible, during the search on Google, I found a very useful Linux command: Screen
You can open a virtual terminal with screen command, in which you can do everything like in the normal terminal, but you can detach it if you want to do other things in the main terminal and reattach it later. It even works after you quit your main terminal, for example, your Windows crashs :-).
Common screen command:
1. Start a new terminal:
# screen
2. Type CTRL+A and D to detach this new terminal
3. Reattach it:
# screen -R
If you have more than one screens, you will be reminded how to specify certain screen, it has very clear on-screen instruction.
List all screens:
# screen -list
Reattach a screen by pid:
# screen -R pid
Detailed usage:
Continue reading "Screen Command"
Category : Command & Utility
Posted by FreeBSD Newbie at 05:27 AM | Comments (1)
November 04, 2004
Redirect Output to Email
If you prefer to reading long document or output on Windows, output redirect does this job well, for example,
# mysqladmin variables | mail yourname@domain.com
But I don't know why the following command doesn't work, only got an empty message.
# man crontab | mail yourname@domain.com
(Update: please read comments for explanation)
Category : Tips
Posted by FreeBSD Newbie at 01:50 PM | Comments (2)
Optimizing MySQL
A ServInt forum member posted the following tutorials for MySQL optimization:
MySQL's Query Cache
Optimizing MySQL: Queries and Indexes
Optimizing MySQL: Hardware and the Mysqld Variables
The first one is directly related to administration, I followed the article and inserted two lines into the file "/etc/my.cnf".
query-cache-type = 1
query-cache-size = 20M
But this doesn't work, this can be checked with the following MySQL command.
mysql> SHOW STATUS LIKE '%qcache%';
I hate it when you followed an article carefully but it didn't work. Tanfwc on ServInt forum shared his my.cnf, it works great after I merged it into mine. If you use this file, make sure your my.cnf doesn't have duplicated entries and insert the code into the right sections.
[mysqld]
max_connections = 500
key_buffer = 32M
myisam_sort_buffer_size = 64M
join_buffer_size = 1M
read_buffer_size = 1M
sort_buffer_size = 2M
table_cache = 1024
thread_cache_size = 64
wait_timeout = 1800
connect_timeout = 10
max_allowed_packet = 16M
max_connect_errors = 10
query_cache_limit = 1M
query_cache_size = 32M
query_cache_type = 1
skip-innodb
[mysqld_safe]
open_files_limit = 8192
[mysqldump]
quick
max_allowed_packet = 16M
[myisamchk]
key_buffer = 64M
sort_buffer = 64M
read_buffer = 16M
write_buffer = 16M
Here is the new output with query cache enabled:
mysql> SHOW STATUS LIKE '%qcache%';
+-------------------------+----------+
| Variable_name | Value |
+-------------------------+----------+
| Qcache_queries_in_cache | 671 |
| Qcache_inserts | 17227 |
| Qcache_hits | 46232 |
| Qcache_lowmem_prunes | 0 |
| Qcache_not_cached | 152 |
| Qcache_free_memory | 31787024 |
| Qcache_free_blocks | 238 |
| Qcache_total_blocks | 1687 |
+-------------------------+----------+
8 rows in set (0.01 sec)
Category : MySQL
Posted by FreeBSD Newbie at 09:24 AM | Comments (0)
November 03, 2004
Cron Job
Cron job is a very convenient tool in Linux, there are lots of information if you search "cron job" on Google, for example, this is a very comprehensive guide.
It seems to be easy, but it took me a lot of time to setup a cron job, here are some advice if you can't make your cron job running.
1. Add a mailto line at the beginning, it will send you the result by email, it's very helpful to debug the problems.
MAILTO="yourname@yourdomain.com"
2. Cron job has different environment from your shell command. Even you can run your script at the command line, it doesn't mean cron job has no problem with it. You can get cron job environment using the following code, then compare with the command line result by running "env", make sure you have inserted the mailto line.
* * * * * /usr/bin/env
3. Always use absolute path. Cron job doesn't run a script in the directory as you expected. Besides the script path, if the script itself takes file names as parameter, you also must use absolute path, my cron job failed here, for example:
30 * * * * /home/username/run.sh
Content of run.sh:
/usr/bin/php /home/username/www/dosomething.php
You should be able to solve most cron job problems with above tips.
Open question for myself:
1. How to modify cron job environment?
2. MAILTO="account_name" (not full email address) doesn't work. Email to other accounts at the command line doesn't work either, this should be related with the server email configuration.
3. It seems that the MAILTO sends all cron jobs result, I don't want to watch every task, is it possible to specify only certain cron jobs?
Eric answered my question, it works great, thanks!
----------------------------
You can redirect the output of a cron job to null, then it won't be mailed to you. Where you currently have the command to execute, such as:
/path/to/somecommand
change it to be like this:
/path/to/somecommand >/dev/null
Since you can redirect to null on individual jobs, you can choose those jobs which you no longer want email from.
----------------------------
Category : Command & Utility
Posted by FreeBSD Newbie at 02:05 PM | Comments (2)
Recursively FTP Files
How to get files recursively by FTP?
Update: NcFTP doesn't work well on some FTP servers, the best way to transfer files is using tar command.
NcFTP Client is a very nice tool which enables you get/put files recursively. I used it to transfer my sites, the whole procedure becomes very fast and easy: get all files, export/import DB data, setup necessary configuration for some program (e.g. blog, forums), done. You don't have to upload everything with slow home connection, also needn't to change the scripts' file attributes since FTP maintains all file information. NcFTP also supports bookmarks which is very convenient.
Download the source file here, extract all files and read README.txt for installation guide, it is very straightforward, just run:
# ./configure
# make
# make install
The third step needs root account, but after installation, all users can use the program.
The command for getting files recursively is:
# get -R filename
(You might want to replace "filename" with "." to get current directory.)
Category : FTP
Posted by FreeBSD Newbie at 08:24 AM | Comments (0)
About This Blog
I started building my websites since 2001 and only used shared hosting until last week. As the websites growing, I feel a strong need of a dedicated server. Shared web hosting is very limited in many aspects, such as disk space, traffic volumn and shell access, the last one is most important to me.
After looking around for a while - mainly on WebHostingTalk.com, I got three option to get my own server:
1. A fully managed dedicated server (ex. theplanet.com), but it is too expensive for me at the moment.
2. An unmanaged dedicated server. There are some really cheap options (under $70/month), e.g. 15minuteservers.com, iPowerWeb.com, etc. But you have to take care of everything yourself, such as system upgrade, backup, security, etc. After I considered it very carefully and decided not to go for it, at least before I have reasonable Linux knowledge.
3. VPS, this is my final decision, VPS stands for virtual private server, I never heard of this word before. Basically it's a server running like a dedicated server, but you are actually sharing with other people, for more information about VPS, please visit my VPS provider's website: ServInt.com.
I ordered my VPS last week and started transferring all my websits. It's really hard for a Linux newbie like me, I feel lost in most time, Fortunately ServInt has very fast support and a private VPS forum to ask all my dumb questions :-). Now all my sites have been up and running, although I still have a lot of things to do. During this time, I came across with many question as well as some nice tips, which urges me to write everything down to make my life easier in the future.
My background:
I'm a Java programmer with little Linux knowledge, especially on administration part. should I blame my nice system administrator colleagues :-)? They always setup a very convenient environment for us developers, when I need to do something on our server, normally all I have to do is running a shell script to get everything done.
If you are also a Linux newbie, I hope this blog is a little useful to you; If you are an expert, that's great, any comment on my posts is much appreciated.
Category : General
Posted by FreeBSD Newbie at 08:22 AM | Comments (3)
