  We prove a local-global principle for the embedding problems of global fields
with restricted ramification. By this local-global principle, for a global
field $k$, we use only the local information to give a presentation of the
maximal pro-$p$ Galois group of $k$ with restricted ramification, when some
Galois cohomological conditions are satisfied. For a Galois $p$-extension
$K/k$, we use our presentation result for $k$ to study the structure of pro-$p$
Galois groups of $K$. Then for $k=\mathbb{Q}$ and $k=\mathbb{F}_q(t)$ with
$p\nmid q$, we give upper and lower bounds for the rank of $p$-torsion group of
the class group of $K$, and these bounds depend only on the structure of the
Galois group and the inertia subgroups of $K/k$. Finally, we study the $p$-rank
of class groups of cyclic $p$-extensions of $\mathbb{Q}$ and the $2$-rank of
class groups of multiquadratic extensions of $\mathbb{Q}$, for a fixed
ramification type.
