A few methods for dealing with Barbarian Units (and misc. info; #4 is based on my own work and that of KMadCandy's a while back)
1) Fogbusting: Barbarians spawn in the 'fog of war', the hazy graying of terrain outside your city's Line of Sight. Thus, the less fog there is, the less spawn. This applies to AI Civilizations as well; wherever a Civilization can see, Barbarians cannot spawn. To help eliminate Fog of War, build a few Archers and give them Guerrilla I (Axes and Chariots work as well, but don't get hill defense promotions; give them Combat I, then Cover or Shock). Plant them on a hill at the edge/in the middle of flat terrain, and watch as the barbarians head for them. Now, if the Barbarians ignore them, have a few Mounted Units ready to defend.
2) Sizable Army: Keep Units on your necessary resources in the 'frontier', the area where your borders meet no-man's land. Plant Archers or Axemen on Metals (Iron, Copper, Gold, Gems, Silver), Food (Wheat, Rice, Sheep, Pigs, Cows, Corn) or other military resources (Horses, Ivory) whenever necessary. Inevitably, upkeep costs will go up, so if there is a resource within one-turn reach from a city, keep an Axeman on Sentry mode within the city. When the Barbarian comes within a one-tile radius of the resource, you can attack.
3) The Great Wall: As someone earlier pointed out, never, ever build this just for the Barbarian threat. Build it instead for the extra Great General and Great Spy points. However, it remains an excellent deterrent to the Barbarian. Its powers extend throughout your culture, not just the area hemmed in by the Wall graphics.
4) Barbarian Civilization: Barbarians cannot build most Wonders (The Great Lighthouse, The Colossus, and a few others IIRC are exceptions), and some buildings, one of which is the Palace. Their cities spawn the same way as their Units. The Civilization controls all Barbarian Animals, Units, and Cities around the globe. When more than 2/3 of the AI/Human Civilizations on a map know a certain tech, the Barbarian will gain that knowledge. However, their straight research and production times are very long compared to those of a normal Civilization. They can use Workers and build Units/Buildings similar to that of an AI.