Knowing how to use the roll of the climb to maintain your momentum is important. Most riders slow down on steeper stretches and shift gears. Better climbers just lean on the pedals or stand up on them to carry their momentum up the grade. Losing speed on a long climb is tough on legs because it is hard to regain that speed and it kills your legs to struggle at a slower speed. Learn to attack when the grade eases because it is easier on your legs and others will want to slow to rest.
Long climbs are very mental.
Don't focus on how far it is to the top. Pull inside of yourself and focus on your pace, gearing, using your body to maintain cadence, and racing. Learn to race inside of yourself and the top will get to you sooner. The most common mistake people make in long climbs is how they train. Attack short, steep climbs to build your climbing speed for the longer climbs.