While an undergrad at Harvard College, Dana had an attack of the measles which affected his vision. Thinking it might help his sight, Dana left Harvard to enlist as a common sailor on a voyage around Cape Horn on the brig Pilgrim. He returned to Massachusetts two years later aboard the Alert (which left California sooner than the Pilgrim).
 A sailor's story
The term "before the mast" refers to the quarters of the common sailors — in the forecastle, in the front of the ship. His writing evidences his later social feeling for the oppressed; he later became a prominent anti-slavery activist and helped found the Free Soil Party.
Dana did not set out to write Two Years Before the Mast as a sea adventure, but to highlight how poorly common sailors were treated on ships. It quickly became a best seller.
 The journey
In the book, which takes place between 1834 and 1836, Dana gives a vivid account of "the life of a common sailor at sea as it really is". He sails from Boston, around Cape Horn, arriving in California when it was a remote Mexican land, and San Diego, San Pedro, Santa Barbara, and San Francisco were not much more than a few sheds. He gives descriptions of landing at each of the ports up and down the California coast as they existed then. In the book, he makes a tellingly accurate prediction of San Francisco's future. He also gives a nice description of a society wedding amongst the "Californios."
His ship was on a voyage to trade goods from the east for cow hides. Interestingly, the bluffs near Mission San Juan Capistrano presented an obstacle to taking the cow hides to the beach for subsequent loading onto the ship. So, Dana, along with others of the Pilgrim's crew, tossed the hides from the bluffs, while spinning them like a frisbee. Some hides got stuck part way down the cliff and Dana was lowered with ropes to retrieve them. Since that day, that point where the bluffs were located, took on Dana's name, and is today the city of Dana Point. Being an educated person on his ship, he learned Spanish and became an interpreter. He befriended a Kanaka (a native of modern-day Hawaii), later saving his life when his captain would as soon see him die. He spent a season in San Diego preparing hides for the journey home.
On the return trip around Cape Horn in the middle of the Antarctic winter he describes terrifying storms and incredible beauty, giving vivid descriptions of icebergs, and the scurvy that afflicts members of the crew. In White-Jacket, Herman Melville wrote, "But if you want the best idea of Cape Horn, get my friend Dana's unmatchable Two Years Before the Mast. But you can read, and so you must have read it. His chapters describing Cape Horn must have been written with an icicle."