9. Let the sequence $\left\{a_{n}\right\}\left(a_{n}>0\right)$ have the sum of its first $n$ terms as $S_{n}$, and the arithmetic mean of $a_{n}$ and 2 equals the geometric mean of $S_{n}$ and 2. Then the general term of $\left\{a_{n}\right\}$ is ( ).
(A) $a_{n}=n^{2}+n$
(B) $a_{n}=n^{2}-n$
(C) $a_{n}=3 n-1$
(D) $a_{n}=4 n-2$
9. D.

According to the problem, we have $\frac{a_{n}+2}{2}=\sqrt{2 S_{n}}$. Therefore,
$$
\begin{array}{l}
S_{n}=\frac{\left(a_{n}+2\right)^{2}}{8}, \\
S_{n-1}=\frac{\left(a_{n-1}+2\right)^{2}}{8}(n \geqslant 2) .
\end{array}
$$
Subtracting (2) from (1) and simplifying, we get
$$
\left(a_{n}+a_{n-1}\right)\left(a_{n}-a_{n-1}-4\right)=0 .
$$

Since $a_{n}>0$, it follows that $a_{n}-a_{n-1}=4$.
From equation (1), we get $a_{n}=2$.
Thus, the sequence $\left\{a_{n}\right\}$ is an arithmetic sequence with the first term 2 and common difference 4, i.e., $a_{n}=4 n-2$.