How to move a large database from one Linux server to another

Suppose you have a virtual server with a massive database that you need to move from one Linux server to another. Let’s also assume that you don’t have copious amounts of bandwidth at your disposal to download and upload the SQL files. I have found that the simplest method to move large files between two servers, is by using an application called rsync.

rsync is a software application and network protocol for Unix, Linux and Windows systems which synchronizes files and directories from one location to another while minimizing data transfer using delta encoding when appropriate.

Simply follow the steps below to transfer your database to a new Linux server.

 

1. Backup your database.

mysqldump -u root -p database_name > dumpfilename.sql

Once complete, type “ls -al” to view the details of your SQL file for interest’s sake.

ls -al

2. Compress your file.

gzip dumpfilename.sql

Take a look at this site for more information on compressing files in Linux

3. Install rsync on BOTH servers.

sudo yum install rsync

4. Transfer the file to your new server.

rsync -v -e ssh dumpfilename.sql.gz root@ipaddress_of_your_server:~

“dumpfilename.sql.gz” represents the zipped file that we just compressed using step 2 above.
“~” represents the home directory.
“root” represents your SSH username
“ipaddress_of_your_server” represents the, you guessed it, IP address of your server.

5. Decompress the file on the new server

gzip -d dumpfilename.sql.gz

6. Create your mysql database on the new server
Remember to keep the name the same as the old server’s database as we will be attempting to import it to a database with the same name.

7. Import your SQL file

mysql -u root -p  dbname < dumpfilename.sql

Your database move is complete!

Let me know if you need help or get stuck by using the comment section below.

How to reduce your CPA with minimal effort

Forget about how great your click through ratio is and how many visitors your managed to get off that one keyword and take a moment to focus on your actual CPA, or Cost per Acquisition (a.k.a. Cost per Lead). This has become somewhat of a buzz word in the South African online advertising industry as of late, though it really should have been a key factor straight off the bat. Online agencies have been focusing their attention more on CTR’s and the sheer volume of visitors and have forgotten to focus on what really counts – you’re Return on Investment!

Reducing your CPA can take a lot of brain power, epic late nights and can add to your grey hair at a rate second to none. With that being said, I have decided to help you out with a series of tips to keep you “above the fold”. These tips will help you reduce your CPA in a matter of days, rather than months. The steps below are related to how you can optimise your landing pages in order to reduce your CPA.

Remove 99% of the links on your page

Depending on your product or goal of your landing page, ensure that you have removed any links that can distract the user from turning into a sale or a lead. If you have all the information that the user needs on your landing page, the user shouldn’t need to click on anything but the call to action you want them to click on. By simply removing the navigation and other distracting links from your page you will reduce the movement away from your page by up to 30%, which in turn can improve your conversion rate by 3% or more.

Optimise “Instinctiveness”

The user needs to instinctively know what to do on the page. Whether they need to fill out an enquiry form or add an item to a shopping cart, make sure that the CTA is as clear to them as a crack in their car’s windscreen. Make the CTA stand out by using different colours to that of your brand and layout. A study has found that a softer blue colour appeals more to users in the morning while an orange tone appeals more to afternoon visitors – fact!

TRUST

Trust plays a massive psychological role in the way a user interacts with your website or landing page. Ensure there are trust elements such as testimonials, SSL certificates and any other image, badge or message you believe will help the user trust your product or service. If you are using SSL, make sure that you have a big badge displaying the fact that the user’s information is secure – this will help increase your conversions by more than 5%

 

Optimising these three elements of your landing page could double or even triple your current conversion rate and thereby reduce your CPA with little effort. Remember to keep testing different variations of your landing pages in order to fully optimise your CPA.

Top Group Buying Websites in South Africa (Updated May 2011)

Group Buying websites have become very popular in the past few months, so much so that every Tom, Dick and Sipho have decided to create one of their own. With the help from a list compiled over at iGeek, I took the time to analyse which of these group buying websites are actually making an impression on the South Africa internet landscape.

*** 23 May 2011 (Latest)

Rank Website Alexa Rank (ZA) Unique Visitors (AdPlanner)
1 My City Deal 50 420k
2 Ubuntudeal 296 14k
3 WiCount 302 48k
4 CityMob 488
5 Zappon 524 12k
Twangoo 896 11k
VuvuPlaza 943 15k
OneDayOnly 1258 5.3k
Dealio 1701
24 Hours Only 1941
Skoop 2293
AllDeals 2599
UCit 5073
Collective Cow 8360
SaleWine 9636
Justhenga 12 228
Bangoo 14 623
GroupBuying 20 828
DealsOn 21 057

The biggest climber for May was Zappon.

 

*** as at 30 Mar 2011

Rank Website Alexa Rank (ZA) Unique Visitors (AdPlanner)
1 My City Deal 39 350k
2 WiCount 248 44k
3 Twangoo 333 27k
4 Ubuntudeal 655 10k
5 OneDayOnly 868 7.9k
Zappon 295 (* new)
Dealio 1030
Skoop 1826
UCit 1913
24 Hours Only 1944
VuvuPlaza 2559
Collective Cow 3252
Justhenga 7575
Bangoo 7638
AllDeals 8131
SaleWine 11382
DealsOn 13737
GroupBuying 19339

 

Although Zappon was only recently created, Alexa.com believes its already the 295th ranked website in SA. Pretty impressive.

Which one is your favourite?

Cache certain areas of your page using PHP

Sometimes it’s necessary to cache only certain elements or areas of your dynamic website to speed up the load times. I recently needed to cache two DIV’s that were being dynamically generated on one of my websites.

Sometimes it’s necessary to cache only certain elements or areas of your dynamic page to speed up the load times. I recently needed to cache two DIV’s that were being dynamically generated on one of my websites. They were each taking about 10 seconds to load which as you know, can be detrimental to your SEO efforts. Here’s the steps I followed in order to reduce my page load times from 20 seconds to under 1.5 seconds.

Step 1: Separate the areas

First of all, you would need to make the areas you would want to cache separate from the page. You can do this by creating new files for these areas and using the “include (‘page_name.php’);” function. This allows us to better control that specific file for caching purposes.

Code:

<div id="pane_popular">
<? 
      // this is one of the divs we want to cache
      include('div_top_articles.php'); 
?>
</div>

Step 2: Create the cache directory
Create a directory called “cache” on your web server. We will reference this in step 3.

Step 3: Insert the PHP cache code

Insert the following script at the top of the included file (in this case it’s the ‘div_top_articles.php’ file).

Code:

<?
    $cachedir = 'cache/'; // Cache directory
    $cachetime = 600; // Seconds to cache files for
    $cacheext = 'cache'; // Extension to give cached files (usually cache, htm, txt)
 
    // Script
    $page = 'http://' . $_SERVER['HTTP_HOST'] . $_SERVER['REQUEST_URI'];
    $cachefile = $cachedir.md5($page).'.'.$cacheext; // Cache file to either load or create
 
    $cachefile_created = ((@file_exists($cachefile))) ? @filemtime($cachefile) : 0;
    @clearstatcache();
 
    // Show file from cache if still valid
    if (time() - $cachetime < $cachefile_created) {
 
        //ob_start('ob_gzhandler');
        @readfile($cachefile);
        //ob_end_flush();
 
    }
    else {
    // If we're still here, we need to generate a cache file
 
        ob_start();
 
        // <CONTENT THAT YOU WANT CACHED-->
        // ----------------------------------------------------
        // ----------------------------------------------------
 
        show_latest_articles(10,"latest");
        echo "<small><small>Cached on: ".date("Y-m-d H:i:s")."</small></small>";
 
        // ----------------------------------------------------
        // ----------------------------------------------------
        // 
 
        // Now the script has run, generate a new cache file
        $fp = @fopen($cachefile, 'w'); 
 
        // save the contents of output buffer to the file
        @fwrite($fp, ob_get_contents());
        @fclose($fp); 
 
        ob_end_flush();
    }
 
?>

Code thanks to AddedBytes, modified slightly.

That’s all there is to it.