Here are some things you can do to prevent yourself from getting altitude sickness.
1. Avoid flying directly to areas of high altitude, if possible.
2. Take 2-3 days to get used to high altitudes before going above 3,000m.
3. Avoid climbing more than 300-500m a day.
4. Have a rest day every 600-900m you go up, or every 3-4 days.
5. Make sure you're drinking enough water.
6. Avoid alcohol.