Before Runs: An hour before you start your run, try to drink 16 to 24 ounces of water or other non-caffeinated fluid. Stop drinking at that point, so that you can void extra fluids and prevent having to stop to go to the bathroom during your run. To make sure you're hydrated before you start running, you can drink another 4 to 8 ounces right before you start.
During Runs: The general rule of thumb for fluid consumption during your runs: You should take in 6 to 8 ounces of fluid every 20 minutes during your runs. During longer runs (90 minutes or more), some of your fluid intake should include a sports drink (like Gatorade) to replace sodium and other minerals (electrolytes) lost through sweat. Muscle cramping often occurs as a result of electrolyte imbalance, so it's critical that you replace your electrolytes.
After Runs: Don't forget to rehydrate with water or a sports drink after your run. If your urine is dark yellow after your run, you need to keep rehydrating. It should be a light lemonade color.
Staying well-hydrated will help prevent muscle cramps, but if you're dealing with cramps on a run, try slowly stretching the affected area. Stopping to stretch for a minute or two during a run will help keep the cramps from getting worse.
Going for a sports massage is a good way to treat soreness that often develops as a result of muscle cramps. Regular massages also help keep your muscles in optimal shape, greatly reducing your chances of muscle cramping during runs.

